DonMatio Posted April 30, 2018 Share Posted April 30, 2018 (edited) So before i added extra codes to the prefab.lua, i was able to run my character mod, but since i added the codes the game says that the mod is 'Crashed! Disabled'. Here's the .lua: local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting items local start_inv = { } -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when reviving from ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "rinko_speed_mod", 1.05) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "rinko_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 local function UpdateSpeed(inst, phase) local mult = 1 if phase == "day" then mult = 1.1 elseif phase == "dusk" then mult = 1 elseif phase == "night" then mult = 0.95 end inst.components.locomotor:SetExternalSpeedMultiplier(inst, "phase_speed", mult) end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "rinko.tex" ) end local function DoSanityDeltaOnAttacked(inst) for _, v in pairs(AllPlayers) do if v.components.sanity ~= nil and not v:HasTag("playerghost") if v == inst then v.components.sanity:DoDelta(-10) else v.components.sanity:DoDelta(-3) end end end end local function DoSanityDeltaOnDeath() for _, v in pairs(AllPlayers) do if v.components.sanity ~= nil and not v:HasTag("playerghost") v.components.sanity:DoDelta(-90) end end end local function SetSanityOnRevive(inst) inst:DoTaskInTime(0, function(inst) v.components.sanity.current = 20 end) 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/" -- Stats inst.components.health:SetMaxHealth(200) inst.components.hunger:SetMax(140) inst.components.sanity:SetMax(250) inst:ListenForEvent("attacked", DoSanityDeltaOnAttacked) inst:ListenForEvent("ms_becameghost", DoSanityDeltaOnDeath) inst:ListenForEvent("ms_respawnedfromghost", SetSanityOnRevive) inst.components.sanity.night_drain_mult = 0 inst.components.sanity.neg_aura_mult = 1 inst:WatchWorldState("phase", UpdateSpeed) UpdateSpeed(inst, TheWorld.state.phase) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1 -- Hunger rate (optional) inst.components.hunger.hungerrate = 0.95 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("rinko", prefabs, assets, common_postinit, master_postinit, start_inv) Edited April 30, 2018 by DonMatio Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/ Share on other sites More sharing options...
Lokoluna Posted April 30, 2018 Share Posted April 30, 2018 I used to have something like the speed stuff you got, while I'm not at my computer I believe the errors revolve around phase_speed and updatespeed, If I remember correctly there has to be something in your master postinit yo make it function Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1031459 Share on other sites More sharing options...
DonMatio Posted April 30, 2018 Author Share Posted April 30, 2018 (edited) Yeah i think i found what it was - inst:WatchWorldState("phase", UpdateSpeed) UpdateSpeed(inst, TheWorld.state.phase) I placed it in my master_postinit but it still says 'Crashed! Disabled' (I compiled it again after i placed it in) Edited April 30, 2018 by DonMatio Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1031462 Share on other sites More sharing options...
Lokoluna Posted April 30, 2018 Share Posted April 30, 2018 does your server_log.txt tell you why? Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1031506 Share on other sites More sharing options...
DonMatio Posted May 1, 2018 Author Share Posted May 1, 2018 (edited) This error appeared the third time i tried to run the mod: [string "scripts/mainfunctions.lua"]:147: Error loading file prefabs/rinko [string "../mods/workshop-361202313/scripts/prefabs/rinko.lua"]:58: 'then' expected near 'if' LUA ERROR stack traceback: =[C] in fucntions 'assert' scripts/mainfucntions.lua(147,1) =(tail call) ? =[C] in functions 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(596,1) scripts/gamelogic.lua(267,1) in function 'LoadAssets' Edited May 1, 2018 by DonMatio Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1031575 Share on other sites More sharing options...
Lokoluna Posted May 1, 2018 Share Posted May 1, 2018 The error is stated here, "then expected near if" So go to line 58, and look for if, then put it like this "thenif" atleast i think so. I know elseif works. so i think it has to be thenif. Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1031581 Share on other sites More sharing options...
ksaab Posted May 1, 2018 Share Posted May 1, 2018 if v.components.sanity ~= nil and not v:HasTag("playerghost") then There are two same errors. You should asked this in your previous thread. Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1031600 Share on other sites More sharing options...
DonMatio Posted May 1, 2018 Author Share Posted May 1, 2018 (edited) 5 hours ago, ksaab said: if v.components.sanity ~= nil and not v:HasTag("playerghost") then it works now, thank you so much! Can i add you to the mod's credit description when i'm completely done with the mod? Edited May 1, 2018 by DonMatio Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1031652 Share on other sites More sharing options...
ksaab Posted May 2, 2018 Share Posted May 2, 2018 19 hours ago, DonMatio said: Can i add you to the mod's credit description when i'm completely done with the mod? Yes, if you want. Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1031940 Share on other sites More sharing options...
DonMatio Posted May 2, 2018 Author Share Posted May 2, 2018 (edited) So there just happens to be another error, this time the game crashes for the host after i revive myself with this character mod in our server. (Image taken by my friend who was the host) Edited May 2, 2018 by DonMatio Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1032118 Share on other sites More sharing options...
Developer bizziboi Posted May 2, 2018 Developer Share Posted May 2, 2018 In inst:DoTaskInTime(0, function(inst) v.components.sanity.current = 20 end) try inst:DoTaskInTime(0, function(inst) inst.components.sanity.current = 20 end) Link to comment https://forums.kleientertainment.com/forums/topic/90368-mod-comes-up-as-crashed-disabled-coding-error/#findComment-1032126 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