Hard Light Productions Forums

FreeSpace Releases => Scripting Releases => Topic started by: X3N0-Life-Form on November 10, 2015, 03:00:08 pm

Title: [RELEASE] Ship variant manager v1.0
Post by: X3N0-Life-Form on November 10, 2015, 03:00:08 pm
Greeting, fellow modders

Mentioned in the parsing script release thread (http://www.hard-light.net/forums/index.php?topic=89168.msg1776654#msg1776654), this script allows modders to change a capship's loadout and a few other characteristics through a single lua call. The idea was that if a ship or a group of ships has a specific set of characteristics (turret loadout, armor type, AI class, etc.) that differentiate that ship from others of the same class, instead of having to manually copy these from mission to mission, and potentially introduce errors in the process, you would define a "ship variant" in a config table file, then only have to copy a single script-eval-block SEXP referencing that variant and the ship you want to apply it to.

While you can probably get similar results by defining different ship templates in your regular ship tables (since I remember reading that they were working again), I personally have several reasons to use that script over that :


Source code is available here (https://raw.githubusercontent.com/X3N0-Life-Form/AVPoV/master/data/scripts/shipVariant.lua).

How to use it:

Note: REQUIRES parse.lua (http://www.hard-light.net/forums/index.php?topic=89168.msg1776654#msg1776654)

Put shipVariant.lua in data/scripts.

In data/tables/init-sct.tbm, under #Conditional Hooks:
Code: [Select]
$On Game Init: [[shipVariant.lua]]
$On Warp In: [setVariantDelayed()]

In data/config/ship_variants.tbl:
Table specification:



Example:
Code: [Select]
#SD Ravana
$Name: Battle Destroyer
$hull:  200k
$armor: Shivan Elite Armor
$ai class: General
$turret armor: Shivan Elite Armor
$turret01:LRed
+armor:Hell Armor
$turret02:LRed
+armor:Hell Armor
$turret03:SRed
+Rof:200
+armor:Hell Armor
$turret04:SRed
+Rof:200
+armor:Hell Armor
$turret05:SAAA
$turret06:SAAA
$turret07:Standard Flak
$turret08:SAAA
$turret09:SAAA
$turret10:SAAA
$turret11:SAAA
$turret12:Standard Flak
$turret13:SAAA
$turret14:Standard Flak
$turret15:SRed
$turret16:Standard Flak
$turret17:Standard Flak
$turret18:Standard Flak
$turret19:Piranha#Shivan
$turret20:Standard Flak
$turret21:Standard Flak
$turret22:Standard Flak
$turret23:Standard Flak
$turret24:SAAA
$turret25:SRed
$turret26:Piranha#Shivan
$turret27:SRed
$turret28:SRed
$turret29:SAAA
$turret30:Standard Flak
#End

In FRED:
Code: [Select]
( script-eval-block
"setVariant("
"'ship name',"
"'variant name')"
)

I am open to suggestions, remarks, questions regarding both this script and the way it is presented in this thread (in other words: I'm not sure if I'm explaining things properly here).