Jump to content

[HELP] Implementing a custom Action


Recommended Posts

I'm having a little trouble with getting my Action to work properly!

I think I have an understanding of how they work, but this just doesn't seem to work.

 

I'm trying to make an action similar to ADDFUEL, but instead of fueled, able to be repairable.
(I know there's already a repairable component, but that seems to only be for health related things)

 

I've created a component called repairitem and have implemented CollectUseActions in the component.

I'm adding the component repairitem to the Nightmare Armor prefab, armor_sanity, and I've tested that and it works fine, it's correctly applied to that item and that component is loaded fine.

function repairitem:CollectUseActions(doer, target, actions, right)	if target.components.repairitem then		table.insert(actions, ACTIONS.REPAIRITEM)	endend 

Here's my AddAction bit, I looked at fueled.lua for inspiration

local Action = GLOBAL.Actionlocal ActionHandler = GLOBAL.ActionHandlerlocal repairitem = Action()repairitem.str = "Repair Item"repairitem.id = "REPAIRITEM"repairitem.fn = function(act)	if act.doer.components.inventory then		local resource = act.doer.components.inventory:RemoveItem(act.invobject)		if resource then			if act.target.components.repairitem:DoRepair(resource, act.target, act.doer) then				return true			else				print("False")				act.doer.components.inventory:GiveItem(resource)			end		end	endendAddAction(repairitem)AddStategraphActionHandler("wilson", ActionHandler(repairitem, "dolongaction"))

There isn't any crashing, but it just doesn't seem to work, could anyone give me insight on how this all works? I believe I've covered all the correct steps, but might be missing one bit?

I've looked at a similar mod for repairing but it's based around an item repairing another item using resource/fuel in the inventory rather than applying the fuel right onto the target.

Thanks in advance!

Link to comment
Share on other sites

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.

×
  • Create New...