diff options
Diffstat (limited to 'src/world_test.moon')
| -rw-r--r-- | src/world_test.moon | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/world_test.moon b/src/world_test.moon index 8fa9da5..c574f6b 100644 --- a/src/world_test.moon +++ b/src/world_test.moon @@ -8,6 +8,8 @@ ui = require("ui") peer = require("router") server = ui.button(-200,0,100,100, "Server") +textbox = ui.textbox(200,100,100,32, "Serverid") +client = ui.button(200,0,100,100, "Client") co = nil server.on = () => if @co == nil @@ -32,9 +34,26 @@ server.on = () => ) client.on = () => + if @co == nil + print("Setting co...") + @co = coroutine.create(() -> + router = peer.Router(textbox.text.text) + router\initalize! + router + ) + button = @ + @node\action(() => + if button.co and coroutine.status(button.co) ~= "dead" + succ, val = coroutine.resume(button.co) + if not succ + error(debug.traceback(button.co, val)) + if type(val) == "string" + button.text.text = val + else + router = val + world.router = router + ) -textbox = ui.textbox(200,100,100,32, "Serverid") -client = ui.button(200,0,100,100, "Client") test_sprite = am.translate(0,0) ^ am.scale(20) ^ am.sprite("BRY\nYYY\nBBB") ui.node\prepend(test_sprite) |
