bluemarvin Posted July 15, 2012 Share Posted July 15, 2012 Strangest thing... I have a script where I set and get values from two globals. In one case, all works great. In the other case, GetValue() always returns 0. So here's some relevant lines, I'm taking out the code that's not at issue: GlobalVariable Property GoldValueMultiplier Auto float MyValueMultiplier If MyCountVariable > 0 MyBaseValue = MyItemRef.GetGoldValue() MyValueMultiplier = GoldValueMultiplier.GetValue() Debug.MessageBox ("Multiplier: " + MyValueMultiplier) MyAdjustedValue = (MyBaseValue * MyValueMultiplier) EndIf 1. Yes, I have set the property to the VAR.2. The var does not have constant checked.3. The var has an initial value of 2. The debug message returns "0" and even though MyBaseValue is showing that it's being set right, MyAdjustedValue is getting set to 0 also since MyBaseValue is getting multiplied by 0 instead of the desired 2. However, if I enter the game and use the console command GetGlobalValue, I'm getting 2 for the global that GoldValueMultiplier is linked to. And the real kicked is... I am using the EXACT SAME syntax on another Global in the exact same code snippet and it's setting correctly, changing right, pulling the value right, etc. Any ideas? Link to comment Share on other sites More sharing options...
bluemarvin Posted July 15, 2012 Author Share Posted July 15, 2012 (edited) Eh, I have a partial answer here at least. It has something to do with my save file. I went further back loaded an older save, before I was in the area where I was modding... and one where that global hadn't existed yet. This solved the problem, though I don't understand how it happened in the first place yet. Edited July 15, 2012 by bluemarvin Link to comment Share on other sites More sharing options...
flobalob Posted July 15, 2012 Share Posted July 15, 2012 (edited) I think scripts get attached/copied into your save game so if you visit an area that has an Item with a script attached and save, then quit change the script, and finally reload the save you will still be running the OLD version of the script. Although I wouldn't guarantee that this ALWAYS happens. To be on the safe side, when testing always use "COC <Insert area name>" in the console before loading any savegame. Edited July 15, 2012 by flobalob Link to comment Share on other sites More sharing options...
steve40 Posted July 16, 2012 Share Posted July 16, 2012 Global values are saved into your savegame. Given that things can go wrong (saved a value that's no longer useful to you), you need an initialization routine, or a maintenance routine, in your script that checks for bad values and resets them to default. Link to comment Share on other sites More sharing options...
Recommended Posts