FreeSpace Releases > Scripting Releases

ship save/load script v2.0

(1/1)

Goober5000:
This is an updated version of Admiral MS's ship save/load script.

shipsaveloadv2-sct.tbm
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:

[*] Now uses the dynamic sexp system, so you can call it without fiddling with script-eval.
[*] Includes the deferred file access upgrade, speeding up reading and writing by only doing it once.
[*] Removes some esoteric options.  Ships now always reproduce their exited status (destroyed/departed/vanished) exactly as it was saved.  The script always behaves as if the old stat parameter is set to 3.
[*] Because of the previous point, ships are no longer created only to be immediately destroyed or warped out.  Consequently, the script no longer requires a custom "Shipsave" ship entry.
[*] The Lua was cleaned up, with appropriate use of local variables and other efficiency enhancements.  The script no longer iterates through a table on every frame.
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.

Admiral MS:
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.

Mobius:
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?

Goober5000:
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

Goober5000:
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.

Navigation

[0] Message Index

Go to full version