I have come across yet another maddening bug in the scripting language. If anyone has had a similar problem and a resolution then please let me know.
On the first few turns my code works. If I carry on a few more turns it stops working, however, if after it fails I save the game and reload it then it works instantly, meaning when it loads it is fixed as if it took a reload to unstick it.
I am dealing with while loops and am wondering if it is possible that after a few turns of running these that somehow the game gets temperamental about them and if so then what is the act of saving then loading doing to make the code appear properly.
In more detail then:
The code runs at start turn (it alters the value of a counter) and then during the turn I can summon a historic event to tell me the value of the counter that has just been processed by my while loop. After a failure the historic event shows that the value is unchanged by the code.
The problem is definitely not with the historic event not correctly showing the counter value BTW.
So now I save and then load that save. Again I summon the historic event which now shows the counter value has changed correctly (not just the historic event showing differently - the counter has actually altered value) - yet no code has run since the save and reload. Could the game's intention of running the while loop at FactionTurnStart really be held in memory, stored in a save and then reloaded and triggered to run mid turn like this?
I cannot get my head around how this is possible.
Small simplified sample script transfering the value of c into b (and also into other counters in further sections of the bold script) :
monitor_event FactionTurnStart FactionIsLocal
set_event_counter c 100
end_monitor
monitor_event FactionTurnStart FactionIsLocal
and I_EventCounter c > 0;---- problem happens with or without this line
while I_EventCounter c > 0
if I_EventCounter o = 1
and I_EventCounter c > 0
inc_event_counter c -1
if I_EventCounter b1 < 90
inc_event_counter b1 1
end_if
end_if
similar code repeated for b2, b3, b4 etc (until c is spread amongst all these counters. NOTE: There is no danger that c will run out of counters to go into and thus prevent the loop ending)
end_while
end_monitor
Remember that there are no errors in the code. What I am hoping to find is a reason why it should sometimes stick and only run when reloaded mid-turn. Ideally I need a way to unstick it in code rather than saving and loading.






Reply With Quote







