Jump to content

Can I make my character eat rocks?


Recommended Posts

I mean, is there a script so he can eat rocks? I tried to discover this on my own but I'm a newby in coding and stuff like that. I found in Woodie_nobeav.lua this: TUNING.SANITY_PER_CONE_WOODIE = 1.25 So can I somehow remake this so he gains "hunger" while eating rocks?

Link to comment
Share on other sites

-- So you can eat all elementals
local eater = inst.components.eater
table.insert(eater.preferseating, FOODTYPE.ELEMENTAL)
table.insert(eater.caneat, FOODTYPE.ELEMENTAL)
eater.inst:AddTag(FOODTYPE.ELEMENTAL.."_eater")

local _TestFood = eater.TestFood
eater.TestFood = function(self, food, testvalues)
	-- So you can only eat rocks, out of all stuff of the elementals group
	if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.ELEMENTAL then
		return food.prefab == "rocks"
	end
	return _TestFood(self, food, testvalues)
end

-- So you benefit for eating rocks
eater.oneatfn = function(inst, food)
	if food and food.prefab == "rocks" then
		-- rocks give 1 hunger back by default, 1 + 9 = 10
		inst.components.hunger:DoDelta(9)
	end
end

 

Link to comment
Share on other sites

Ok, so I copied that and it shows me this: 
And that's how looks my file

local master_postinit = function(inst)
	inst.soundsname = "willow"
	
	if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.ELEMENTAL then
		return food.prefab == "rocks"
	end
	return _TestFood(self, food, testvalues)
end
	

	
	eater.oneatfn = function(inst, food)
	if food and food.prefab == "rocks" then
		inst.components.hunger:DoDelta(4)
	end
end

	
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
	
	inst.components.health:SetMaxHealth(150)
	inst.components.hunger:SetMax(150)
	inst.components.sanity:SetMax(200)
	
    inst.components.combat.damagemultiplier = 1
	
	inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload
	
end

return MakePlayerCharacter("cygan", prefabs, assets, common_postinit, master_postinit, start_inv)

 

20160703010917_1.jpg

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