Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

Lumina

How to add custom console command ?

Recommended Posts

Lumina    2,136

Hi,

I'm testing a mod and it would be more convenient to have shortcut for some commands i'm using often, like when i want to give myself some items. How can i add my own commands to the game ?

Thanks.

Share this post


Link to post
Share on other sites
Lumina    2,136

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.

Share this post


Link to post
Share on other sites
Backtalker    3

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.

Share this post


Link to post
Share on other sites
Weexer    6

@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:

Share this post


Link to post
Share on other sites
CarlZalph    3,394

Customcommands.lua still works.

If you're trying to use it on the server, then put it in the server's directory and not your client's.

Else you'll need to use TheNet:SendRemoteExecute on the client.

Share this post


Link to post
Share on other sites