Hard Light Productions Forums

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

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

The final part of my ship variant framework is a script capable of assigning a variant to any number of ships in a mission with a single lua call. The script relies on the ship variant infrastructure, as well as another config table which specifies which variant is used by which ships within a certain number of categories. The ships are grouped by table category.

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

How to use it:

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

Put shipVariantMissionWide.lua in data/scripts.

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

Let's say you have a bunch of recurring baddies called 'Serkr Team'. You've made Serkr variants for each of their ship classes in ship_variants.tbl, so now you'll want to add these to you mission-wide variant table:

In data/config/ship_variants_mission_wide.tbl:
Code: [Select]

$Name: Marcus Glaive
$Variant: Serkr

$Name: Hydra
$Variant: Serkr

$Name: Pilum
$Variant: Serkr


In FRED, for missions that use Serkr Team:
Code: [Select]
( script-eval-block

You can also assign a variant to a "wing" of ships by adding the +Wing: + a number sub-attribute to the $Variant: attribute, the script will then assign the variant to every ship bearing the same name + a number, for instance:
Code: [Select]
#Mission 10-hard
; assigns the "Morning-Maxim" variant to sentry guns 1 through 12
$Name: Sentry Gun
$Variant: Morning-Maxim
+Wing: 12


#Mission 10-easy

; assigns the "PromR-Subach" variant to sentry guns 1 through 8
$Name: Sentry Gun
$Variant: PromR-Subach
+Wing: 8


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).