Hello, I need help with a really bizzare behavior.
I've encountered a situation where putting some lines of code into a function will produce a different result. No change of order, ofc, just part of the code is in a function - different result. If I put all lines into the same function - evereything is back to normal.
Details:
1. I have the following (simplified) code:
The above is working as expected, no problems.
2. Then I have this:
Working the same, no problems.
3. Last version:
..and it doesn't work. Meaning - the program works, but the results are totally different. I'm lost and confused.
I have attached a mod with this situation. I'll be glad if anyone could check if this situation happens also for you and maybe even explain it or fix it?
Attached mod and how to use it.
It's a simple mod for testing some UI functions (specifically Lenses). Run it with no other mods active. Then start a game and move your units for a few turns. All the plots that your units ever visited will be highlighted with red, your current positions with blue. Also for 2 first units the path of their movement will be drawn. Then there are 3 versions of HelloWorldPopup.lua that corresponds to 3 scenarios I described above. Scenario 1 and 2 are working as expected. Scenario 3 is not working - plots are not highligthed and no paths are drawn.
I've encountered a situation where putting some lines of code into a function will produce a different result. No change of order, ofc, just part of the code is in a function - different result. If I put all lines into the same function - evereything is back to normal.
Details:
1. I have the following (simplified) code:
Code:
function SetUnitMovesLens()
-- now does nothing
end
function OnLocalPlayerTurnBegin() -- standard event hook
<some code A>
<some code B>
<some code C>
<some code D>
end
2. Then I have this:
Code:
function SetUnitMovesLens()
<some code A>
<some code B>
<some code C>
<some code D>
end
function OnLocalPlayerTurnBegin() -- standard event hook
SetUnitMovesLens()
end
3. Last version:
Code:
function SetUnitMovesLens()
<some code C>
<some code D>
end
function OnLocalPlayerTurnBegin() -- standard event hook
<some code A>
<some code B>
SetUnitMovesLens()
end
I have attached a mod with this situation. I'll be glad if anyone could check if this situation happens also for you and maybe even explain it or fix it?
Attached mod and how to use it.
It's a simple mod for testing some UI functions (specifically Lenses). Run it with no other mods active. Then start a game and move your units for a few turns. All the plots that your units ever visited will be highlighted with red, your current positions with blue. Also for 2 first units the path of their movement will be drawn. Then there are 3 versions of HelloWorldPopup.lua that corresponds to 3 scenarios I described above. Scenario 1 and 2 are working as expected. Scenario 3 is not working - plots are not highligthed and no paths are drawn.