Jump to content

[SOLVED]how to make a character able to use pitchfork when unable to use weapon


Recommended Posts

hi, my character is unable to use any weapon(except my custom weapon) and it still can use tools but pitchfork does not have tool tag in its lua. It only has weapon and sharp tags. Is there anyway to add pitchfork, pitchfork tag or use it without pitchfork tag. here is my code for weapons and tools

	if equippedweb ~= nil and not equippedweb:HasTag("kitsuraitem") then
		if equippedweb ~= nil and not equippedweb:HasTag("tool") or equippedweb:HasTag("pitchfork") or equippedweb:HasTag("farm_hoe") or equippedweb:HasTag("golden_farm_hoe")  then
			inst.components.inventory:DropItem(equippedweb)
		end
	end

neither farm_hoe or pitchfork is able to use for my character. (also i couldn't find farm hoe's lua idk how they named it)

Edited by AkaiNight
Link to comment
Share on other sites

You could either add a PrefabPostInit to the pitchfork and give it the tag you want or you use inherentactions.

I used this in my mod to detect if a handheld item is a tool, change it what you need:

local function inherentaction(inst)
	if inst.inherentactions ~= nil then
		if inst.inherentactions[ACTIONS.TILL] ~= nil or inst.inherentactions[ACTIONS.TERRAFORM] ~= nil or inst.inherentactions[ACTIONS.DIG] ~= nil then
			return true
		end
	end
	return false
end

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

@monti18 thanks im leaving the code if anyone else needs it 

AddPrefabPostInit('pitchfork', function(inst)
    if inst.components and inst.components.weapon then
        inst:AddTag("tool")
    end
end)

in modmain.lua

 

quick question: If i change something with "AddPrefabPostInit" is it changes just for the character or everyone?

Edited by AkaiNight
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...