This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

What about global and static variables
#1
Hello,

I just started a few days ago to make some scripts and learn Lua.
I wonder about Lua global variables that were supposed to be shared between scripts and the unavailable static variables for subsequent or recursive calls.
The only way I have found is thru the 'storage' function. Am I missing something ? Huh

Thanx
Tiny
Reply
#2
Yes, storage is one of possible approaches for global/static variables. In more advanced cases you can use an external Redis key-value database. This way several LMs can share data between them.

Only resident script variables are static by default. Simplified resident script logic:

Code:
while SCRIPT_ACTIVE do
  RUN_RESIDENT_FUNCTION()
  sleep(SCRIPT_SLEEP_TIME)
end
Reply
#3
Thank you, that's clear.
I only tried with event fired scripts.

Tiny
Reply


Forum Jump: