Im starting to learn Lua modules a bit, and I am having troubles with a small part in my Lua. Everytime I change my variable it reverts back to nil.
myModule.lua
--I should note that client is a number.
module(..., package.seeall)
local LoggedIn = { }
function isLogged( client )
return LoggedIn[client]
end
function logIn(client)
table.insert(LoggedIn,client,true)
end
function logOut(client)
table.remove(LoggedIn,client)
end
main.lua an event happens
package.loaded.myModule= nil; require "myModule"
function event( client )
myModule.logIn(client)
end
function event_2( client )
myModule.logOut(client)
end
EDIT: Using functions instead, and making it local variable. It is still returning nil even though I can confirm the logIn function happened with no errors. Without even using the logout function yet. Any thoughts?
but later on in main.lua I check if client is logged in and it just returns nil.
Is this just a limitation of modules or am I just accessing the variable wrong.
I should note I need to be able to do this in other Luas that acces myModule.lua too.
Thanks in advance
client? Show us the code that usesfunction event(note that function is spelled incorrectly in your example). - Doug Currie