Jump to content

noob question: how to set a value via script that will be saved in the game


Recommended Posts

Posted

thanks the light just went on!! I needed a GlobalVariable object defined in CK in the mod to associate to the variable defined to the script ..

Posted (edited)

ok, so have Global object ID CafePostersRan Value 0.0000 (Constant not checked).

 

In my script the property is defined as:

 

GlobalVariable Property CafePostersRan Auto
{global variable to know if it ran}

 

In the properties for the script, for CafePostersRan its type GlobalVariable and the Value is the CafePostersRan Global Object above.

 

in the script to try to set the value to non- 0 I have:

 

float modRan = CafePostersRan.GetValue()

Debug.notification("modRan value is "+modRan)
If (modRan == 0.0)
Debug.notification("Cafe Posters installed, do NOT disable while game is running!")
CafePostersRan.SetValue(1)

Endif
Debug.notification("CafePostersRan mod value now is "+CafePostersRan.GetValue())

 

And the value starts as 0.000 , the notification about "CaféPosters installed" is displayed .. but the SetValue(1) does not seem to take because the last debug says the GetValue() is still 0.000 ..

 

I thought I had all the right things finally ! :/

Edited by jrfk2
Posted
Add Const at the end of the global declaration line, the Const is just saying this property will always be this global, it won't prevent you from setting the value of the Global.
Posted (edited)

ahh ok, yeah Const seemed to imply it can't change .. that was the last piece of the puzzle .. all working now .. thanks Folks!!

Edited by jrfk2
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...