Don’t Starve Together Commands
To start the command console, the default keybinding is ` or ~. Commands use the Lua programming languages. This is just a simple list of common commands I use. Pressing the Ctrl key will switch between Remote and Local command mode. Typically you would want to be in Remote mode. When pasting commands using Ctrl-V, you may inadvertently switch modes.
Targetting Yourself
-- Use this
ThePlayer
-- This is deprecated
GetPlayer()
List all players
for i, v in ipairs(AllPlayers) do TheNet:SystemMessage(tostring(i) .. ": " .. v.name, false) end
Execute command on all players
for k,v in pairs(AllPlayers) do INSERTCOMMANDHERE end
Resurrect everybody
for k,v in pairs(AllPlayers) do AllPlayers[k]:PushEvent('respawnfromghost') end
Heal all players on server.
for k,v in pairs(AllPlayers) do AllPlayers[k].components.health:SetPercent(1) end
Give an item to player by name
for k,v in pairs(AllPlayers) do if v.name == "playernamehere" then v.components.inventory:GiveItem(DebugSpawn("honey")) end end
Examples to get properties/methods from ThePlayer object
for key,value in pairs(ThePlayer) do print("ThePlayer " .. key, value) end
for key,value in pairs(getmetatable(ThePlayer)) do print("getmetatable(ThePlayer) " .. key, value) end
for key,value in pairs(ThePlayer.components) do print("ThePlayer.components - " .. key, value) end
for key,value in pairs(ThePlayer.components.health) do print("ThePlayer.components.health - " .. key, value) end
for key,value in pairs(getmetatable(ThePlayer.components.health)) do print("getmetatable(ThePlayer.components.health) - " .. key,value) end
The values will be printed to console as well as %UserProfile%\Documents\Klei\DoNotStarveTogether\client_log.txt
by default.
Remove a nearby object
c_find('pond'):Remove()
Domesticate a nearby beefalo
c_find("beefalo").components.domesticatable.domestication=1; c_find("beefalo").components.domesticatable:BecomeDomesticated();
Change the tendancy of a nearby beefalo
Possible values are “DEFAULT”, “ORNERY”, “RIDER”, “PUDGY”
c_find("beefalo").components.hunger:DoDelta(400); c_find("beefalo").components.domesticatable:DeltaTendency("RIDER",100); c_find("beefalo"):SetTendency()
Game Files
The scripts.zip
has lua files that can be examined to understand the data structure and methods better: C:\Program Files (x86)\Steam\steamapps\common\Don't Starve Together\data\databundles\scripts.zip
References
https://dontstarve.fandom.com/wiki/Console/Don%27t_Starve_Together_Commands