Hello!
Could you help me, please?
I cann't use socket with widgets. I tried to start example widget, which uses socket (\Spring\engine\91.0\examples\Widgets\luasocket.lua):
Error: Error in Initialize(): [string "LuaUI\Widgets\luasocket.lua"]:64: attempt to index upvalue 'socket' (a nil value)
line 64: client=socket.tcp()
before socket was defined using: local socket = socket
Also in system.lua present line: socket = socket,
I use spring 91.0.
Usage of socket in widgets
Moderator: Moderators
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Usage of socket in widgets
local socket = socket, I think, will initialize socket with nil value. What will happen is that you've tried to inialize socket as equal to itself, but socket isn't defined yet so it will be initialized to nil. If you are trying to initialize socket to have the value of a string reading 'socket', I think you should use local socket = "socket".
Re: Usage of socket in widgets
did you set LuaSocketEnabled=1 in springsettings.cfg? luasocket is disabled as default before spring 92.0.
Re: Usage of socket in widgets
Thank you very much for help, guys!
My fault, I just didn't set LuaSocketEnabled=1...
But I don't understand why this check was passed:
if not Spring.GetConfigInt("LuaSocketEnabled", 0) == 1 then
Spring.Echo("LuaSocketEnabled is disabled")
return false
end
Anyway, I added LuaSocketEnabled=1 and now I can create socket)))
My fault, I just didn't set LuaSocketEnabled=1...
But I don't understand why this check was passed:
if not Spring.GetConfigInt("LuaSocketEnabled", 0) == 1 then
Spring.Echo("LuaSocketEnabled is disabled")
return false
end
Anyway, I added LuaSocketEnabled=1 and now I can create socket)))
Re: Usage of socket in widgets
"not" has a higher priority than "=="
So when you write: if not a==b then
You think you write: if not (a==b) then
But what you actually write is: if (not a) == b then
It caught me many times as well.
I suggest you use ~=
So when you write: if not a==b then
You think you write: if not (a==b) then
But what you actually write is: if (not a) == b then
It caught me many times as well.
I suggest you use ~=
Re: Usage of socket in widgets
zwzsg, good to know, thanks)
abma, nice!)
abma, nice!)