Difference between revisions of "Lua Functions List"

Jump to navigation Jump to search
2,388 bytes added ,  07:07, 25 September 2021
major improvement according to some community advancements
(major improvement according to some community advancements)
Line 1: Line 1:
[[Category:Lua Code]]
[[Category:Lua Code]]
==Functions==


;ActivateTriggerByName( ObjectName )
;ActivateTriggerByName( ObjectName )
Line 10: Line 9:
;CONFIG = ...
;CONFIG = ...
:Changes the global variable CONFIG which shows what sort of build the game is. "Valid" options appear to be <code>Gold, PublicBeta, Demo, Production, and Debug.</code> 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.
:Changes the global variable CONFIG which shows what sort of build the game is. "Valid" options appear to be <code>Gold, PublicBeta, Demo, Production, and Debug.</code> 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.




Line 25: Line 26:
: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.
: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 <code>game:cameraSystem():GetDebugCam():SetAngleLock(true)</code> and use keyboard keys assigned to forward/back. Run same code but with (false) to go back to regular debugcam control scheme.
:If you need to tilt the camera up/down, run <code>game:cameraSystem():GetDebugCam():SetAngleLock(true)</code> 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 <code>game:cameraSystem():GetDebugCam():SetCinematicMode(true)</code> it appears that dpad and left stick perform two different things here as w/s causes both fov adjustment and elevation modifications
;<nowiki>game:pauseSystem():DebugPrevKeyFrame(game:cameraSystem()) & game:pauseSystem():DebugNextKeyFrame(game:cameraSystem())</nowiki>
: Allows moving back and forth across the menu/pause/screensaver slides that are active.




;<nowiki>game:debugHud():CycleMode()</nowiki>
;<nowiki>game:debugHud():CycleMode()</nowiki>
:Displays a HUD showing information about connection, cameras, trigger timelines, and memory use(?); cycles through three different levels of detail.
:Displays a HUD showing information about network connection, camera states, timelines, and profiling information; cycles through three different levels of detail.




Line 37: Line 43:


;<nowiki>game:input():GetPad(0):Right() & game:input():GetPad(0):Left();</nowiki>
;<nowiki>game:input():GetPad(0):Right() & game:input():GetPad(0):Left();</nowiki>
: Controller sticks
: Returns an array[1-2] with numbers between 1 to -1 depending on joystick position.
: Returns an array[1-2] with numbers between 1 to -1 depending on joystick position.
::[1] is left/right axis
::[1] is left/right axis
Line 45: Line 52:
: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.
: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.
:More values may exist, needs testing.
::12 = Fly button
:Unfortunately ScePad on PC is emulated meaning that for the most part we're limited to the following buttons:
::13 = Chirp button
::12 = Fly button (A/X)
::19 = Pause button
::13 = Chirp button (B/O)
::20 = Menu button
::19 = Pause button (Select?/Start?)
::20 = Menu button (Start/Esc?)
 
 
;<nowiki>game:matchmaker():Disconnect()</nowiki>
:Self-explanatory, instant disconnection.




;<nowiki>game:netGui():ToggleEnabled()</nowiki>
;<nowiki>game:netGui():ToggleEnabled()</nowiki>
:(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.
:(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), 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.
::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.
::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.


Line 70: Line 82:


;<nowiki>game:playerBarn():GetLocalDude():SetOutfit( number )</nowiki>
;<nowiki>game:playerBarn():GetLocalDude():SetOutfit( number )</nowiki>
: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?)
: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
::0, 1, 2, 3 are red robe tiers 1, 2, 3, 4
::4, 5, 6 are white robe tiers 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.
::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.
;<nowiki>game:playerBarn():GetLocalDude():SetPos(game:playerBarn():GetRemoteDude():GetPos())</nowiki>
: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.




;<nowiki>game:playerBarn():GetLocalDude()/GetRemoteDude():GetAnimBarn():QueueAnimation( animName, blendIn, blendOut, animSpeed, numLoops, duration )</nowiki>
;<nowiki>game:playerBarn():GetLocalDude()/GetRemoteDude():GetAnimBarn():QueueAnimation( animName, blendIn, blendOut, animSpeed, numLoops, duration )</nowiki>
: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."
: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."
;<nowiki>game:playerBarn():GetLocalDude():FillScarf( number, game:soundBarn() )</nowiki>
:Ability to give or take scarf energy, value is relative, negative values remove scarf energy




Line 85: Line 106:


;<nowiki>game:QueueLevel( "Level_Name" )</nowiki>
;<nowiki>game:QueueLevel( "Level_Name" )</nowiki>
:Instantly warps player to beginning of specified level and starts regular triggers.
: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: <code>Level_Graveyard, Level_Barrens, Level_Desert, Level_Canyon, Level_Cave, Level_Ruins, Level_Mountain, Level_Summit, Level_Credits, Level_Desert, Level_Bryan, Level_Chris</code>
:Available options: <code>Level_Graveyard, Level_Barrens, Level_Desert, Level_Canyon, Level_Cave, Level_Ruins, Level_Mountain, Level_Summit, Level_Credits, Level_Matt, Level_Bryan, Level_Chris</code>




;SpawnEvent{ triggertype = { var1 = a, var2 = b, etc } }
;<nowiki>SpawnEvent{ triggertype = { var1 = a, var2 = b, etc } }</nowiki>
: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.
: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)
:(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)
Line 100: Line 121:


;<nowiki>SpawnEvent{ SetMaxCloth = { changeAmount = number } }</nowiki>
;<nowiki>SpawnEvent{ SetMaxCloth = { changeAmount = number } }</nowiki>
:Changes wayfarer cape length using any positive or negative number. You can reach max/zero length by changing amount by +/- 30, but cannot go past past the regular cape limit using this function.
: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)
; 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.
: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)




Line 113: Line 135:
;Vars.Game.cheatsEnabled(true)
;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".
: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)
; 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.
: 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)
;Vars.SoundBarn.kEnableDebugHud(true/false)
:Toggles a debug HUD with information about sounds being used.
: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.




Navigation menu