Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added async handling for signals #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

geekrelief
Copy link
Contributor

So we can handle signals with an {.async.} proc like this:

...
import asynchdispatch

gdobj SpriteComp of Sprite:

  signal bsclick(button_idx:int, shape_idx:int)

  method ready() =
    ...
    registerFrameCallback(
      proc() =
        if hasPendingOperations():
          poll(0)
    )
    asyncCheck self.fireTimer()
    self.emit_signal("bsclick", 1.toVariant, 0.toVariant)

  proc fireTimer() {.async.} =
    await on_signal(self.get_tree().createTimer(1), "timeout")
    print "timeout sceneTree"

    var vals = await on_signal(self, "bsclick", tuple[button_idx:int, shape_idx:int])
    print &"bsclick {vals.button_idx = } {vals.shape_idx = }"

cleaned up godotmacros imports
updated code sample at bottom of godotmacros.nim
@arunvickram
Copy link
Contributor

Do signals work with either camelCase or snake_case? Or does it only work with snake_case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants