Jump to content

trying to make a custom character but server won't start dew to charater


Recommended Posts

my character main lua

-----------------------------------------------------------------------------------

local MakePlayerCharacter = require "prefabs/player_common"

local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
}

-- Your character's stats
--TUNING.RGDOG_HEALTH = 250
--TUNING.RGDOG_HUNGER = 150
--TUNING.RGDOG_SANITY = 200

local function TurnBackToNormal(inst)
    -- Do whatever is needed to be in the normal state.
    -- You at least need to change the animation build, if your character needs to look different.
    inst.components.health:SetMaxHealth = 250
    inst.components.hunger:SetMax = 150
    inst.components.sanity:SetMax = 200
    inst.components.locomotor.walkspeed = 9.5
    inst.components.locomotor.runspeed = 9.5
    inst.components.temperature.mintemp = 20
end

-- Custom starting inventory
TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.RGDOG = {
    "flint",
    "flint",
    "twigs",
    "twigs",
}

local start_inv = {}
for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do
    start_inv[string.lower(k)] = v.RGDOG
end
local prefabs = FlattenTree(start_inv, true)

-- When the character is revived from human
local function onbecamehuman(inst)
    -- Set speed when not a ghost (optional)
    inst.components.locomotor:SetExternalSpeedMultiplier(inst, "rgdog_speed_mod", 1)
end

local function onbecameghost(inst)
    -- Remove speed modifier when becoming a ghost
   inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "rgdog_speed_mod")
end

-- When loading or spawning the character
local function onload(inst)
    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
    inst:ListenForEvent("ms_becameghost", onbecameghost)

    if inst:HasTag("playerghost") then
        onbecameghost(inst)
    else
        onbecamehuman(inst)
    end
end


-- This initializes for both the server and client. Tags can be added here.
local common_postinit = function(inst) 
    -- Minimap icon
    inst.MiniMapEntity:SetIcon( "rgdog.tex" )
end

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
    -- Set starting inventory
    inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default
    
    -- 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(TUNING.RGDOG_HEALTH)
    inst.components.hunger:SetMax(TUNING.RGDOG_HUNGER)
    inst.components.sanity:SetMax(TUNING.RGDOG_SANITY)
    
    -- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1
    
    -- Hunger rate (optional)
    inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
    
    inst.OnLoad = onload
    inst.OnNewSpawn = onload
    
end

--day night sanity
local function sanityfn(inst)

    --time sanity function - this is the one that works.
    if TheWorld.state.isday then delta = delta +1
    elseif TheWorld.state.isdusk then delta = delta +0.15
    elseif TheWorld.state.isnight then delta = delta +0.10
    end
    
    return delta
end

--Loves the rain code
local function onprecipitationchanged(src, preciptype)
        if preciptype == "rain" then
            inst.components.sanity.dapperness = dapperness_onrain
        else
            inst.components.sanity.dapperness = +1
        end
    end
    
    -- Remove raw meat penalty
    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
            end
            if food.components.edible.healthvalue < 0 then
                food.components.edible.healthvalue = 0
            end
        end
        return inst.components.eater:Eat_orig(food)
    end
    
    local function UpdateNightVision(inst, phase)
    local enable = phase == "night"
    inst:DoTaskInTime(enable and 0 or 1, function(inst)
        inst.components.playervision:ForceNightVision(enable)
        inst.components.playervision:SetCustomCCTable(enable and {} or nil)
    end)
end

local function OnInitNightVision(inst)
    if TheWorld.ismastersim or inst.HUD then
        inst:WatchWorldState("phase", UpdateNightVision)
        UpdateNightVision(inst, TheWorld.state.phase)
    end
end

--NightVision
local function UpdateNightVision(inst, phase)
    local enable = phase == "night"
    inst:DoTaskInTime(enable and 0 or 1, function(inst)
        inst.components.playervision:ForceNightVision(enable)
        inst.components.playervision:SetCustomCCTable(enable and {} or nil)
    end)
end

local function OnInitNightVision(inst)
    if TheWorld.ismastersim or inst.HUD then
        inst:WatchWorldState("phase", UpdateNightVision)
        UpdateNightVision(inst, TheWorld.state.phase)
    end
end

return MakePlayerCharacter("rgdog", prefabs, assets, common_postinit, master_postinit, prefabs)
 

 

modmain.lua

Edited by RGgameDog
updateing
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...