Jump to content

Recommended Posts

Ok so, I am trying to help my brother make a character mod. One of the things that is supposed to make the character special is that they can smash rocks with their bare hands. We have done a LOT of looking, and a lot of digging through the code, and we are pretty stumped. The woodie character seems to have the code we need but for the life of me I can't get it to work. I've dug through the pig creature that can chip trees, and I've looked at the gollum mod (which cheats and makes ponds pickable instead of giving gollum the ability to fish). I've combed the forums and the net for similar requests.

The closest I've gotten is this:

https://forums.kleientertainment.com/forums/topic/69670-solved-how-to-make-character-be-able-to-dig-without-need-of-tool/ 

But I can't get this to run either.

 

I desperately want someone to just explain to me what the process is for getting this to work. How do I use addaction? What pieces are nessisary to trigger all this? I am not a bad programmer by any stretch, but I feel like there are so many little pieces working together here and I can't figure out what they are to even start debugging

Anyone, please? I've run out of things to try and examples to tear appart. I do not understand why the code I found won't run, I don't get any errors, I know I am missing some part of the process but because I don't know what that process is I can't make it work. X.X

So, I used this code from the thread you showed earlier and it worked. Here's the code I used:

local ActionHandler = GLOBAL.ActionHandler
local ACTIONS = GLOBAL.ACTIONS

local MYMINEACTION = AddAction("HARVESTMINE", "Mine", ACTIONS.MINE.fn)

local harvestminehandler = ActionHandler(MYMINEACTION, "dolongaction")
AddStategraphActionHandler("wilson", harvestminehandler)
AddStategraphActionHandler("wilson_client", harvestminehandler)

AddComponentPostInit("playeractionpicker", function(self)
	if self.inst:HasTag("hardhand") then -- This is the tag that the player needs to be able to mine with hands
		local LEAPACTION = ACTIONS.LEAP
		local MINEID = ACTIONS.MINE.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(MINEID.."_workable") then
					actions = self:SortActionList({MYMINEACTION}, target)
				end
			end
			return actions
		end
	end
end)

 

And I added the "hardhand" tag to Wilson for testing.

  • Like 1
  • Thanks 1

Thank you! I am the brother in question. When I added this code to my character mod (at the bottom of my modmain) and added the tag "hardhand" to my common_postinit, I was able to select my character, but then the game stopped loading in. I never even got to spawn. Did I place it in the wrong place?

Thank you so much for answering. I've been tearing my hair out trying to figure this stuff out. But I have a few questions.

 

The original code includes stuff to allow the character to jump, and I'm not sure which pieces I need to remove and which pieces are nessisary to mine.

Also, why right click? Isn't mining usually a left click thing? Or am I missremembering.

 

As my brother states, the code seems to crash when we try to use it. But at least it's doing something different so that's a start. X.X. is this supposed to go into the character prefab or the modmain? I feel like I am missing something stupid...

 

I'm an idiot. I used the wrong punctuation for the inst:AddTag, it works now. But, is there a way to change the animation so that it will auto harvest, either by holding space or the mouse button? or to make it so boulders break easier for him?

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