96
edits
m (→Timelines) |
(Initial info on loading alternate resource files) |
||
| Line 1: | Line 1: | ||
[[Category:Native Lua Functions]] | [[Category:Native Lua Functions]] | ||
[[Category:Level Resources]] | [[Category:Level Resources]] | ||
This is what has been found so far to add and/or modify level resource objects | This is what has been found so far to add and/or modify level resource objects using a Lua script, along with brief descriptions of what these objects do. | ||
==== | ==Loading Resource Files== | ||
To make different sets of resources load at the start of a level, one way is to run code that alters the resTbl table used within the QueueResourcesForLoad() function. This function is initially defined in plain text in Journey.exe . | |||
For example, if you inject this script, then whenever you define swapLevel as an internal level name ("Graveyard","Barrens",etc) the next level's resources will all be replaced with the ones from Level_''swapLevel''. | |||
swapLevel = "" | |||
function QueueResourcesForLoad( resManager, resTbl, alloc ) | |||
DebugPrint( "Loading: Queuing resources for load." ) | |||
--this if/then block is the modded code, the rest is original | |||
if swapLevel ~= "" then | |||
for i,v in ipairs (resTbl) do | |||
if v.class == "Script" then v.source = "Level_"..swapLevel.."/"..v.name..".lua" | |||
elseif v.class == "Binary" then v.source = "Scripts/Level_"..swapLevel.."/"..v.name..".lua" | |||
elseif v.name == "LvlMus" then v.source = swapLevel.."_MUS.bnk" | |||
elseif v.name == "LvlSfx" then v.source = swapLevel.."_SFX.bnk" | |||
elseif v.class == "Texture" then v.source = "Level_"..swapLevel.."/DuneColorShadow.dds" | |||
elseif v.class == "TerrainData" then | |||
v.outDir = "Level_"..swapLevel.."/" | |||
v.srcGround = "Level_"..swapLevel.."/LandColor.dds" | |||
v.srcHeight = "Level_"..swapLevel.."/Heightmap.dds" | |||
v.srcMask = "Level_"..swapLevel.."/MaskData.dds" | |||
end | |||
end | |||
swapLevel = "" | |||
end | |||
for i,resCons in ipairs( resTbl ) do | |||
DebugPrint( "Loading: Queuing "..resCons.name..", a "..resCons.class.."." ) | |||
-- Allocate the resource object. | |||
local metatbl = _G[ resCons.class ] | |||
local res = metatbl.new( alloc ) | |||
-- Initialize some values in the resource object based on the | |||
-- construction table. | |||
resCons.class = nil | |||
for varName,varValue in pairs( resCons ) do | |||
local varAccessor = res.__vars[ varName ] | |||
if varAccessor then varAccessor( res, varValue ) end | |||
end | |||
-- Tell the C++ end this resource is ready to be loaded. | |||
resManager:AddToLoadList( res ) | |||
end | |||
end | |||
"Script" resources are .lua's embedded in Journey.exe, but all other resources are loaded from the game folders. | |||
Keep in mind that some resource types reference each other in a way that will cause the game to crash if something is wrong/missing, so some resource sets can only be safely replaced if you properly replace certain others as well. | |||
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: | |||
{ | |||
{ | |||
class = "ScreamBank", | |||
name = "LvlSfx", | |||
source = "Graveyard-SFX.bank" | |||
}, { | |||
class = "ScreamBank", | |||
name = "LvlMus", | |||
source = "Graveyard-MUS.bank" | |||
}, { | |||
class = "TerrainData", | |||
name = "TerrainData", | |||
outDir = "Level_Graveyard/", | |||
srcGround = "Level_Graveyard/LandColor.dds", | |||
srcHeight = "Level_Graveyard/Heightmap.dds", | |||
srcMask = "Level_Graveyard/MaskData.dds" | |||
}, { | |||
class = "Binary", | |||
name = "HullInstances", | |||
source = "Scripts/Level_Graveyard/HullInstances.lua", | |||
type = "Hull" | |||
}, { | |||
class = "Binary", | |||
name = "DecorationMeshInstances", | |||
source = "Scripts/Level_Graveyard/DecorationMeshInstances.lua", | |||
type = "Decoration" | |||
}, { | |||
class = "Script", | |||
name = "EnvNodeInstances", | |||
source = "Level_Graveyard/EnvNodeInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "MarkerInstances", | |||
source = "Level_Graveyard/MarkerInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "ParticleEmitterInstances", | |||
source = "Level_Graveyard/ParticleEmitterInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "SoundEmitterInstances", | |||
source = "Level_Graveyard/SoundEmitterInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "SignInstances", | |||
source = "Level_Graveyard/SignInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "SignData", | |||
source = "Level_Graveyard/SignData.lua" | |||
}, { | |||
class = "Script", | |||
name = "JetInstances", | |||
source = "Level_Graveyard/JetInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "DynamicNodeInstances", | |||
source = "Level_Graveyard/DynamicNodeInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "CameraKeyFrameInstances", | |||
source = "Level_Graveyard/CameraKeyFrameInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "StartLocation", | |||
source = "Level_Graveyard/StartLocation.lua" | |||
}, { | |||
class = "Script", | |||
name = "TimelineInstances", | |||
source = "Level_Graveyard/TimelineInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "TriggerInstances", | |||
source = "Level_Graveyard/TriggerInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "ClumpInstances", | |||
source = "Level_Graveyard/ClumpInstances.lua" | |||
}, { | |||
class = "Script", | |||
name = "RailInstances", | |||
source = "Level_Graveyard/RailInstances.lua" | |||
}, { | |||
class = "Texture", | |||
gammaRemap = true, | |||
name = "DuneColorShadow", | |||
source = "Level_Graveyard/DuneColorShadow.dds" | |||
} | |||
} | |||
==Adding/Modifying Individual Resources== | |||
'''Important things to remember''' | |||
These methods do not actually edit how the game reads an embedded Level_''Somewhere''/''Something''Instances.lua , so these changes only last until the level is unloaded. When a level unloads, it seems the Names table is completely cleared, including any new objects you created that weren't in the original ''Something''Instances.lua. | These methods do not actually edit how the game reads an embedded Level_''Somewhere''/''Something''Instances.lua , so these changes only last until the level is unloaded. When a level unloads, it seems the Names table is completely cleared, including any new objects you created that weren't in the original ''Something''Instances.lua. | ||
| Line 30: | Line 179: | ||
*Load order not yet known for Particle Emitters, Sound Emitters, Terrain Data, the SFX/Music Banks, or the DuneColorShadow texture. | *Load order not yet known for Particle Emitters, Sound Emitters, Terrain Data, the SFX/Music Banks, or the DuneColorShadow texture. | ||
==Triggers== | ===Triggers=== | ||
Triggers are various types of events, including events that activate other events. They control basically everything that ever "happens" in a level, apart from basic player actions. | Triggers are various types of events, including events that activate other events. They control basically everything that ever "happens" in a level, apart from basic player actions. | ||
The functions in this category are mainly from EventSetter.lua . | The functions in this category are mainly from EventSetter.lua . | ||
===Modifying Triggers=== | ====Modifying Triggers==== | ||
To modify existing Triggers, find them in TriggerInstances.lua, define them in the TriggerInstances table with the same format used in that lua, then run the ResolveTriggerNames function. | To modify existing Triggers, find them in TriggerInstances.lua, define them in the TriggerInstances table with the same format used in that lua, then run the ResolveTriggerNames function. | ||
| Line 56: | Line 205: | ||
With this method by itself, if you change the trigger type to a different one than the original, it seems to (sometimes?) not work due to it expecting different data types; it's not yet known how to completely change the trigger type. You might be able to at least change trigger types if the Vars would be the same data types/names - for example if two trigger types both use { var1 = float, var2 = string, var3 = a Clump of Hulls, var4 = boolean } you could possibly switch from one type to the other and change the Var values and it would work; not tested yet. | With this method by itself, if you change the trigger type to a different one than the original, it seems to (sometimes?) not work due to it expecting different data types; it's not yet known how to completely change the trigger type. You might be able to at least change trigger types if the Vars would be the same data types/names - for example if two trigger types both use { var1 = float, var2 = string, var3 = a Clump of Hulls, var4 = boolean } you could possibly switch from one type to the other and change the Var values and it would work; not tested yet. | ||
===Creating new Triggers=== | ====Creating new Triggers==== | ||
You can temporarily create new triggers basically the same way, by adding the CreateTriggers function: | You can temporarily create new triggers basically the same way, by adding the CreateTriggers function: | ||
| Line 98: | Line 247: | ||
</code> | </code> | ||
==Clumps== | ===Clumps=== | ||
Clumps are groups of multiple objects, used so that a single Trigger can reference and/or manipulate everything in the Clump at once. | Clumps are groups of multiple objects, used so that a single Trigger can reference and/or manipulate everything in the Clump at once. | ||
| Line 106: | Line 255: | ||
The functions in this category are from ClumpLoader.lua. | The functions in this category are from ClumpLoader.lua. | ||
===Creating new Clumps=== | ====Creating new Clumps==== | ||
To create new Clumps, define the ClumpInstances table with the same format used in ClumpInstances.lua (but concatenated, not with line breaks). Then run the LoadClumps function, then the SetClumpMembers function. | To create new Clumps, define the ClumpInstances table with the same format used in ClumpInstances.lua (but concatenated, not with line breaks). Then run the LoadClumps function, then the SetClumpMembers function. | ||
| Line 141: | Line 290: | ||
</code> | </code> | ||
===Modifying Clumps=== | ====Modifying Clumps==== | ||
To modify existing Clumps, get them from ClumpInstances.lua and do basically the same code, but without the LoadClumps function: | To modify existing Clumps, get them from ClumpInstances.lua and do basically the same code, but without the LoadClumps function: | ||
| Line 165: | Line 314: | ||
</code> | </code> | ||
==Timelines== | ===Timelines=== | ||
Timelines are timed sequences of Trigger activations, used to organize cutscenes and other events where a bunch of Triggers get activated in a row. | Timelines are timed sequences of Trigger activations, used to organize cutscenes and other events where a bunch of Triggers get activated in a row. | ||
| Line 177: | Line 326: | ||
</code> | </code> | ||
==Creatures / Dynamic Nodes== | ===Creatures / Dynamic Nodes=== | ||
Creatures are dynamically moving and interacting objects, other than the player avatars and the tiny flying cloths (Strands). | Creatures are dynamically moving and interacting objects, other than the player avatars and the tiny flying cloths (Strands). | ||
| Line 195: | Line 344: | ||
It seems that Creatures/Dynamic Nodes might actually be Triggers, based on how TriggerInitialize() is also used in Creatures.lua - so new Creatures might have the same issue as Triggers, and might disappear from the Names table shortly after being created with this method. | It seems that Creatures/Dynamic Nodes might actually be Triggers, based on how TriggerInitialize() is also used in Creatures.lua - so new Creatures might have the same issue as Triggers, and might disappear from the Names table shortly after being created with this method. | ||
==Particle Emitters== | ===Particle Emitters=== | ||
Particle Emitters emit particles (sparkles, puffs of sand/dust, etc.) | Particle Emitters emit particles (sparkles, puffs of sand/dust, etc.) | ||
| Line 209: | Line 358: | ||
Based on tests where logging code was put in LoadEnvFXParticles() and ParticleEmitterInitialize() and nothing was logged, it seems this script doesn't actually run at level start, so Particle Emitters might be added to Names table by another Lua script or by inaccessible C code. But maybe this function could still add/modify Particle Emitters anyway. | Based on tests where logging code was put in LoadEnvFXParticles() and ParticleEmitterInitialize() and nothing was logged, it seems this script doesn't actually run at level start, so Particle Emitters might be added to Names table by another Lua script or by inaccessible C code. But maybe this function could still add/modify Particle Emitters anyway. | ||
==Sound Emitters== | ===Sound Emitters=== | ||
Sound Emitters emit sounds. They can be stationary or attached to a moving object somehow. It seems that most looping music is played by Sound Emitters that are set to be audible at the same volume anywhere in the level. | Sound Emitters emit sounds. They can be stationary or attached to a moving object somehow. It seems that most looping music is played by Sound Emitters that are set to be audible at the same volume anywhere in the level. | ||
| Line 223: | Line 372: | ||
Based on tests where logging code was put in LoadSoundEmitters() and SoundEmitterInitialize() and nothing was logged, it seems this script doesn't actually run at level start, so Sound Emitters might be added to Names table by another Lua script or by inaccessible C code. But maybe this function could still add/modify Sound Emitters anyway. | Based on tests where logging code was put in LoadSoundEmitters() and SoundEmitterInitialize() and nothing was logged, it seems this script doesn't actually run at level start, so Sound Emitters might be added to Names table by another Lua script or by inaccessible C code. But maybe this function could still add/modify Sound Emitters anyway. | ||
==Environment Nodes== | ===Environment Nodes=== | ||
Environment/Env Nodes set the environmental effects within certain regions, such as lighting, sky color, shadows, fog, bloom, etc. | Environment/Env Nodes set the environmental effects within certain regions, such as lighting, sky color, shadows, fog, bloom, etc. | ||
| Line 240: | Line 389: | ||
LoadEnvNodes does ''not'' clear the EnvNodeInstances table automatically upon completion, and the code comments say this causes a crash, so might be a bad idea to do it yourself. | LoadEnvNodes does ''not'' clear the EnvNodeInstances table automatically upon completion, and the code comments say this causes a crash, so might be a bad idea to do it yourself. | ||
==Markers== | ===Markers=== | ||
Markers seem to be locations, or regions of space around locations, which objects can be aimed or moved towards/away from by certain Triggers. Also, Markers can be moved around or attached to moving objects by Triggers. | Markers seem to be locations, or regions of space around locations, which objects can be aimed or moved towards/away from by certain Triggers. Also, Markers can be moved around or attached to moving objects by Triggers. | ||
| Line 252: | Line 401: | ||
</code> | </code> | ||
==Rails== | ===Rails=== | ||
Rails seem to be paths that objects can move along. | Rails seem to be paths that objects can move along. | ||
| Line 265: | Line 414: | ||
( There doesn't seem to be a game:railBarn(), so maybe it's a different name in game:, or maybe it's used like RailBarn, RailBarn() or RailBarn(game). ) | ( There doesn't seem to be a game:railBarn(), so maybe it's a different name in game:, or maybe it's used like RailBarn, RailBarn() or RailBarn(game). ) | ||
==Camera Key Frames== | ===Camera Key Frames=== | ||
Camera Key Frames seem to be the data for basically any location/angle/etc that the camera can get moved to, whenever the camera moves by itself - not just following behind the player, or being moved around by the player. | Camera Key Frames seem to be the data for basically any location/angle/etc that the camera can get moved to, whenever the camera moves by itself - not just following behind the player, or being moved around by the player. | ||
| Line 277: | Line 426: | ||
</code> | </code> | ||
==Jets== | ===Jets=== | ||
Jets seem to be the physics effect that pushes your avatar down when you are inside certain sandfalls, and maybe other effects. Could probably be used to push the avatar in other directions as well. | Jets seem to be the physics effect that pushes your avatar down when you are inside certain sandfalls, and maybe other effects. Could probably be used to push the avatar in other directions as well. | ||
| Line 290: | Line 439: | ||
( There doesn't seem to be a game:jetBarn(), so maybe it's a different name in game:, or maybe it's used like JetBarn, JetBarn() or JetBarn(game). ) | ( There doesn't seem to be a game:jetBarn(), so maybe it's a different name in game:, or maybe it's used like JetBarn, JetBarn() or JetBarn(game). ) | ||
==Signs== | ===Signs=== | ||
Signs are scrolling text, used only in the credits. Could maybe be used for other scrolling text as well, although there seem to already be scrolling text Triggers that might be easier for that. | Signs are scrolling text, used only in the credits. Could maybe be used for other scrolling text as well, although there seem to already be scrolling text Triggers that might be easier for that. | ||
| Line 305: | Line 454: | ||
( There doesn't seem to be a game:signBarn(), so maybe it's a different name in game:, or maybe it's used like SignBarn, SignBarn() or SignBarn(game). Also, signData/signInstances don't seem to actually be referenced inside InitializeSignBarn, so they might not be required, but if required then maybe signData is Credits and signInstances is SignInstances. ) | ( There doesn't seem to be a game:signBarn(), so maybe it's a different name in game:, or maybe it's used like SignBarn, SignBarn() or SignBarn(game). Also, signData/signInstances don't seem to actually be referenced inside InitializeSignBarn, so they might not be required, but if required then maybe signData is Credits and signInstances is SignInstances. ) | ||
==TBD / Other== | ===TBD / Other=== | ||
These are the remaining types of level resources. They can *maybe* be manipulated in real time with Lua code, but it's not yet known if/how it can be done. | These are the remaining types of level resources. They can *maybe* be manipulated in real time with Lua code, but it's not yet known if/how it can be done. | ||
===Hulls=== | ====Hulls==== | ||
Hulls are regions of space that never move(?), which are used as physical collision geometry and/or a way for Triggers to determine "if ''this thing'' is touching/inside ''this region'', do ''this event''". | Hulls are regions of space that never move(?), which are used as physical collision geometry and/or a way for Triggers to determine "if ''this thing'' is touching/inside ''this region'', do ''this event''". | ||
| Line 315: | Line 464: | ||
You can change the Hulls loaded at start of level by editing HullInstances.lua in the folder for that level under Data/Scripts. | You can change the Hulls loaded at start of level by editing HullInstances.lua in the folder for that level under Data/Scripts. | ||
===Decoration Meshes=== | ====Decoration Meshes==== | ||
Decoration Meshes are any visible object other than terrain, fog, particle effects, Strands(?), and the basic "naked" player avatar. By themselves, they are not physical objects, their collision data comes from physical Hulls put in the same place. | Decoration Meshes are any visible object other than terrain, fog, particle effects, Strands(?), and the basic "naked" player avatar. By themselves, they are not physical objects, their collision data comes from physical Hulls put in the same place. | ||
| Line 321: | Line 470: | ||
You can change the Decoration Meshes loaded at start of level by editing DecorationMeshInstances.lua.bin in the folder for that level under Data/Scripts. | You can change the Decoration Meshes loaded at start of level by editing DecorationMeshInstances.lua.bin in the folder for that level under Data/Scripts. | ||
===Sound Banks=== | ====Sound Banks==== | ||
SFX Banks contain sounds, and references/mixing data for longer sounds streamed from the audio files in Data/Sounds/Streams. | SFX Banks contain sounds, and references/mixing data for longer sounds streamed from the audio files in Data/Sounds/Streams. | ||
| Line 329: | Line 478: | ||
These are LevelSfx''Somewhere''-SFX.bnk and LevelMus''Somewhere''-MUS.bnk in the Data/Sounds folder; not much is known yet about how to edit these at all, other than renaming files to swap one level for another. | These are LevelSfx''Somewhere''-SFX.bnk and LevelMus''Somewhere''-MUS.bnk in the Data/Sounds folder; not much is known yet about how to edit these at all, other than renaming files to swap one level for another. | ||
===TerrainData=== | ====TerrainData==== | ||
Terrain Data determines the terrain's Height Map and Land Color (the color of sand/snow added to the sides and/or top of some Decoration Meshes, and that collects on the player avatars). It also determines Mask Data which seems to be unused. | Terrain Data determines the terrain's Height Map and Land Color (the color of sand/snow added to the sides and/or top of some Decoration Meshes, and that collects on the player avatars). It also determines Mask Data which seems to be unused. | ||
| Line 335: | Line 484: | ||
You can change what is loaded at start of level by editing the TerrainData.bin inside TerrainData.bin.gz in the Data/Terrain/Level_''Somewhere'' folder. | You can change what is loaded at start of level by editing the TerrainData.bin inside TerrainData.bin.gz in the Data/Terrain/Level_''Somewhere'' folder. | ||
===DuneColorShadow=== | ====DuneColorShadow==== | ||
DuneColorShadow is a texture that determines the color of the terrain in a level, and which areas are in shadow. | DuneColorShadow is a texture that determines the color of the terrain in a level, and which areas are in shadow. | ||
You can change what is loaded at the start of a level by editing/replacing the DuneColorShadow.dds texture inside the DuneColorShadow.dds.D3D11x64 file in the Data/Textures/Level_''Somewhere''/Bin folder. | You can change what is loaded at the start of a level by editing/replacing the DuneColorShadow.dds texture inside the DuneColorShadow.dds.D3D11x64 file in the Data/Textures/Level_''Somewhere''/Bin folder. | ||