Difference between revisions of "Loading Level Resources With Lua"

Jump to navigation Jump to search
m
Line 54: Line 54:
If you try to load a set of resources that doesn't exist, some resource types will allow it and just load none of that resource, but other types will make the game crash.
If you try to load a set of resources that doesn't exist, some resource types will allow it and just load none of that resource, but other types will make the game crash.


Here is the format of resTbl as it gets passed to QueueResourcesForLoad:
Here is a sample of the contents of resTbl as it gets passed to QueueResourcesForLoad:
  {  
  {  
  {
  {
Line 207: Line 207:
TriggerInstances = { ObjectType = "TriggerInstances", { ObjectName = "TextTrigger", GardenerName = "TextTrigger_G", Type = "DisplayText", Shortcut = "", Vars = {text = "Check this out, I can do a backflip", x = 0, y = 0, duration = 3, fadeTime = 0.5 } }, { ObjectName = "AnimTrigger", GardenerName = "AnimTrigger_G", Type = "PlayDudeAnim", Shortcut = "", Vars = { animName = "HitBodyMAir", clearAnimQueue = true, useLocal = true} } }
TriggerInstances = { ObjectType = "TriggerInstances", { ObjectName = "TextTrigger", GardenerName = "TextTrigger_G", Type = "DisplayText", Shortcut = "", Vars = {text = "Check this out, I can do a backflip", x = 0, y = 0, duration = 3, fadeTime = 0.5 } }, { ObjectName = "AnimTrigger", GardenerName = "AnimTrigger_G", Type = "PlayDudeAnim", Shortcut = "", Vars = { animName = "HitBodyMAir", clearAnimQueue = true, useLocal = true} } }
CreateTriggers( game:eventBarn() )
CreateTriggers( game:eventBarn() )
ResolveTriggerNames( game:eventBarn(), game:clumpBarn() )
ResolveTriggerNames( game:eventBarn(), game:clumpBarn() )


-- these activations aren't necessary to load the triggers, just done on the same frame to demonstrate that they work; see below for why it's done on same frame
-- these activations aren't necessary to load the triggers, just done on the same frame to demonstrate that they work; see below for why it's done on same frame
ActivateTriggerByName( "TextTrigger" )
ActivateTriggerByName( "TextTrigger" )
ActivateTriggerByName( "AnimTrigger" )
ActivateTriggerByName( "AnimTrigger" )
Line 238: Line 236:


<code>
<code>
ClumpInstances = { ObjectType = "ClumpInstances", { ObjectName = "NewClumpName", GardenerName = "NewClumpName_G(this name doesn't matter?)", Objects = { "some object's ObjectName", "another object's ObjectName", "and another, etc" } }, { same thing for another new Clump }, {another, etc} }  
ClumpInstances = { ObjectType = "ClumpInstances", { ObjectName = "NewClumpName", GardenerName = "NewClumpName_G(this name doesn't matter?)", Objects = { "some object's ObjectName", "another object's ObjectName", "and another, etc" } }, { same thing for another new Clump }, {another, etc} }
LoadClumps( game:clumpBarn() )
LoadClumps( game:clumpBarn() )
SetClumpMembers( game:clumpBarn() )
SetClumpMembers( game:clumpBarn() )
Line 246: Line 244:


<code>
<code>
ClumpInstances = { ObjectType = "ClumpInstances", { ObjectName = "NewGameStandUpEvents", GardenerName = "NewGameStandUpEvents_G", Objects = { "70c1306a4a41c624a9ff123f344ef6ad", "d951daedc9f58a681efd39a8875f32c6", "1a737db99c2f3a7733e5c6426211d0e8", "daa0dd930abe88d5d241e02752c636d4", "f26b85b929a3e48edf43a5ec1f076c91", "65eef6f7bcbfcfa07b32c34d07e53132", "796c354ac61bd62ac987778b9fa96c4c", "5abf9a5b00e2e29c36f7871028e9c1e5", "e4fada7df843f162ebb2ee56a0e9f40f" } } }  
ClumpInstances = { ObjectType = "ClumpInstances", { ObjectName = "NewGameStandUpEvents", GardenerName = "NewGameStandUpEvents_G", Objects = { "70c1306a4a41c624a9ff123f344ef6ad", "d951daedc9f58a681efd39a8875f32c6", "1a737db99c2f3a7733e5c6426211d0e8", "daa0dd930abe88d5d241e02752c636d4", "f26b85b929a3e48edf43a5ec1f076c91", "65eef6f7bcbfcfa07b32c34d07e53132", "796c354ac61bd62ac987778b9fa96c4c", "5abf9a5b00e2e29c36f7871028e9c1e5", "e4fada7df843f162ebb2ee56a0e9f40f" } } }
LoadClumps( game:clumpBarn() )
LoadClumps( game:clumpBarn() )
SetClumpMembers( game:clumpBarn() )
SetClumpMembers( game:clumpBarn() )
Line 255: Line 253:
<code>
<code>
SpawnEvent {EventAfterDelay = {delay = 0.01, effects = Names["NewGameStandUpEvents"]}}
SpawnEvent {EventAfterDelay = {delay = 0.01, effects = Names["NewGameStandUpEvents"]}}
Demonstration of the Clump it's duplicating:
Demonstration of the Clump it's duplicating:


Navigation menu