Jump to content

How to add certain traits for your character?


Recommended Posts

Hi! I don't know if this is a bit of a dumb question, but I'm creating a character mod and I got the art down and all the quotes too. The thing I need to do now is give my character his assigned traits. I want him to be able to read wickerbottoms books, be able to eat raw meat with no sanity loss and 3 points of hunger, as well as eat any sweet foods (cookies, ice cream, taffy, etc) with a bit of a bigger bonus, but the thing is i don't know how to make that happen...i just see all the things for the art and the speech files and what not. Help would be appreciated bc im dumb. 

Edited by takoyamaa
Link to comment
Share on other sites

Look at wickerbottom.lua and look also at waxwell.lua.

Both character are able to read books so you could try to guess what you need to be able to make your character able to read book. Note : being able to read book and to craft them are two different things.

Link to comment
Share on other sites

For reading Wickerbottom books put this inside YOURCHARACTER.lua inside the master_postinit

Spoiler

inst:AddComponent("reader")

 

To be able to eat raw meat with no Sanity penalty & bonus 3 points of hunger put this inside YOURCHARACTER.lua inside the master_postinit

Spoiler

inst.components.eater.Eat_orig = inst.components.eater.Eat
function inst.components.eater:Eat(food)
	if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.MEAT and self:CanEat(food) then
		if food.components.edible.sanityvalue < 0 then
			food.components.edible.sanityvalue = 0
			inst.components.hunger:DoDelta(3)
		end
	end
	return inst.components.eater:Eat_orig(food)
end

 

To get more bonus from eating sweet foods you should put this inside YOURCHARACTER.lua inside the master_postinit

Spoiler

inst.components.eater:SetOnEatFn(Eat_Sweets)

 

this is also for the sweet bonus put this inside YOURCHARACTER.lua outside the master_postinit

Spoiler

local function Eat_Sweets(inst, food)	
	local sweets = --add whatever food you want boost from, it needs to be its name which you can spawn it in with console commands
	{
	jellybean = true,
	butterflymuffin = true,
	icecream = true,
	taffy = true,
	waffles = true,
	pumpkincookie = true,
	}
	
	if sweets[food.prefab] then
		inst.components.health:DoDelta(5) --replace 5 with whatever boost you would want
		inst.components.hunger:DoDelta(5)
		inst.components.sanity:DoDelta(5)
		inst.components.talker:Say("I love sweets~!")
	end
end

 

 

I think that should all work :wilson_laugh:!

Edited by SuperDavid
Link to comment
Share on other sites

5 hours ago, SuperDavid said:

For reading Wickerbottom books put this inside YOURCHARACTER.lua inside the master_postinit

  Hide contents


inst:AddComponent("reader")

 

To be able to eat raw meat with no Sanity penalty & bonus 3 points of hunger put this inside YOURCHARACTER.lua inside the master_postinit

  Hide contents


inst.components.eater.Eat_orig = inst.components.eater.Eat
function inst.components.eater:Eat(food)
	if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.MEAT and self:CanEat(food) then
		if food.components.edible.sanityvalue < 0 then
			food.components.edible.sanityvalue = 0
			inst.components.hunger:DoDelta(3)
		end
	end
	return inst.components.eater:Eat_orig(food)
end

 

To get more bonus from eating sweet foods you should put this inside YOURCHARACTER.lua inside the master_postinit

  Hide contents


inst.components.eater:SetOnEatFn(Eat_Sweets)

 

this is also for the sweet bonus put this inside YOURCHARACTER.lua outside the master_postinit

  Hide contents


local function Eat_Sweets(inst, food)	
	local sweets = --add whatever food you want boost from, it needs to be its name which you can spawn it in with console commands
	{
	jellybean = true,
	butterflymuffin = true,
	icecream = true,
	taffy = true,
	waffles = true,
	pumpkincookie = true,
	}
	
	if sweets[food.prefab] then
		inst.components.health:DoDelta(5) --replace 5 with whatever boost you would want
		inst.components.hunger:DoDelta(5)
		inst.components.sanity:DoDelta(5)
		inst.components.talker:Say("I love sweets~!")
	end
end

 

 

I think that should all work :wilson_laugh:!

Ok everything seems fine but i keep getting this error message and idk why : ( i tried checking it a couple of times help!!

sad face emoji.png

Link to comment
Share on other sites

Did you put 

local function Eat_Sweets(inst, food)	
	local sweets = --add whatever food you want boost from, it needs to be its name which you can spawn it in with console commands
	{
	jellybean = true,
	butterflymuffin = true,
	icecream = true,
	taffy = true,
	waffles = true,
	pumpkincookie = true,
	}
	
	if sweets[food.prefab] then
		inst.components.health:DoDelta(5) --replace 5 with whatever boost you would want
		inst.components.hunger:DoDelta(5)
		inst.components.sanity:DoDelta(5)
		inst.components.talker:Say("I love sweets~!")
	end
end

ABOVE your master_postinit ?

Link to comment
Share on other sites

On 9/26/2017 at 8:05 PM, SuperDavid said:

Did you put 


local function Eat_Sweets(inst, food)	
	local sweets = --add whatever food you want boost from, it needs to be its name which you can spawn it in with console commands
	{
	jellybean = true,
	butterflymuffin = true,
	icecream = true,
	taffy = true,
	waffles = true,
	pumpkincookie = true,
	}
	
	if sweets[food.prefab] then
		inst.components.health:DoDelta(5) --replace 5 with whatever boost you would want
		inst.components.hunger:DoDelta(5)
		inst.components.sanity:DoDelta(5)
		inst.components.talker:Say("I love sweets~!")
	end
end

ABOVE your master_postinit ?

ok everything works now without much error! Also this post was gonna ask u how to craft the books but i just figured it out! thanks for your help!

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