Jump to content

How add custom action Don't starve together?


Recommended Posts

I ask for help! I'm trying to add a new action for one object.

First I say that this is not an example! This method does not work and I ask for help from you!

First I created a new component "drop_please.lua" in \scripts\components

local Drop_Please = Class(function(self, inst)
    self.inst = inst
end)

function Drop_Please:Drop_All(askdrop)		
	if askdrop:HasTag('player') and self.inst.prefab == ("abigail_human") then
	    self.inst.components.inventory:DropEverything()
	end
end

return Drop_Please

Then I added this to the modmain

AddAction("DROP_ALL", "Command drop all.", function(act)
	if act.target.prefab == ("abigail_human") then
		act.target.components.drop_please:Drop_All(act.doer)
		return true
	else
		return false
	end
end)


AddComponentAction("SCENE", "drop_please", function(inst, doer, actions, right)
	if right then
		if inst.prefab and inst.prefab == ("abigail_human") then
			table.insert(actions, GLOBAL.ACTIONS.DROP_ALL)
		end
	end
end)

AddStategraphActionHandler("wilson", GLOBAL.ActionHandler(GLOBAL.ACTIONS.DROP_ALL, "drop_all"))
AddStategraphActionHandler("wilson_client", GLOBAL.ActionHandler(GLOBAL.ACTIONS.DROP_ALL, "drop_all"))

As a result, the action appears. But it does not work with a mouse click. What am I doing wrong? What is missing?

 

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...