Sh4d0wS14d3 Posted January 19, 2018 Share Posted January 19, 2018 (edited) I've been working with a friend to create a character (I'm working on the scripts, and he's been working on the art), and, using other mods as templates here and there, I was able to do every single thing I wanted my character to do. (Actually, I still want to make an experience bar that fills up per kill, but I feel like that might be a bit out of my reach considering this is my first character. And about 90% of the scripting wasn't exactly me, either...) The only problem now is that it crashes when I exit the world. The game still saves, and I can continue hosting my game as if nothing happened - but I feel like it'd probably be inconvenient to upload now, even if it's mainly for private use. Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting items local start_inv = { "leafblade", } -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when reviving from ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "snivy_speed_mod", 1) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "snivy_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( "snivy.tex" ) inst.Transform:SetScale(0.8, 0.8, 0.8) end -- This initializes for the server only. Components are added here. 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/" --(Leveling up script based from Shiro) local function onsave(inst, data) data.maxhealth = inst.components.health.maxhealth or nil data.maxhunger = inst.components.hunger.max or nil data.maxsanity = inst.components.sanity.max or nil data.absorb = inst.components.health.absorb or nil data.hungerrate = inst.components.hunger.hungerrate or nil data.aura_mult = inst.components.sanity.neg_aura_mult or nil data.drain_mult = inst.components.sanity.night_drain_mult or nil data.damagemultiplier = inst.components.combat.damagemultiplier or nil data.dapperness = inst.components.sanity.dapperness or nil data.inherentinsulation = inst.components.temperature.inherentinsulation or nil data.walkspeed = inst.components.locomotor.walkspeed or nil data.runspeed = inst.components.locomotor.runspeed or nil end --(Leveling up script based from Shiro) local function onpreload(inst, data) inst.components.health:SetMaxHealth(data.maxhealth) inst.components.hunger:SetMax(data.maxhunger) inst.components.sanity:SetMax(data.maxsanity) inst.components.health.absorb = data.absorb inst.components.hunger.hungerrate = data.hungerrate inst.components.sanity.neg_aura_mult = data.aura_mult inst.components.sanity.night_drain_mult = data.drain_mult inst.components.combat.damagemultiplier = data.damagemultiplier inst.components.sanity.dapperness = data.dapperness inst.components.temperature.inherentinsulation = data.inherentinsulation inst.components.locomotor.walkspeed = data.walkspeed inst.components.locomotor.runspeed = data.runspeed end --(Leveling up script based from Shiro) local function levelup(inst) if inst.components.health.maxhealth <= (294) then inst.components.health.maxhealth = (inst.components.health.maxhealth + 1) end if inst.components.sanity.max <= (229) then inst.components.sanity.max = (inst.components.sanity.max + 1) end if inst.components.hunger.max <= (229) then inst.components.hunger.max = (inst.components.hunger.max + 1) end if inst.components.combat.damagemultiplier <= (2.07) then inst.components.combat.damagemultiplier = (inst.components.combat.damagemultiplier + 0.01) end if inst.components.locomotor.walkspeed <= (6.27) then inst.components.locomotor.walkspeed = (inst.components.locomotor.walkspeed + 0.01) end if inst.components.locomotor.runspeed <= (8.27) then inst.components.locomotor.runspeed = (inst.components.locomotor.runspeed + 0.01) end end --Photosynthesis (Taken from Whimsy, sorry.) local function Photosynthesis(inst) if TheWorld.state.phase == "day" and not TheWorld:HasTag("cave") then if inst.components.health ~= nil then inst.components.health:StartRegen(2, 4) end inst.components.hunger:DoDelta(1, false) inst.components.hunger.hungerrate = -TUNING.WILSON_HUNGER_RATE*1.25 else inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE *1.5 if inst.components.health ~= nil then inst.components.health:StopRegen() end end end -- Stats inst.components.health:SetMaxHealth(45) inst.components.hunger:SetMax(55) inst.components.sanity:SetMax(55) inst.components.temperature.inherentsummerinsulation = 15 inst.components.temperature.overheattemp = 80 inst.components.temperature.inherentinsulation = 0 inst.components.health.fire_damage_scale = 2 inst.components.temperature.mintemp = -60 inst.components.temperature.hurtrate = 2 inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 6 inst.components.sanity.dapperness = 0.25 inst.components.sanity.night_drain_mult = 0.25 -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 0.45 --Attack Speed (also optional) inst.components.combat.min_attack_period = (TUNING.WILSON_ATTACK_PERIOD / 1.25) -- Hunger rate (optional) --inst.components.hunger.hungerrate = 0.6 * TUNING.WILSON_HUNGER_RATE inst:ListenForEvent("killed", function(inst) levelup(inst) end) inst.OnSave = onsave inst.OnLoad = onload inst.OnNewSpawn = onload inst.OnPreLoad = onpreload inst:WatchWorldState("phase", Photosynthesis) Photosynthesis(inst) end return MakePlayerCharacter("snivy", prefabs, assets, common_postinit, master_postinit, start_inv) snivy.lua Edited January 19, 2018 by Sh4d0wS14d3 Link to comment https://forums.kleientertainment.com/forums/topic/86597-character-crashes-on-exit/ Share on other sites More sharing options...
Sh4d0wS14d3 Posted January 20, 2018 Author Share Posted January 20, 2018 Nevermind, the issue was fixed - apparently, the bigportrait was still referencing esctemplate. Whoops. Link to comment https://forums.kleientertainment.com/forums/topic/86597-character-crashes-on-exit/#findComment-994548 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now