Liberty Unleashed
Scripting => Script Help => Topic started by: VetalYA on October 30, 2011, 11:32:04 am
-
I need to use global variables, can some one give me an example ?
(I ask it here, because http://squirrel-lang.org/doc/squirrel3.html#d0e599 (http://squirrel-lang.org/doc/squirrel3.html#d0e599) contain ugly examples )
Thank you in advance.
-
Ok, i understand how to create them.
Its simply
g_myGlobalVar <- 234;//at the top of file
g_myGlobalVar1 <- "my value";//at the top of file
function onServerStart()
{
print( "My own global variable: " + g_myGlobalVar);
print( "My own global variable : " + g_myGlobalVar1);
return 1;
}
They have to be declared like this example:
g_YourVarName <- your_value;
-
It doesn't need to be at the top of your file btw, Declaring them in any function and then calling them somewhere else works just fine. Thats where global variables are for in the first place.