Developer Console

From A Hat in Time Wiki
Jump to navigation Jump to search

This page describes content only available in the Steam release of A Hat in Time.
Other versions may have it with limited functionality or may lack it entirely.

The Console with some inputted console commands.

The Developer Console (simply known as Console) is a command-line interface that allows us to write Console Commands to change the game's state.

By default, the console is disabled and can only be enabled directly from the game by going to Settings -> Game Settings -> Scroll to System Settings and then check "Developer Console". To open the console press Keyboard tilde.png for the full console, if you want a smaller one line only you can press Key tab.png to write one command and it will automatically close afterwards.

Executable Functions

The console allows us to run executable functions that are defined with exec in the source code, for example exec function RestartLevel() defined in PlayerController.uc can be written into the console as restartlevel to restart the level (to the last checkpoint).

Some console commands require additional parameter(s) to run in that case each parameter needs to be separated by a space, for examples:

  • exec function FOV(float F)
    • fov <F>
      • fov 50 -> camera will look zoomed in.
  • [Requires cheats] exec function SetSkinColor(String BodyPart, int R, int G, int B)
    • setskincolor <BodyPart> <R> <G> <B>
      • setskincolor Hair 0 250 154 -> Your hair color is now Medium Spring Green.

These functions must be valid and existing in the current space, e.g. you cannot use CheatManager related executable functions without it being created first this is what the enablecheats command does in this regard, see #Enable Cheats for an example.

If you attempt to run any executable functions that don't exist in the current context it will print into the console the following error:

Command not recognized: <command>

Custom Console Commands

The simplest way to add custom console commands is through a custom Interaction subclass:

// NOTE: "within PlayerController" allows this class to use the outer PlayerController's functions, such as ClientMessage().
class Example_CustomCommands extends Interaction within PlayerController; 

// type "someconsolecommand"
// result: "Hello world!"
exec function SomeConsoleCommand()
{
    ClientMessage("Hello world!");
    // Your code here...
} 

// type "anotherconsolecommand <s>"
// example: "anotherconsolecommand hi :3" {{!}} result: "Simon says: hi :3"
exec function AnotherConsoleCommand(Coerce String s)
{
    ClientMessage("Simon says:" @ s);
}

This class has to be instantiated and inserted into the PlayerController.Interactions array. For example, you can do this through the GameMod:

class Example_GameMod extends GameMod; 

var Interaction CommandsInteraction; 

event OnModLoaded()
{
    SetTimer(0.001f, false, NameOf(RegisterCommands));
} 

event OnModUnloaded()
{
    UnregisterCommands();
} 

function RegisterCommands()
{
    local PlayerController PC; 

    PC = GetALocalPlayerController();
    if (PC == None) return; 

    if (CommandsInteraction != None && PC.Interactions.Find(CommandsInteraction) != INDEX_NONE) return; 

    CommandsInteraction = new(PC) class'Example_CustomCommands';
    PC.Interactions.InsertItem(0, CommandsInteraction);
} 

function UnregisterCommands()
{
    local PlayerController PC; 

    if (CommandsInteraction == None) return; 

    PC = GetALocalPlayerController();
    if (PC != None)
        PC.Interactions.RemoveItem(CommandsInteraction); 

    CommandsInteraction = None;
}

Compatible Classes

Besides Interactions, there's a few other classes that can add new console commands. Here's the full list of them:

  • GameViewportClient
  • GameInfo / Hat_Game
  • PlayerInput / Hat_PlayerInput
  • PlayerController / Hat_PlayerControllerSpecial
  • Pawn / Hat_Player (player-controlled)
  • InventoryManager / Hat_InventoryManager
  • Weapon / Hat_Weapon_Umbrella
  • HUD / Hat_HUD
  • CheatManager / Hat_CheatManager (when cheats are enabled)
  • Interaction - Those in the PlayerController.Interactions array. This is the easiest way for mods to add console commands, even outside of custom levels.

NOTE: Commands are prioritized from top to bottom in that list. The order in the Editor is slightly different though, as GameInfo is below HUD in playtests.

Enable Cheats

Cheats are commands that provide an advantage in game play and can only be used when cheats are enabled, to activate you need to write enablecheats into the console or by pressing Keyboard o.png on your keyboard, doing so results in Hat_CheatManager getting initialized and all its functions valid for execution. Despite their cheaty nature they do not disable Achievements.

You cannot enable cheats while in an Online Party (and enabling cheats before entering the lobby will resulting in them getting disabled) resulting in the following message:

"Cheats cannot be enabled while Online Functionality is on."

In Death Wish enabling cheats will result in you taking 1 damage with Snatcher writing into the console mocking you for trying to circumvent the rules of the Death Wish:

"Didn't you read the fine print in your contract? No cheating!"
"Trying to cheat me, eh kid?"
"I write the rules, kiddo. You don't get to change them like that!"
"Now where's the fun in that?"

Cheats are always enabled by default while using the Editor.

Kismet

You can run console commands directly from Kismet using the "Console Command" node, inside the node you can input a list of commands to be run by order. If you want to use commands that requires cheats prior please specify enablecheats before running them, additionally to avoid bugs do not run these commands when the level is loaded through the "Level Loaded" event node but instead by using the "Player Spawned" event node.

List of Commands

These can be used at any time without requiring prior commands to get them enabled. Some commands are marked "With caution" or "Dangerous" depending on their severity, please read carefully before using them.

Clicking on any command will make a direct link to the command.

Command Description
bind <key> <command> With caution. Bind a keyboard key to a specific console command, see this list for the proper naming conventions especially for None-Alphabetic buttons.

Binds are saved in the game's installation directory under HatinTime\HatinTimeGame\Config\HatinTimeInput.ini starting at the bottom of the file, to unbind you need to exit the game and edit the file then save. You can also adjust those bindings to work with Ctrl / Shift / Alt from the file (but this also requires a game restart to take effect).
set <class> <variable> <value> Sets the <variable> of <class> to <value> of ALL objects in the world, the passed <value> must be the correct data type of <variable>. This is now considered the new DEFAULT value and will persist even after restarting the level until you close the game.
getall <class> <variable> Displays all <variable>s of all instances of <class>.
getallstate <class> Displays the states of all instances of <class>.
show <type> Toggles Editor related helper based on the passed <type>. Valid: bounds, collision, cover, decals, fog, levelcoloration, paths, postprocess, skelmeshes, terrain, volumes, splines.
stat <type> Shows debug information on screen related to <type>. Valid: fps, unit, levels and collision. ghostparty is only valid in Online Party.
showdebug Dangerous. Enables an assortment of debug related utility. This seems bugged and will cause the game to crash because it ran out of memory due to debug line drawing not being removed. You can avoid this by calling flushpersistentdebuglines every now and then to clear the lag. This command cannot be disabled until you load a new map (e.g. quit to main menu) or reload the map through any means such dying or writing suicide/restartlevel in the console.
flushpersistentdebuglines Exactly as calling FlushPersistentDebugLines(); that is found in the Actor class. Removes all instances of debug lines, good to call in case of lag from the tons of debug lines that were created.
open <file_name> Opens a valid map file named <file_name>. Example: open hub_spaceship opens the Spaceship Map.
exit Closes the game.
disconnect Returns back to the Main Menu.
togglehud Show/Hides the HUD, during the hide state the HUD is completely uninteractable.
enablecheats Allows you to use more commands that are marked as "cheating", this command cannot be run while in Online Party and causes 1 damage while a Death Wish contract is active. This gets automatically executed when opening the Editor. Casting this command or their "cheat" commands do not disable acquiring achievements.
fov <value> Sets your camera's field of view to <value>, <value> is clamped between 1 and 170 anything higher or lower will reset the field of view to the default. Default is 90.
say <message> Write into the console "[Steam Name]: <message>", this has no interaction in Online features.
restartlevel Restart the level to the last checkpoint without saving. This can be used to circumvent mechanics that occur on death such as 3x Miscponheart.png lives system from Death Wish and Challenge Road, causing infinite lives as long as you restart level before the UI removes one life and save game.
pause Opens the Pause menu.
startfire 0 Similar to firing left click causing an attack.
suicide Commit suicide by calling Died() on the player who called this with the received damage type as DmgType_Suicided.
jump Causes the player to jump.
remoteevent [event=""]
re [event=""]
Triggers a remote event that is defined in the map's Kismet, if these commands were called while keeping <event> empty, they will instead print all possible remote event that can be called into the console.
invertmouse With caution. Invert the vertical movement of the camera and save changes. Call it again to revert the change.
invertturn With caution. Invert the horizontal movement of the camera and save changes. Call it again to revert the change.
setsensitivity Set your mouse sensitivity. Default is 30.
duck Activates crouching.
unduck Deactivates crouching.
playeremotestart Opens the Emote wheel.
playeremotestop Closes the emote wheel, if it was hovering on an item, it will emote that item.

List of Commands Marked as Cheating

These commands are marked as cheating and thus they require to write enablecheats into the console for them to work, this doesn't apply to the Editor as cheats are enabled by default. The Editor column implies that these commands can only be used through the A Hat in Time Editor that is provided through the Modding Tools. Some commands are marked "With caution" or "Dangerous" depending on their severity, please read carefully before using them.

Clicking on any command will make a direct link to the command.

Command Editor Description
walk No.png Sets the player to walking state.
fly No.png Sets the player to flying state.
ghost No.png Sets the player to ghost state.
god No.png Toggles god mode.
benchcamera No.png Create a camera that works similar to sitting on a chair. Call again to put the camera back to normal.
skipforward No.png Sets and teleports you to the next checkpoint. Free Roam maps are instead get their Acts incremented if the Time Piece Misctimepiece.png was already collected.
setskincolor <body> <red> <green> <blue> No.png Sets the color of a specified part of the body with an 0 - 255 RGB color format, similar to Color Palettes Dyeribbit.png.

Valid bodies: Hat, HatBand, HatAlt, Hair, Cape, Orange, Zipper, Dress, Pants, Shoes and ShoesBottom.
openskineditor No.png Opens the skin editor that is used to make Color Palettes Dyeribbit.png, you can export and import data to test it out, this is similar to setskincolor but user friendly.
setact <number> No.png Sets the current act number.
cammode No.png Sets your camera to be a free roam camera with no bounds. During this state you cannot move the player model because your physics are set to None. Call it again to go back to your default camera.
cammodespeed <number> No.png Default is 1. Multiplies the free roam camera speed from cammode command.
tposeme Yes.png Sets the player animation tree to None, causing a T-Pose.
givekey Yes.png Adds a key to the player's inventory.
dotaunt Yes.png Plays the tongue sticking out 😝 animation.
istaunting No.png Checks if a taunting animation is playing.
itemtaunt No.png Plays the "item obtained" animation, type stoptaunt to stop the softlock.
stoptaunt No.png Stops the "item obtained" animation or any taunt from currently playing.
resetinventory No.png Dangerous. Strips all your inventory, including hats, badges, weapons. Type restartlevel to avoid saving this new inventory state!
adddefaultinventory No.png Dangerous. Replace your inventory with a new (empty) inventory. Type restartlevel to avoid saving this new inventory state!
savegame No.png Saves the current save file, this type of saving is similar to when the player dies or collects a Time Piece Misctimepiece.png.
resetcheckpoint No.png Set checkpoint to 0, subsequent restart (ergo restartlevel) will start from the beginning, if you don't reset, this might break some interactions related to checkpoints..
unlockumbrella Yes.png Gives you the Umbrella.
givecosmetic <cosmetic_name> [equip=true] Yes.png Gives you an existing Hat_CosmeticItem and immediately equip it. Set [equip] to false to not equip it.
giveskin <skin_name> [equip=true] Yes.png Gives you an existing Hat_Collectible_Skin and immediately equip it. Set [equip] to false to not equip it.
startmusic No.png Starts playing music.
stopmusic No.png Stops playing music.
showmusic No.png Opens Hat_HUDElementDebugMusic which shows the currently playing music.
criticalhealth Yes.png Sets player health to 1.
destroycpuactors Yes.png Destroy an assortment of enemies, particles, NPCs, doors, dynamic meshes.
destroycontrolleractors Yes.png Destroy all Pawns.
printbase Yes.png Prints the name of the ground the player is standing on top.
gctest No.png Forces garbage collection to happen now. (Might help with performance problems).
haslevelintro No.png Prints false/true if a level intro is currently playing.
printloadout No.png Prints all currently owned items. Inconsistent because printing is limited.
clearplayerloadouts No.png Dangerous. Strips all players from their loadouts. Type restartlevel to avoid saving this new inventory state!
printinventory No.png Prints your inventory items. Inconsistent because printing is limited.
addlevelbit <id> <value> Yes.png Adds a level bit. This bit persists regardless of level.
removelevelbit <id> <value> Yes.png Removes a level bit.
addactbit <id> <value> Yes.png Adds an act bit. This bit persists until the act number changes.
removeactbit <id> <value> Yes.png Removes an act bit.
hasrainmanager No.png Checks if its raining.
printdetailmode No.png Prints the current detail mode of the world.
printmapname No.png Prints the file name of the map.
printstate No.png Prints the current player physics.
stateinfo No.png Prints a bunch of player current states.
openhud <hud_name> [command=""] No.png Opens a Hat_HUDElement with an optional [command]. [command] can cause changes in the HUD behaving depending on what is written inside the file. Example: openhud Hat_HUDElementButtonHelp doublejump. This command is constrained to only HatinTimeGameContent package and cannot be used to open Modded HUDs.
fullyrestartlevel No.png restartlevel but also sets the checkpoint to 0.
camerayoffset <number> No.png Offsets the camera on the y-axis.
camerazoffset <number> No.png Offsets the camera on the z-axis.
cleanbackpack No.png Removes level related collectibles from the backpack.
freezeframe [delay=0] No.png Causes the game to freeze after a short [delay=0], this doesn't mean it is malfunctioning, this is exactly the same state when pausing the game. To unfreeze, press the pause key.
teleport No.png Teleport to exactly where the camera is looking. Limited to 10,000 meters.
changesize <number> No.png Changes the size of the player. Default size is 1.
slomo <number> No.png Changes the world's speed with the passed value. Default time is 1. Note: Changable from other sources such as Time Stop Hattimestop.png and the Hat Menu Wheel.
setjumpz <number> No.png Changes the jump height. Default is 540.
setgravity <number> No.png Sets the world gravity, gravity is a negative modifier so inputting positive will cause you to flow up forever. Default is -750.
setspeed <number> No.png Multiplies the player's default movement speed, only affects water movement. Default is 1.
killall <class_name> No.png Destroys every Actor related to <class_name>.
killallpawns <class_name> No.png Similar to killall but kills all Pawn related classes and their controllers. (Like enemies and their AI)
killpawns No.png Exactly as calling killallpawns Pawn.
avatar <class_name> No.png Posses a Pawn and giving you full control of the specified <class_name>, you can recast this to cycle through another Pawn that is equal to <class_name>, to go back to your original body type avatar Hat_Player to cycle repeatedly until you return back to your own body.
summon <path> No.png Spawn an instance of the specified Actor class that is contained inside a Content Package, the <path> must be <content_package_name>.<class_name>.

A Hat in Time's package is called HatinTimeGameContent, for Mods however, their packages are named based on their CookedPC file's name (which is based on the mod's folder) holding the mod locally (example: ExampleMod), this is also true for mods downloaded from the Steam Workshop despite their folder being replaced with the mod's workshop ID.

To keep it simple, summon HatinTimeGameContent.<class_name> where <class_name> can be any Actor such as Hat_Collectible_EnergyBit Miscpon.png, Hat_TimeObject Misctimepiece.png or an enemy Hat_Enemy_Mobster.

Further Reading