nyolc8 Posted March 27, 2015 Share Posted March 27, 2015 I thought global variables accessible from any script, that's why they called "global". But now I realized that if I set a global variable value from a script, then that global variable value is empty when I read it from another script. Is this normal? I don't understand now how global variables work then :| Link to comment Share on other sites More sharing options...
spaceeinstein Posted March 27, 2015 Share Posted March 27, 2015 (edited) If you do have to use global variables, you have to make sure they use consistent numbers as the labels (like $1234 and not $abcd). If you use names, the compiler will assign a number to the name that may be different between different scripts if the names are not defined in the custom variables INI file. Edited March 27, 2015 by spaceeinstein Link to comment Share on other sites More sharing options...
nyolc8 Posted March 27, 2015 Author Share Posted March 27, 2015 oh, I forgot that with the assigning... now I got it, thanks! Link to comment Share on other sites More sharing options...
xToK3x Posted March 27, 2015 Share Posted March 27, 2015 (edited) zaz just showed me Special Global Cleo Variables, It helped me. Pretty much you can store a variable such as [email protected] and retrieve it from another file. Just do "0AB3: var 0 = [email protected]" to store a variable, Then "0AB4: [email protected] = var 0" on the file that needs the variable to retrieve it. you can store up to var 999. Special Global Cleo Variable: This theme requires the understanding of the description about Local Variables and Global Variablesof the theme DATA TYPE MEANINGTo realize Global Variables for Cleo scripts exist following Cleo opcode connected with a special expression:Opcode 0AB3: and 0AB4:The expression var together with a number, is building the Special Global Cleo Variable0AB3: var 0 = 10or0006: [email protected] = 10 // integer values0AB3: var 0 = [email protected]and0AB4: [email protected] = var 0var 0 up to var 999 will be stored, in exemble var 0 is stored with 10to get then stored value into your script needs to submit into a local:0AB4: [email protected] = var 44if0039: [email protected] == 1 // integer values004D: jump_if_false @nextlabel Edited March 27, 2015 by xToK3x Link to comment Share on other sites More sharing options...
nyolc8 Posted March 27, 2015 Author Share Posted March 27, 2015 (edited) I know that but I have a script which already uses a global variable (couldn't make it another way), and now I writing an extra script which would read that global variable... well, from one script I can read it without problems, from another script when I read it, game crashes... Again... it crashes because I READ it, not writing... wtf. edit: fixed, used another number for variable, but still not geting how a reading can make crash. Edited March 27, 2015 by nyolc8 Link to comment Share on other sites More sharing options...
xToK3x Posted March 28, 2015 Share Posted March 28, 2015 so you have something like Var 0 = [email protected] then you have 2 more scripts with something like this [email protected] = Var 0 is that correct? You should post the codes so people can help you easier, not sure though I'm super new at cleo. Link to comment Share on other sites More sharing options...
nyolc8 Posted March 28, 2015 Author Share Posted March 28, 2015 I didn't used that, I used $whatever and $1234 like methods (I know it's not the best), but anyway as I said I already made it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now