Jump to content

Recommended Posts

Hi everyone, I need help with error in my character mod based on extended sample character template. So my character works almost flawless, but there is one defect - character's stats didn't change at all: movement speed, attack multiplier, health, sanity, hunger. I don't know how to fix it. Please don't let me go insane, I am losing my mind.

EDIT:

I figured out that the bug is in this sector

local master_postinit = function(inst)

everything out of this grup works fine

swin.lua

Edited by Yakuzashi
+ info
Link to comment
Share on other sites

You need to add return inst to the very bottom of your master_postinit function.

local master_postinit = function(inst)
	-- choose which sounds this character will play
	inst.soundsname = "willow"
	
	-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
	
	-- Stats	
	inst.components.health:SetMaxHealth(100)
	inst.components.hunger:SetMax(150)
	inst.components.sanity:SetMax(300)
	
	-- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1.15
	
	-- Rain resistance [speed of getting wet] (0 = rainproof, 0.75 = normal value_)
	inst.components.moisture.maxMoistureRate = 0.375 -- 50% slower rain weting rate 
	
	-- Hunger rate (optional)
	inst.components.hunger.hungerrate = 1.1 * TUNING.WILSON_HUNGER_RATE
	
	-- Cold resistance (10 Degrees per 50 seconds, [without this line -> 10 degrees per 20 seconds] 
    inst.components.temperature.inherentinsulation = TUNING.INSULATION_MED
	
	--Ambush by Cherry (Steam) [Thank you very much- great modder]
	inst:DoPeriodicTask(0.1, function()
		local CAN_ATTACK =
		{
			CHOP = false,
			DIG = false,
			HAMMER = false,
			MINE = false,
			ATTACK = true,
		}

		local ATTACK_TAGS = {"_combat"}

		for k, v in pairs(CAN_ATTACK) do
			table.insert(ATTACK_TAGS, k.."_workable")
		end

		local NON_ATTACK_TAGS = {"INLIMBO", "playerghost"}

		local x, y, z = inst.Transform:GetWorldPosition()
		local ents = TheSim:FindEntities(x, y, z, 2.5, nil, NON_ATTACK_TAGS, ATTACK_TAGS)
		
		for i, v in ipairs(ents) do
			if not v:HasTag("player") and not v:HasTag("shadow") and not v:HasTag("shadowminion") and not v:HasTag("shadowchesspiece") and v.components.health and not v.components.health:IsDead() and inst.components.health and not inst.components.health:IsDead() then -- No hiding from nightmare creatures, mwuhahaha!
				inst:RemoveTag("notarget")
				inst:AddTag("scarytoprey")
			else
				inst:AddTag("notarget")
				inst:RemoveTag("scarytoprey")
			end
		end 
	end)
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload
	
	return inst
end

 

Link to comment
Share on other sites

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
	-- choose which sounds this character will play
	inst.soundsname = "wendy"
	
	-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
	
	-- Stats	
	inst.components.health:SetMaxHealth(100)
	inst.components.hunger:SetMax(150)
	inst.components.sanity:SetMax(300)
	
	-- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1.15
	
	-- Rain resistance [speed of getting wet] (0 = rainproof, 0.75 = normal value_)
	inst.components.moisture.maxMoistureRate = 0.375 -- 50% slower rain weting rate 
	
	-- Hunger rate (optional)
	inst.components.hunger.hungerrate = 1.1 * TUNING.WILSON_HUNGER_RATE
	
	-- Cold resistance (10 Degrees per 50 seconds, [without this line -> 10 degrees per 20 seconds] 
    inst.components.temperature.inherentinsulation = TUNING.INSULATION_MED
	
	--Ambush by Cherry (Steam) [Thank you very much- great modder]
	inst:DoPeriodicTask(0.1, function()
		local CAN_ATTACK =
		{
			CHOP = false,
			DIG = false,
			HAMMER = false,
			MINE = false,
			ATTACK = true,
		}

		local ATTACK_TAGS = {"_combat"}

		for k, v in pairs(CAN_ATTACK) do
			table.insert(ATTACK_TAGS, k.."_workable")
		end

		local NON_ATTACK_TAGS = {"INLIMBO", "playerghost"}

		local x, y, z = inst.Transform:GetWorldPosition()
		local ents = TheSim:FindEntities(x, y, z, 2.5, nil, NON_ATTACK_TAGS, ATTACK_TAGS)
		
		for i, v in ipairs(ents) do
			if not v:HasTag("player") and not v:HasTag("shadow") and not v:HasTag("shadowminion") and not v:HasTag("shadowchesspiece") and v.components.health and not v.components.health:IsDead() and inst.components.health and not inst.components.health:IsDead() then -- No hiding from nightmare creatures, mwuhahaha!
				inst:RemoveTag("notarget")
				inst:AddTag("scarytoprey")
			else
				inst:AddTag("notarget")
				inst:RemoveTag("scarytoprey")
			end
		end 
	end)
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload
	
	return inst
end

    --Recipes knowledge ( inst.components.builder.science_bonus = 1 -> science machine [2-> alchemy enginge] ) 
local function master_postinit(inst)
    inst.components.builder.science_bonus = 1
end

Here's the problem, you have 2 master_postinit functions when you should only have 1. Just update it to this.

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
	-- choose which sounds this character will play
	inst.soundsname = "wendy"
	
	-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
	
	-- Stats	
	inst.components.health:SetMaxHealth(100)
	inst.components.hunger:SetMax(150)
	inst.components.sanity:SetMax(300)
	
	-- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1.15
	
	-- Rain resistance [speed of getting wet] (0 = rainproof, 0.75 = normal value_)
	inst.components.moisture.maxMoistureRate = 0.375 -- 50% slower rain weting rate 
	
	-- Hunger rate (optional)
	inst.components.hunger.hungerrate = 1.1 * TUNING.WILSON_HUNGER_RATE
	
	-- Cold resistance (10 Degrees per 50 seconds, [without this line -> 10 degrees per 20 seconds] 
    inst.components.temperature.inherentinsulation = TUNING.INSULATION_MED
	
	--Ambush by Cherry (Steam) [Thank you very much- great modder]
	inst:DoPeriodicTask(0.1, function()
		local CAN_ATTACK =
		{
			CHOP = false,
			DIG = false,
			HAMMER = false,
			MINE = false,
			ATTACK = true,
		}

		local ATTACK_TAGS = {"_combat"}

		for k, v in pairs(CAN_ATTACK) do
			table.insert(ATTACK_TAGS, k.."_workable")
		end

		local NON_ATTACK_TAGS = {"INLIMBO", "playerghost"}

		local x, y, z = inst.Transform:GetWorldPosition()
		local ents = TheSim:FindEntities(x, y, z, 2.5, nil, NON_ATTACK_TAGS, ATTACK_TAGS)
		
		for i, v in ipairs(ents) do
			if not v:HasTag("player") and not v:HasTag("shadow") and not v:HasTag("shadowminion") and not v:HasTag("shadowchesspiece") and v.components.health and not v.components.health:IsDead() and inst.components.health and not inst.components.health:IsDead() then -- No hiding from nightmare creatures, mwuhahaha!
				inst:RemoveTag("notarget")
				inst:AddTag("scarytoprey")
			else
				inst:AddTag("notarget")
				inst:RemoveTag("scarytoprey")
			end
		end 
	end)

	--Recipes knowledge ( inst.components.builder.science_bonus = 1 -> science machine [2-> alchemy enginge] ) 
	inst.components.builder.science_bonus = 1
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload
	
	return inst
end
    

That should fix the issue.

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