Jump to content

Recommended Posts

Hello there, friendly folks of the mod forums. I'm making a custom character and despite my best efforts I can't seem to understand what's going wrong with this custom character I'm working on! A character for the original Don't Starve has this functionality, specifically Writhe, a wonderful character by Mr. Tiddles, and in particular the code in here I was looking at is

local function drop(inst)local hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)	if hand thenif not hand:HasTag("nikmikwrithe") theninst:DoTaskInTime(0.1, function()local item = inst.components.inventory:Unequip(EQUIPSLOTS.HANDS)inst.components.inventory:GiveItem(item)    inst.AnimState:OverrideSymbol("swap_object", "nil", "nil")		end)		end	endend

when I plug everything into my character, it runs, but the effect of not being able to equip anything without the specified tag does not work! What seems to be the issue here? I've toyed with it for a bit over a day now, with no results. :fatigue:

Edited by Noggle

@Noggle, The game seems to be using this right now for the unequip action:

ACTIONS.UNEQUIP.fn = function(act)    if act.doer.components.inventory and act.invobject and act.invobject.components.inventoryitem.cangoincontainer then		act.doer.components.inventory:GiveItem(act.invobject)    	--return act.doer.components.inventory:Unequip(act.invobject)    	return true    elseif act.doer.components.inventory and act.invobject and not act.invobject.components.inventoryitem.cangoincontainer then        act.doer.components.inventory:DropItem(act.invobject, true, true)        return true    endend

So maybe try removing the Unequip(EQUIPSLOTS.HANDS) line and changing "item" on the next line to "hand"?

 

@rezecib

So maybe try removing the Unequip(EQUIPSLOTS.HANDS) line and changing "item" on the next line to "hand"?

 

I have tried this, and haven't seen any difference. I'm also the guy who asked in the other thread, but I haven't been able to get either of these to work for me. I must be missing something here. Would posting my full .lua shine some light on my problem? This is the only thing that is currently not working, but I'm not too knowledgeable on these things.

 

 

edit: Dear god I'm so bad at this I even broke the quote function.

Edited by Noggle

I might not be completely understanding something but I do not see you calling the function anywhere in your code. You could add an event listener that triggers when something is equipped and the function fires.

inst:ListenForEvent("equip", drop)

Place that in the same area where you initialize your characters stats. This will create a listener that will fire your drop function whenever your character tries to equip something. I am sure there are probably better ways of doing it and someone with more knowledge will shine light on it.

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