Jump to content

How to add custom console command ?


Recommended Posts

So, i encounter some problem.

 

The file didn't existed on this folder, i created it.

Then i created my command.

 

But when i'm trying to use it on game nothing happens.

There is nothing in the log about something wrong with the custom command.

Here is the content of my file :


function c_gofast(player)
    player = ListingOrConsolePlayer(player)
    if player ~= nil then
        c_select(player)
        c_give("cane", nil, true)
        c_give("yellowamulet", nil, true)
    end
end

(I used the "c_goadventuring()" command as a template).

The console command itself is enabled. Do i have to enable the custom command too ? Should i add something in my custom command lua file ? What is missing ?

Thanks for help.

Link to comment
Share on other sites

Another way you can do this is by making a mod (If you want to make a mod for it)

If not, then their way is perfectly sustainable.

If you are making a mod for it you can do this.

local d = function(text)
  if not type(text) == "string" then return end
  print(string.lower(tostring(text))) -- A word of warning, I come from a simplified lua, so I amm not sure if this would work.
end

GLOBAL.d = d -- Creates the console command "d"

For example, if my simplified version of LUA works, then it should lower the string.

Edited by Backtalker
Link to comment
Share on other sites

@Lumina looks like customcommands.lua doesn't work anymore, it's not working for me aswell. Im sure Your function will work if You paste it there:

...\Steam\steamapps\common\Don't Starve Together\data\scripts\consolecommands.lua

Be aware that file can be overwritten by updates. Here are custom commands that i use for testing ingame:

function c_speed()
	c_give("cane")
    c_give("yellowamulet")
    c_give("minerhat")
    c_give("walrushat")
end
function c_fight()
	c_give("armorwood")
    c_give("hambat")
    c_give("wathgrithrhat")
end
function c_stats()
	ThePlayer.components.sanity:SetPercent(1)
	ThePlayer.components.health:SetPercent(1)
	ThePlayer.components.hunger:SetPercent(1)
end
function c_stats2()
	AllPlayers[2].components.sanity:SetPercent(1)
	AllPlayers[2].components.health:SetPercent(1)
	AllPlayers[2].components.hunger:SetPercent(1)
end
function c_creative()
	c_listallplayers()
	c_supergodmode()
	ThePlayer.components.builder:GiveAllRecipes()
end
function c_creative2()
	c_supergodmode(AllPlayers[2])
	AllPlayers[2].components.builder:GiveAllRecipes()
end

Hope i helped a little :wilson_wink:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...