Jump to content

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!

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
×
  • Create New...