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:

Code: [Select]
#SD Ravana
$Name: Battle Destroyer
$hull:  200k
$armor: Shivan Elite Armor
$ai class: General
$turret armor: Shivan Elite Armor
+armor:Hell Armor
+armor:Hell Armor
+armor:Hell Armor
+armor:Hell Armor
$turret07:Standard Flak
$turret12:Standard Flak
$turret14:Standard Flak
$turret16:Standard Flak
$turret17:Standard Flak
$turret18:Standard Flak
$turret20:Standard Flak
$turret21:Standard Flak
$turret22:Standard Flak
$turret23:Standard Flak
$turret30:Standard Flak

Code: [Select]
( script-eval-block
"'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).