From 89a8f94ac0206412c1a2d7b8766d97dbdbd36253 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Tue, 21 Jan 2025 16:03:25 -0600 Subject: work --- src/world_test.moon | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/world_test.moon') 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) -- cgit v1.2.3-70-g09d2