Hi,
I used defold-websocket by britzel
I am having problem with handling on_message:
global_ws:on_message( function(message)
print("Received message", message)
msg = split(message,"/*^*/")
switch(msg[1])
if tonumber(msg[1]) == 9001 then
print ("Room Joined")
end
end)
I am trying to split the incoming message using this split function
function split(s, sep)
local fields = {}
local sep = sep or " "
local pattern = string.format("([^%s]+)", sep)
string.gsub(s, pattern, function(c) fields[#fields + 1] = c end)
return fields
end
It works, and I am able to see the output:
DEBUG:SCRIPT: Cursor out hash: [/instance4] hash: [green] 68.5 190.5
DEBUG:SCRIPT: Cursor over hash: [/instance3] hash: [green] 79.5 171.5
DEBUG:SCRIPT: Pressed hash: [/instance3] hash: [green] 113.5 125.5
DEBUG:SCRIPT: Clicked hash: [/instance3] hash: [green] 115.5 124.5
DEBUG:SCRIPT: calc
DEBUG:SCRIPT: Released hash: [/instance3] hash: [green] 115.5 124.5
DEBUG:SCRIPT: 9001/*^*/Unknown-2824 joined the room. > 10
DEBUG:SCRIPT:
{ --[[0000020C99703D50]]
1 = "9001",
2 = "Unknown-2824 joined the room. > 10"
}
DEBUG:SCRIPT: 1 9001
DEBUG:SCRIPT: 2 Unknown-2824 joined the room. > 10
However,
(as I am modifying https://github.com/britzl/defold-input/tree/master/examples/cursor project to fit my need )
It throws error asap I move my mouse away from Any button.
DEBUG:SCRIPT: 1 9001
DEBUG:SCRIPT: 2 Unknown-2824 joined the room. > 10
ERROR:SCRIPT: /in/cursor.lua:16: attempt to call field 'url' (a nil value)
stack traceback:
/in/cursor.lua:16: in function 'url_to_key'
/in/cursor.lua:22: in function 'trigger'
/in/cursor.script:97: in function 'trigger_event'
/in/cursor.script:169: in function </in/cursor.script:114>
Why is cursor unable to find url_to_key?