Persist information from another script?

  1. 6 years ago

    Is there a way to persist information from another script? For example, I want to keep track of the creation credits used in R3F logistics over multiple sessions, is there a way I could save the number when saving ALiVE, and then call a function when loading ALiVE persistence to set the credits back to that saved number?

  2. Friznit

    9 Dec 2017 Administrator

    You can save custom variables:

    http://alivemod.com/wiki/index.php/Persistence#Editor_Notes

  3. Edited 6 years ago by dev614

    @Friznit You can save custom variables:

    http://alivemod.com/wiki/index.php/Persistence#Editor_Notes

    Excuse my incompetence, but how would I incorporate the variable _creditsCurrent into that code?

    _credisCurrent is a getvariable code that returns the number of credits i.e
    _creditsCurrent = factory1 getVariable "R3F_LOG_CF_credits";

    Do I put both the load and save functions in the init.sqf?

    Something like:
    in init.sqf

    _creditsCurrent = factory1 getVariable "R3F_LOG_CF_credits";
    
    ["_creditsCurrent",_credits] call ALiVE_fnc_ProfileNameSpaceSave; 
    
    waituntil {(player getvariable ["alive_sys_player_playerloaded",false])};
    
    _credits = "_creditsCurrent" call ALiVE_fnc_ProfileNameSpaceLoad; 
    _creditsSet = factory1 setVariable ["R3F_LOG_CF_credits", _credits, true]; 

    or would I want to rather do the setVariable function, like so:

    _creditsVar = factory1 getVariable "R3F_LOG_CF_credits";
    _creditsCurrent = factory1 setVariable ["R3F_LOG_CF_credits", _creditsVar, true];
    
    ["_creditsCurrent",_credits] call ALiVE_fnc_ProfileNameSpaceSave; 
    
    waituntil {(player getvariable ["alive_sys_player_playerloaded",false])};
    
    _credits = "_creditsCurrent" call ALiVE_fnc_ProfileNameSpaceLoad;

    Sorry, I'm not very experienced when it comes to coding, just a little dabbling here and there.

  4. Edited 6 years ago by dev614

    Also, I have respawn markers/triggers that are dynamically added to the game via an FOB system. Would it be possible to save the respawn markers/triggers as well?

    I noticed the "ALIVE_fnc_markerSaveData" function, what exactly is the criteria for a trigger/marker to be saved with this function?

  5. If anybody could assist, I would be very appreciative. This is the final piece to my mission!

  6. So I ended up figuring it out and I got the credits to persist over sessions, but my question is with the respawn markers for the FOBs - they get deleted when an enemy gets too close to them. So after the marker is created and saved, could that data then be deleted after the marker is deleted? Or could I just reference the marker name again inside the trigger that deletes it after it has been deleted, maybe returning null? Idk like I said I'm not very experienced xD

  7. Friznit

    11 Dec 2017 Administrator

    I'm not a scripter so unable to help but it sounds like you're making some great progress. It'd be good to see what you've managed so far, if you're happy to share it of course!

  8. @Friznit I'm not a scripter so unable to help but it sounds like you're making some great progress. It'd be good to see what you've managed so far, if you're happy to share it of course!

    Neither am I, that's the problem xD but I'm getting there, slowly but surely! I'll totally share it once I get it to an acceptable state. It's playable as is, and most of the features I've added are functioning how I want them I just haven't really got to PLAY the mission yet and test it in that manner. I'm sure there's plenty of bugs just waiting to pop up.

    You wouldn't happen to know the function called when pressing "save and exit" would you? It would make it 10x more convenient to be able to save everything at once, instead of having to save custom variables in weird little hacky ways.

 

or Sign Up to reply!