Jump to content

Recommended Posts

Hello, I have a question  R9mG9xk.gif  ... So, I was wondering is it possible to allow a character to be able to dig things up without the need of a shovel? Like when my character goes insane they can dig places up & instead of playing the shovel anim he plays the harvest resource anim, would that be possible or can only tools use dig, mine, chop & hammer actions? If I remember the Werebeaver can dig up places without the need of a tool, my character even gains the beaver tag when she goes insane but can't do those actions.

I tried adding "inst:AddInherentAction(ACTIONS.DIG)" from the shovel.lua to my character but nothing happened! Can someone smart tell me if this would be possible, sorry for being such a noob :(.......... Thank you for reading, have a wonderful day/night  R9mG9xk.gif  !!!!!!

PS. I added all the code below & still didn't give him the ability to dig, it didn't crash the game either :confused:... I'll wait for someone smart to answer me R9mG9xk.gif  ...

inst:AddComponent("worker")
            inst.components.worker:SetAction(ACTIONS.CHOP, 4)
            inst.components.worker:SetAction(ACTIONS.MINE, .334)
            inst.components.worker:SetAction(ACTIONS.DIG, .334)
            inst.components.worker:SetAction(ACTIONS.HAMMER, .25)

            inst:AddComponent("tool") -- :lol: made my character to a tool
            inst.components.tool:SetAction(ACTIONS.DIG)

Edited by SuperDavid
1 hour ago, Soto8969 said:

I know nothing about mods, but why you have a Lenny on the tags? :D

I felt since many of my questions (that get answered) might be useful for beginner modders that are making their own mod characters so I put lenny on the tag if they want to find any of my questions they can easily find it because there's lots of useful code in my questions( of course all the code is credit is to the genius that made it not me xD )if they want they can copy paste it xD because I know when I was beginning on my mod I would've really loved if all the code I need for my character was already existed xD! If it's not okay please tell me then I remove it right away :D!!!!

PS. I'm going to change it to something that makes more sense than ( ͡° ͜ʖ ͡°)... lol xD

Edited by SuperDavid
local ActionHandler = GLOBAL.ActionHandler
local ACTIONS = GLOBAL.ACTIONS

local MYDIGACTION = AddAction("HARVESTDIG", "Dig", ACTIONS.DIG.fn)

local harvestdighandler = ActionHandler(MYDIGACTION, "dolongaction")
AddStategraphActionHandler("wilson", harvestdighandler)
AddStategraphActionHandler("wilson_client", harvestdighandler)

AddComponentPostInit("playeractionpicker", function(self)
	if self.inst:HasTag("mosslingwhisperer") then
		local LEAPACTION = ACTIONS.LEAP
		local DIGID = ACTIONS.DIG.id
		local _GetRightClickActions = self.GetRightClickActions
		self.GetRightClickActions = function(self, position, target)
			local actions = _GetRightClickActions(self, position, target)
			local iscrazyandalive = not self.inst.replica.sanity:IsSane() and not self.inst:HasTag("playerghost")
			if iscrazyandalive then
				if #actions == 0 and position then
					local ishungry = self.inst.replica.hunger:GetCurrent() < 10
					local ispassable = self.map:IsPassableAtPoint(position:Get())
					if ispassable and not ishungry then
						actions = self:SortActionList({LEAPACTION}, position)
					end
				elseif target and target:HasTag(DIGID.."_workable") then
					actions = self:SortActionList({MYDIGACTION}, target)
				end
			end
			return actions
		end
	end
end)

I combined it with the leap action code.

You can use

inst:AddComponent("worker")
inst.components.worker:SetAction(ACTIONS.DIG, 0.334)

in your character to adjust the effectiveness of a single dig action.

By default, the effectiveness is 1.

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