Difference between revisions of "Lua Functions List"

From Journey Modding Wiki
Jump to navigation Jump to search
m (cat upd)
m
Line 1: Line 1:
[[Category:Lua Code]]
[[Category:Lua Code]]
[[Category:Native Lua Functions]]
[[Category:Native Lua Functions]]
;ActivateTriggerByName( ObjectName )
;ActivateTriggerByName( ObjectName )
;OR
;OR

Revision as of 07:20, 25 September 2021

ActivateTriggerByName( ObjectName )
OR
Names["ObjectName"].Start()
Activates a Trigger or Timeline which is loaded in the current level, using their ObjectName.


CONFIG = ...
Changes the global variable CONFIG which shows what sort of build the game is. "Valid" options appear to be Gold, PublicBeta, Demo, Production, and Debug. Using anything other than Gold/PublicBeta/Demo will turn on DebugPrint which outputs some debug info to stdout.txt . Using Production or Debug might allow some scripts to work that are otherwise unusable, hasn't been fully explored.
publicBeta corresponds to the E3 2011 three level demo set, there's a check in Resources that prevents loading other levels. if the config is changed in a disallowed level then a changelevel to a allowed level is performed, the game fails to uninitialize it due to the blocking causing a strange state.
Demo is retail trial mode, fine details unknown, should function about the same but on trial mode, try removing Guard/Guard.txt.edat which is Clark's DRM idea.


DumpClassInfos(c)
A basic customized function included in StartLua.lua, which shows what is included in classes/other objects that Lua can access, printed to ClassInfo.txt in Journey root folder. Good for finding functions/variables/etc that aren't defined in the .lua's.
(For "c", use _G to see everything at the top level, then use the name of almost anything marked as a table to see inside of it, and to see inside deeper use TopTable.TableInside.TableDeeperInside.Etc .)


DumpMetaSys()
Creates TempMetasystem.lua in Journey root folder, which shows "A table of all non-abstract classes registered with the meta system". This file is useful to see all the possible triggers (will have metadata GardenerType = "Trigger") and the variables you can set for those triggers (it shows ObjectName, activityId, and lightbarId in all of them but these are not required to be set).
(The function that the game defines in Tick.lua will crash your game; the default StartLua.lua modifies it to work the same and not crash)


game:cameraSystem():StartDebugCam() & game:cameraSystem():StopDebugCam()
Start/stop the debug camera, which detaches from your character and can be rapidly moved all over the level. Press fly button/key to teleport your character in front of the camera. If debugHud is on, it will show the debug cam coordinates and other info. Keyboard and controller have different types of movement control so it can be useful to use both.
If you need to tilt the camera up/down, run game:cameraSystem():GetDebugCam():SetAngleLock(true) and use keyboard keys assigned to forward/back. Run same code but with (false) to go back to regular debugcam control scheme.
Additionally a Cinematic mode can be enabled that enables smoothed movement in addition to up/down tilting by running game:cameraSystem():GetDebugCam():SetCinematicMode(true) it appears that dpad and left stick perform two different things here as w/s causes both fov adjustment and elevation modifications


game:pauseSystem():DebugPrevKeyFrame(game:cameraSystem()) & game:pauseSystem():DebugNextKeyFrame(game:cameraSystem())
Allows moving back and forth across the menu/pause/screensaver slides that are active.


game:debugHud():CycleMode()
Displays a HUD showing information about network connection, camera states, timelines, and profiling information; cycles through three different levels of detail.


game:gameTiming():GetTotalTime()
Returns game time in long data type, this number constantly increases.
Can be used for in-game timers.


game:input():GetPad(0):Right() & game:input():GetPad(0):Left();
Controller sticks
Returns an array[1-2] with numbers between 1 to -1 depending on joystick position.
[1] is left/right axis
[2] is up/down axis


game:input():GetPad(0):WasButtonPressed( number );
Returns true when specified action button is pressed. (keyboard or controller) You cannot be in main menu or sitting down to trigger Fly and possibly other buttons.
More values may exist, needs testing.
Unfortunately ScePad on PC is emulated meaning that for the most part we're limited to the following buttons:
12 = Fly button (A/X)
13 = Chirp button (B/O)
19 = Pause button (Select?/Start?)
20 = Menu button (Start/Esc?)


game:matchmaker():Disconnect()
Self-explanatory, instant disconnection.


game:netGui():ToggleEnabled()
(needs cheats enabled) Turns on the NetGui HUD, which shows other players in the same "lobby" for the current level and lets you try to manually connect to them (might only be able to show up to 4, even if there are others you can connect to), or shows your current companion.
You can move up/down in this menu with whatever keys are assigned to move forward/back (default W/S) (Not available in all versions), and select something by running game:netGui():ExecuteSelectedItem(game). It seems you still need to be nearby a player and have the same lobby flags triggered to connect to them, or at least to stay connected.
Before you can reconnect to another player after leaving them, the wayfarer on their screen must first dust, which could take up to 30 seconds.


game:netGui():SelectNextItem() & game:netGui():SelectPreviousItem()
Can be used to move up and down NetGui without using W/S keys.

Lua code to move NetGui using Right Joystick up/down

local rightJoystick = game:input():GetPad(0):Right() 

if (rightJoystick[2] == 1) then
    game:netGui():SelectNextItem()
elseif (rightJoystick[2] == -1) then
    game:netGui():SelectPreviousItem()
end


game:playerBarn():GetLocalDude():SetOutfit( number )
Note: This function does not replace your actual saved robe per se, returning to chapter select reveals this.
Changes your robe tier/color based on the number. Change is visible to companion (but maybe sometimes is not?)
0, 1, 2, 3 are red robe tiers 1, 2, 3, 4
4, 5, 6 are white robe tiers 2, 3, 4
7 and above (and negative numbers?) also appear in-game as white robe tier 4, but that "outfit" value in memory does stay as whatever number you set (it isn't reset to 6), and that same value also appears in your companion's game's memory as the RemoteDude outfit value. This could be used as one way to remotely send info between modded games, if the mod can directly read memory values.


game:playerBarn():GetLocalDude():SetPos(game:playerBarn():GetRemoteDude():GetPos())
Teleports your wayfarer to where the companion is, will throw a nil error or crash if no remotehijack is active and no companion is connected.


game:playerBarn():GetLocalDude()/GetRemoteDude():GetAnimBarn():QueueAnimation( animName, blendIn, blendOut, animSpeed, numLoops, duration )
Can play any animation defined in animDatas table in DudeAnimation.lua , but it seems to only be visible in your own game. LocalDude is you, RemoteDude is your companion(might only work while they are hijacked by "Nick"). :Documentation from DudeAnimation.lua: "blendIn, blendOut, and duration are in seconds. to use duration, set numLoops = 0, otherwise it will be ignored. you can set numLoops < 0 to fit a certain number of complete loops in a duration. you can set duration to be a negative number if you want it to keep playing until you stop it."


game:playerBarn():GetLocalDude():FillScarf( number, game:soundBarn() )
Ability to give or take scarf energy, value is relative, negative values remove scarf energy


game:soundBarn():ToggleMuteMusic()
Toggles game music ON / OFF


game:QueueLevel( "Level_Name" )
Instantly warps player to beginning of specified level and starts regular triggers. Not recommended as it is known to break Level_Bryan, changelevel triggers perform the correct behavior.
Available options: Level_Graveyard, Level_Barrens, Level_Desert, Level_Canyon, Level_Cave, Level_Ruins, Level_Mountain, Level_Summit, Level_Credits, Level_Matt, Level_Bryan, Level_Chris


SpawnEvent{ triggertype = { var1 = a, var2 = b, etc } }
Makes an event happen as if a trigger from the level's TriggerInstances.lua had been triggered, you can do a very large amount of custom events this way.
(Use the name of a trigger's Type as seen in TriggerInstances.lua for "triggertype", and fill in the variables the same way TriggerInstances shows for that type of trigger. You can also generate and view TempMetasystem.lua to see all trigger types including some that are unused in the regular game, see below)
(This function is defined in PWeb3.lua but will not work unless you define it yourself; the default StartLua.lua will do that for you)
Examples:
SpawnEvent { DisplayText = { text = "Text that shows up on your screen", x = 0, y = 0, duration = 3, fadeTime = 0.5, scale = 0.1 } }
SpawnEvent { PlayDudeAnim = { animName = "Name of an animation sequence defined in DudeAnimation.lua", clearAnimQueue = true, useLocal = true}}
(plays that animation for your character, and your companion will also be able to see it. Do useLocal=false to play animations on your companion if they are currently hijacked by "Nick")


SpawnEvent{ SetMaxCloth = { changeAmount = number } }
Changes wayfarer cape length relatively using any positive or negative number to give or take.
Does not get past cape limit which is controlled by Vars.Dude.kScarfMaxCapacity


ToggleDMActive(game)
Toggles "Rocket Death Match" mode on and off. Chirp to shoot rockets, press fly button/key rapidly to jump. Your companion can't see your rockets/explosions/craters/etc, but they do see you moving around strangely due to the third-person-shooter controls, jumping really high, never truly flying, etc. (appears to be client sided requiring both to activate this function to work, fired rockets do not show up)


Vars.DudeAnimation.kDebugConsoleEnabled(true)
Toggles a debug HUD with information about player animations being used.


Vars.Game.cheatsEnabled(true)
Needed for NetGui HUD to be turned on, and possibly other unknown things. Is reset to "false" when game loads so you must use lua script to set it to "true".


Vars.Game.allowCheatToggling(true)
Vars.Game.bNetworkDebugKeys(true)
Unknown but significant functionality related to unknown debug/developer enablement.


Vars.Lobby.kUseAutoLobby(true/false)
Turns on/off the AutoLobby system, which is what does matchmaking. Turning off is useful to avoid meeting a random player while trying to connect to someone specific using NetGui, or for playing solo without bothering with firewall/internet connection. If AutoLobby is off, your name can't show up in NetGui for someone else unless you select "Host Game" in NetGui. Does not affect existing SuppressAutoLobby triggers.


Vars.SoundBarn.kEnableDebugHud(true/false)
Toggles a debug HUD with information about sounds being used.


SaveVars("SavedVars.lua")
Writes runtime variables from memory to a file, useful for contextual realization.


Vars.table.setting(value)
Changes settings controlled by Vars.lua. You can also just change the values in Journey.exe itself, but this script is good for changing things while playing, and also some things will be changed by the game when it loads and you must use this script to actually make the game do what you want.
(See Vars.lua in Data/Scripts for possible settings: use a table/category name for "table", the specific setting name within that category for "option", and the desired value for "value".)