Hard Light Productions Forums

FreeSpace Releases => Scripting Releases => Topic started by: Goober5000 on September 30, 2020, 11:11:00 pm

Title: ship save/load script v2.0
Post by: Goober5000 on September 30, 2020, 11:11:00 pm
This is an updated version of Admiral MS's ship save/load script (https://www.hard-light.net/forums/index.php?topic=74716.0).

shipsaveloadv2-sct.tbm (http://staff.hard-light.net/goober5000/downloads/shipsaveloadv2-sct.tbm)
shipsaveloadv2-sexp.tbm (http://staff.hard-light.net/goober5000/downloads/shipsaveloadv2-sexp.tbm)

This is an optimization and upgrading rewrite.  It works largely the same as the original, and in fact savefiles from both scripts are compatible with each other.  The main differences are:


The script can coexist with Admiral MS's script, because it uses a different namespace for all its functions.  You can use both in your mod if you want.  I do recommend eventually converting all missions to use the new script because of the efficiency improvements, and in particular the every-frame performance hit of the old script.

The script requires a somewhat recent build due to the "shipname" parameter type.  Aside from this it should work in 19.0.  You would have to change the "shipname" parameter to "string" in the sexp.tbm, and you would have to type the ship names instead of selecting them from a menu.
Title: Re: ship save/load script v2.0
Post by: Admiral MS on October 21, 2020, 06:54:36 am
Thank you for rewriting the script and making it into something less messy and more up to date. This is something I should have done 3 years ago but I always thought "going to do that later" and then forgot about it anyway. I still feel bad about my beginner level programming skills back then and that the save files have this horrible data structure...  ;)

I modified the first post of my own thread to link here as well.

Title: Re: ship save/load script v2.0
Post by: Mobius on November 24, 2020, 04:12:47 am
Judging from what I read, this script is rather straightforward and requires a very limited number of SEXPs to trigger. I see it also activates ship-vanish automatically should a given ship be destroyed.

Are there any tutorials lurking around?
Title: Re: ship save/load script v2.0
Post by: Goober5000 on November 24, 2020, 09:09:22 am
Axem wrote a pretty good tutorial on checkpoints.  Of course, if you're using the new script, you would have to use the new sexps instead of the script functions.
https://wiki.hard-light.net/index.php/Tutorial_-_Mission_Infrastructure
Title: Re: ship save/load script v2.0
Post by: Goober5000 on January 28, 2021, 07:10:34 pm
Dilmah G discovered a bug in the loadout code that affects both this script as well as Admiral MS's original.  In brief, AmmoMax uses incompatible methods for reading and writing the value.  Mathematically speaking, set(get(x)) for AmmoMax is not idempotent.

Anyway, the bug was easy to fix once Dilmah G did the hard work of figuring it out.  I've updated the file in the first post.