Difference between revisions of "Loading Level Objects When Level Starts"

Jump to navigation Jump to search
(Improved/moved note about avoiding object-order problems)
Line 440: Line 440:


Run the main script, and the script which modifies the object constructor functions (or modify the embedded Lua files containing the object constructor functions so that they look like they do here, and run the main script before the game starts loading Level_Graveyard for the first time).
Run the main script, and the script which modifies the object constructor functions (or modify the embedded Lua files containing the object constructor functions so that they look like they do here, and run the main script before the game starts loading Level_Graveyard for the first time).
*Note: if your other Lua scripts run those functions after the level has started running, make sure you pass it a non-false value for "lua", for example: <code>CreateTriggers(game:eventBarn(),true)</code>  
*Note: if you run those object constructor functions in any other Lua code after the level has started, make sure you pass them a non-false value at the end for "lua", for example: <code>CreateTriggers(game:eventBarn(),true)</code>  


Then create/assign tables of level object constructors inside the Mod.LevelObjects... tables, and the object changes will occur whenever a level loads.


Create/assign tables of level objects inside the Mod.LevelObjects... tables that are created by the main script.
'''Table usage'''


*"Add" object constructors will create new, extra objects.
The "main" tables are for the different functions of the script:
*"Edit" object constructors will replace the original constructor that has the same ObjectName, this can be used to change objects from the original game as well as new objects made with the "Add" tables.
*Mod.LevelObjects.'''Add''' tables will create additional new objects.
*Mod.LevelObjects.'''Edit''' tables will replace existing objects with different objects, using the same ObjectName; this can be used to change objects from the original game, as well as new objects made with the "Add" tables.
*Mod.LevelObjects.'''Null''' tables will safely "remove" objects with the designated ObjectNames, by changing them into predefined "null" objects that do nothing but technically are still there.
**This change to "nothing" takes priority over any changes done in Edit tables.
**The script on this page only can do Null for triggers/timelines/clumps so far, haven't bothered figuring out "null" constructors for other object types yet.
 
 
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.
 
'c''Speifying levels to change'''


*"Null" ObjectName keys will safely "delete" the object with the same ObjectName, by changing it into an object that exists but does nothing.
The tables actually filled with object constructors are level-based, and are named like:
**This change to "nothing" takes priority over any changes done in Edit tables.
 
**The script on this page only works with triggers/timelines/clumps so far, haven't bothered figuring out "null" constructors for other object types yet.
<code> Mod.LevelObjects.(Function).(Object Type).(Level)</code>


For tables that should only load in a specific level, use ["(the level UID).0"] as the table key, for example adding triggers to the default Chapter Select/Level_Graveyard would be:  
For tables that should only load in a specific level, use ["(the level UID).0"] as the table key, for example adding triggers to the default Chapter Select/Level_Graveyard would be:  

Navigation menu