1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
main = require "main"
world = require "world"
color = require "color"
ui = require "ui"
bp = require "broadphase"
action = require "action"
char = require "char"
player = require "player"
room = require "room"
import World from world
import Server from world
import LocalPlayer from player
import LobbyRoom from room
mod = ...
mod.node = am.group!
mod.node\append(am.translate(0,main.height/2)^ am.text("Creating lobby...", color.fg, "center","top")\tag("join_id"))
mod.loaded = false
mod.load = () ->
mod.loaded = true
print("Loading create party")
main.root("screen")\append(mod.node)
print("About to create server")
main["server"] = Server!
print("Created server")
mod.node("join_id").text = "Lobby id:" .. main.server.lobby_id
print("Set join id text")
main["world"] = World!
main.world\set_room(LobbyRoom!)
print("Created world")
main.world\join(main.server.lobby_id)
print("Joined my own lobby")
start_button = ui.create_any_button(mod.node,5,2,(-32*5)/2,0)
start_button.node("loc")\append(am.scale(1.5)^ am.translate(12,-10)^ am.text("GET SILLY", color.fg, "left", "top"))
char_selector = ui.create_char_selector2(mod.node)
char_right, char_left, char_text = char_selector[1], char_selector[2], char_selector[3]
mod.buttons = {char_left, char_right, start_button} --save to remove from the physworld later
classes = char.class_order
class_s = 1
print("got char selector:",char_selector)
touch_indicator = am.group!
touch_cursor = am.sprite("data/cursor.png",vec4(1,1,1,1),"left","top")
touch_loc = am.translate(0,0)^ touch_cursor
touch_indicator\append(touch_loc)
--Set everything transparent, give it color when we're connected
start_button.color = color.transparent
char_right.color = color.transparent
char_left.color = color.transparent
mod.node\action("click_interpreter",coroutine.create(()->
while not main.world.client_open!
coroutine.yield!
char_left.color = color.white
char_right.color = color.white
char_text.text = "Tumbler"
main.world\set_local(LocalPlayer(am.eval_js("CLIENT.peer._id"),{},char.classes.Tumbler))
main.world\load!
while true
if #main.win\active_touches! > 0
touch = main.win\touch_position(1)
touch_cursor.color = vec4(1,1,1,1)
touch_loc.x = touch.x
touch_loc.y = touch.y
col_but = bp.check(touch.x, touch.y + 64)
if #col_but > 0
touch_cursor.color = vec4(0.5,0.5,0.5,0.5)
if #col_but > 0 and main.win\touch_began(1)
if col_but[1] == start_button
print("Starting!")
action.start_game!
coroutine.yield!
if col_but[1] == char_left
print("char left")
class_s = class_s - 1
start_button.color = color.white
if class_s == 0
class_s = #classes
if col_but[1] == char_right
print("char right")
class_s = class_s + 1
start_button.color = color.white
if class_s > #classes
class_s = 1
if col_but[1] == char_left or col_but[1] == char_right
print("class_s",class_s)
print("classes:", classes)
char_text.text = classes[class_s]
action.request_class_change(classes[class_s])
else
touch_cursor.color = vec4(0,0,0,0)
coroutine.yield!
))
mod.node\append(touch_indicator)
mod.unload = () ->
print("Unloading create party")
main.root("screen")\remove(mod.node)
for _, button in pairs(mod.buttons)
bp.remove(button)
mod.loaded = false
mod
|