Jump to content
Rydygier

Values saved via setVariable in the map object's namespace are lost at save/load

Recommended Posts

Does that happen only to me, or it's common/known thing? I would appreciate confirmation from someone else... Here is a footage showing this issue and simple repro steps (used Malden map, Arudy town, no mods, if that matters)

 

 

Repro description:

 

1. Set in EDEN simple mission: a soldier at some town. 

2. Preview. Aim at some house. 

3. Bring Debug console via Esc. put into one watched value: cursorTarget. Aimed house model name should appear. 

4. Put into another watched value: cursorTarget getVariable "my_testVar"

5. Put into execute field: cursorTarget setVariable ["my_testVar",true]

6. Press LOCAL EXEC, observe second watched value changing to true now

7. Save the game. 

8. Load the game.

9. Bring Debug console once more, check second watched value again. 

 

Note: It doesn't have to happen every time, but often. 

Share this post


Link to post
Share on other sites

I don't remember the circumstances leading to it, but I am the belief that setVariable does not work fully with that kind of objects. To the best of my memory, something about buildings/map objects not having identity the same manner as other vehicles. Buildings might be streamed in/out as you travel the map. I am guessing if you save/load the same might happen. Have you tried spawning the building instead and repeating the experiment?

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for your input. It sounds likely. And, as you probably suspected, indeed, no such vanishing for spawned copy of same building. So it is strictly map objects specificity. 

 

Although, BTW, in that case I would disable setVariabling on such objects completely, in current state it's misleading, in first tests seems, setVariable works, problems begins only after resuming saved game making whole thing unreliable and unusable anyway. 

 

Also, it doesn't happen all the time, I saw cases, where after loading saved game set variables was still there. So maybe not a design decision, but rather a bug affecting map objects. 

 

Anyway, in my case that means, I've to change approach in my script, can't rely on setVariable when comes to map objects, and indeed it comes to that.   

  • Like 1

Share this post


Link to post
Share on other sites

In fact, the save load system  saves the damage on buildings (the value). That "loads the bark" of what is having to be saved, but you can try something like:

cursorObject setDamage 0.01; cursorObject setVariable ["my_testVar",true]

Note: on the other hand, that doesn't mean you can pass a variable on any object (like blue or red containers, or usually returning "" as typeOf), even if you saved a set damage on them.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for the tip - it actually seems to work. Now set variable is kept after save/load, as long damage is > 0. 🙂

 

As for other alternatives, technically I could use even damage value itself to "scratch the wall in my special way", by setting certain value of damage, say 0.01234 to mark, what I want to mark (but I need to disable any further damage on this building just in case), then reading, if the house has this certain damage value. Not 100% sure about reliability here though.  

 

And on the top of that, I always can store houses in certain global array to distinguish them from the rest...  

  • Like 2

Share this post


Link to post
Share on other sites
On 11/18/2019 at 2:55 PM, Rydygier said:

Does that happen only to me, or it's common/known thing?

Terrain objects are streamed in/out. Even within a mission it might just disappear at any point.

And the engine also doesn't save every terrain building into every savegame as that would just be a waste since they are always there.

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×