Author Topic: ship save/load script v2.0  (Read 232 times)

0 Members and 1 Guest are viewing this topic.

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
ship save/load script v2.0
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.
« Last Edit: October 01, 2020, 09:18:37 am by Goober5000 »

 
Re: ship save/load script v2.0
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.

« Last Edit: October 21, 2020, 06:57:47 am by Admiral MS »
Here goes scripting and copy paste coding
Freespace RTS Mod
Checkpoint/Shipsaveload script