96
edits
(→Example script: LoadModLevelObjects: clarifying some stuff) |
(→Example script: LoadModLevelObjects: clarification continued) |
||
| Line 443: | Line 443: | ||
Then create/assign tables of level object constructors inside the Mod.LevelObjects... tables, and the object changes will occur whenever a level loads. | Then create/assign tables of level object constructors inside the Mod.LevelObjects... tables, and the object changes will occur whenever a level loads. | ||
'''Table usage''' | '''Table usage''' | ||
The "main" tables are for the different functions of the script: | The "main" tables are for the different functions of the script: | ||
| Line 456: | Line 458: | ||
Each of these function-based tables includes object-type-based tables, with the type name used by their Instances table: for example Mod.LevelObjects.Add.Trigger is for adding Triggers to TriggerInstances. | Each of these function-based tables includes object-type-based tables, with the type name used by their Instances table: for example Mod.LevelObjects.Add.Trigger is for adding Triggers to TriggerInstances. | ||
' | |||
'''Specifying levels to change''' | |||
The tables actually filled with object constructors are level-based, and are named like: | The tables actually filled with object constructors are level-based, and are named like: | ||
| Line 466: | Line 470: | ||
<code>Mod.LevelObjects.Add.Trigger["0.0"]</code> | <code>Mod.LevelObjects.Add.Trigger["0.0"]</code> | ||
For tables that should load in all levels, use | For tables that should load in all levels, use ["All"]/All as the table key, for example: | ||
<code>Mod.LevelObjects.Add.Trigger | <code>Mod.LevelObjects.Add.Trigger["All"] | ||
Mod.LevelObjects.Add.Trigger | Mod.LevelObjects.Add.Trigger.All</code> | ||
You can | You can create these tables directly, running code like: | ||
<code>Mod.LevelObjects.X.Y["Z"] = { Object1, Object2, Object3 }</code> | <code>Mod.LevelObjects.X.Y["Z"] = { Object1, Object2, Object3 }</code> | ||
But it might be more convenient to store the tables elsewhere and | But it might be more convenient to "store" the tables elsewhere and assign them around, like: | ||
<nowiki> | <nowiki> | ||
Table1 = { Object1, Object2, Object3 } | Table1 = { Object1, Object2, Object3 } | ||
Table2 = { Object4, Object5, Object6 } | Table2 = { Object4, Object5, Object6 } | ||
Mod.LevelObjects.X.Y["Z"] = Table1 | Mod.LevelObjects.X.Y["Z"] = Table1 | ||
-- Then later you swap it: | -- Then later you decide to swap it and do: | ||
Mod.LevelObjects.X.Y["Z"] = Table2 | Mod.LevelObjects.X.Y["Z"] = Table2 | ||
</nowiki> | </nowiki> | ||
To make a level stop | |||
To make a level stop changing something, run code like: | |||
<code>Mod.LevelObjects.X.Y["Z"] = nil</code> | <code>Mod.LevelObjects.X.Y["Z"] = nil</code> | ||
'''Formatting object constructors''' | |||
For example, (ObjectType)Instances | You must format these tables a little differently from what is used in (Object Type)Instances.lua files, since this script uses strings for object constructors rather than actual tables (the only way I found so far to avoid errors with persistent tables, explained more in code comments). | ||
For example, (ObjectType)Instances.lua files are formatted like this: | |||
<nowiki>SomethingInstances = | <nowiki>SomethingInstances = | ||
{ ObjectType = "SomethingInstances" | { ObjectType = "SomethingInstances" | ||
| Line 505: | Line 513: | ||
}</nowiki> | }</nowiki> | ||
'But' the | '''But''' the ModLevelObjects tables must be formatted like '''this''': | ||
<nowiki>ExampleTable = | <nowiki>ExampleTable = | ||
{ ExampleName1 = [[ ObjectName = "ExampleName1" | { ExampleName1 = [[ ObjectName = "ExampleName1" | ||
| Line 519: | Line 527: | ||
Null objects can either be formatted the same as Add/Edit, or simply as: | |||
<code>ExampleName = true</code> | <code>ExampleName = true</code> | ||
| Line 527: | Line 535: | ||
'''Object types that need more work''' | |||
(thing)EmitterInstances = | |||
This script does not yet work for Hulls or Decoration Meshes, see code comments. | |||
Also, in order to make it work for Particle Emitters and Sound Emitters, the embedded (thing)EmitterInstances.lua files need to be edited so that they read like: | |||
<nowiki>(thing)EmitterInstances = | |||
{ | { | ||
keep | keep the original table the way it is | ||
} | } | ||
LoadModLevelObjects("(thing)Emitter") | LoadModLevelObjects("(thing)Emitter")</nowiki> | ||
</div></div> | </div></div> | ||