summaryrefslogtreecommitdiff
path: root/src/world_test.moon
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2025-01-21 16:03:25 -0600
committerAlexander M Pickering <alex@cogarr.net>2025-01-21 16:03:25 -0600
commit89a8f94ac0206412c1a2d7b8766d97dbdbd36253 (patch)
treec9ddc23d31d3c5058d3465dabb68aae7b8209138 /src/world_test.moon
parent0370d64b3bd7914be55358817e52bbc8a529a7d3 (diff)
downloadggj25-89a8f94ac0206412c1a2d7b8766d97dbdbd36253.tar.gz
ggj25-89a8f94ac0206412c1a2d7b8766d97dbdbd36253.tar.bz2
ggj25-89a8f94ac0206412c1a2d7b8766d97dbdbd36253.zip
work
Diffstat (limited to 'src/world_test.moon')
-rw-r--r--src/world_test.moon23
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)