Jump to content

Cannot change GlobalVariable with script


Recommended Posts

Hi everybody,

I am having trouble with a GlobalVariable... I am working on a script that will apply penalties to you for dying, and the intent is to set a variable when you die that will persist after your old file is loaded.

I have tested this, and it works using a GlobalVariable set to constant. I can change the value of the GlobalVariable in the console using "set myglobalvar to 1", and the value remains how I set it after I load an old save.

The issue I am having is that I can't seem to set the value of the GlobalVariable using a script. When I try myglobalvar.SetValue(1) or myglobalvar.Mod(1), it doesn't do anything... just stays at the default value of 0. If I change the GlobalVariable to no longer be constant, then the SetValue() and Mod() work just fine...

What I'm asking is, does anybody know of a way to modify the value of a GlobalVariable that is set to constant using Papyrus? Or can it only be done via console?

If it can only be done via console, does anybody know of a way to run a console command via script?

 

Thank you for your time,

- Ultimate Coffee

Link to comment
Share on other sites

Apart from a constant value being... well... constant, you can't change it with SetValue(XX) so that it holds a new value after re-loading a save file. You'll need saving the value to the external file (ini) and picking it when player loads game.

Link to comment
Share on other sites

You'll need saving the value to the external file (ini) and picking it when player loads game.

 

Would it be possible to write the value to the .ini from the script? If so, how would I do that?

Also, when you say write to the .ini, are you referring to the fallout4.ini, fallout4prefs.ini, and fallout4custom.ini? If so, a lot of people play with these files locked, including myself... How could that be addressed?

Link to comment
Share on other sites

IIRC/AFAIK, if you have a mod "MyMod.esp" and also a "MyMod.ini", then the settings of "MyMod.ini" will be loaded if "MyMod.esp" is.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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