leprucio Posted September 10, 2016 Share Posted September 10, 2016 (edited) Hi, long time ago of the last post :P... Te problem is rally easy, i be stucked and i dont know how solve this error my LUA knowledge is a little poor, i trying to remake the wolfgang skill of migthiness but in one "SANITINESS" skill, at the moment i have to work in the future 2 models of the character but i first decided to make the skill work, and i trying it whit some little bugs but i now really dont know how solve this error i think maybe can be really easy but mi brain go out and i falling in mental darkne ss xDD. i put here the code of the character LUA if any one can give me a little of ligth whit this problem, srry for the bad Eng speak, Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset("SOUND", "sound/wendy.fsb") } local prefabs = { } -- Custom starting items local start_inv = { "sweatervest", "tophat", "bushhat", "sewing_kit", "sewing_kit", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", } -- When the character is revived from human -- When loading or spawning the character -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "gatira.tex" ) inst.Transform:SetScale(1.1, 1.1, 1.1) inst:AddTag("dappereffects") end local function sanityfn(inst) for k,v in pairs(inst.components.inventory.equipslots) do if AllRecipes[v.prefab].tab == RECIPETABS.DRESS then return TUNING.DAPPERNESS_LARGE -- Change this value after the "return " to change the sanity amount end end return 0 end local function applysanityness(inst) local percent = inst.components.sanity:GetPercent() local damage_mult = 0.9 local hunger_rate = 1 local health_max = 150 local mighty_scale = 1.2 local wimpy_scale = 0.9 local WALK_SPEED = 1.25 local RUN_SPEED = 1.25 if inst.strength == "sane" then local mighty_start = 180/200 local mighty_percent = math.max(0, (percent - mighty_start) / (1 - mighty_start)) damage_mult = 0.8 health_max = 170 hunger_rate = 1.2 WALK_SPEED = 1 RUN_SPEED = 1 elseif inst.strength == "insane" then local wimpy_start = 50/200 local wimpy_percent = math.min(1, percent/wimpy_start ) damage_mult = 1.1 health_max = 130 hunger_rate = 0.8 WALK_SPEED = 1.5 RUN_SPEED = 1.5 else inst._sanityness_scale = 1 end inst:ApplyScale("sanityness", inst._sanityness_scale) inst.components.hunger:SetRate(hunger_rate*TUNING.WILSON_HUNGER_RATE) inst.components.combat.damagemultiplier = damage_mult inst.components.locomotor.walkspeed = WALK_SPEED*TUNING.WILSON_WALK_SPEED inst.components.locomotor.runspeed = RUN_SPEED*TUNING.WILSON_RUN_SPEED local health_percent = inst.components.health:GetPercent() inst.components.health:SetMaxHealth(health_max) inst.components.health:SetPercent(health_percent, true) if inst.components.rider ~= nil and inst.components.rider:IsRiding() then OnMounted(inst) end end local function becomeinsane(inst, silent) if inst.strength == "insane" then return end if not silent then inst.sg:PushEvent("powerdown") inst.components.talker:Say(GetString(inst, "DEJAD DE GRITAR MALDITAS!!")) inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/talk_small_LP") end inst.talksoundoverride = "dontstarve/characters/wendy/talk_small_LP" inst.strength = "insane" end local function becomenormal(inst, silent) if inst.strength == "normal" then return end if not silent then if inst.strength == "sane" then inst.components.talker:Say(GetString(inst, "El dolor de cabeza vuelve...")) inst.sg:PushEvent("powerdown") inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/talk_small_LP") elseif inst.strength == "insane" then inst.components.talker:Say(GetString(inst, "Callad voces estupidas!!")) inst.sg:PushEvent("powerup") inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/talk_small_LP") end end inst.talksoundoverride = "dontstarve/characters/wendy/talk_small_LP" inst.hurtsoundoverride = nil inst.strength = "normal" end local function becomesane(inst, silent) if inst.strength == "sane" then return end if not silent then inst.components.talker:Say(GetString(inst, "Se callaron las voces.")) inst.sg:PushEvent("powerup") inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/talk_small_LP") end inst.talksoundoverride = "dontstarve/characters/wendy/talk_small_LP" inst.hurtsoundoverride = nil inst.strength = "sane" end local function onsanitychange(inst, data, forcesilent) if inst.sg:HasStateTag("nomorph") or inst:HasTag("playerghost") or inst.components.health:IsDead() then return end local silent = inst.sg:HasStateTag("silentmorph") or not inst.entity:IsVisible() or forcesilent if inst.strength == "sane" then if inst.components.sanity.current < 180 then if silent and inst.components.sanity.current < 50 then becomeinsane(inst, true) else becomenormal(inst, silent) end end elseif inst.strength == "insane" then if inst.components.sanity.current > 180 then if silent and inst.components.sanity.current > 50 then becomesane(inst, true) else becomenormal(inst, silent) end end elseif inst.components.sanity.current > 180 then becomesane(inst, silent) elseif inst.components.sanity.current < 50 then becomeinsane(inst, silent) end applysanityness(inst) end local function onnewstate(inst) if inst._wasnomorph ~= inst.sg:HasStateTag("nomorph") then inst._wasnomorph = not inst._wasnomorph if not inst._wasnomorph then onsanitychange(inst) end end end local function onbecamehuman(inst) -- Set speed when reviving from ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "gatira_speed_mod", 1) if inst._wasnomorph == nil then inst.strength = "normal" inst._wasnomorph = inst.sg:HasStateTag("nomorph") inst.talksoundoverride = nil inst.hurtsoundoverride = nil inst:ListenForEvent("sanitydelta", onsanitychange) inst:ListenForEvent("newstate", onnewstate) onsanitychange(inst, nil, true) end end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "gatira_speed_mod") if inst._wasnomorph ~= nil then inst.strength = "normal" inst._wasnomorph = nil inst.talksoundoverride = nil inst.hurtsoundoverride = nil inst:RemoveEventCallback("sanitydelta", onsanitychange) inst:RemoveEventCallback("newstate", onnewstate) end end local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) local loadhealth = inst._loadhealth or inst.components.health.currenthealth inst._loadhealth = nil if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end inst.components.health:SetPercent(loadhealth / inst.components.health.maxhealth, true) end local function onpreload(inst, data) if data ~= nil and data.health ~= nil then inst._loadhealth = data.health.health end end 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/" inst.strength = "normal" inst._mightiness_scale = 1 inst._wasnomorph = nil inst.talksoundoverride = nil inst.hurtsoundoverride = nil -- Stats inst.components.health:SetMaxHealth(150) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(200) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 0.9 -- Hunger rate (optional) inst.components.sanity.night_drain_mult = 2 inst.components.sanity.neg_aura_mult = 2 inst.components.sanity.custom_rate_fn = sanityfn inst.components.sanity.dapperness = TUNING.DAPPERNESS_SMALL*-2 inst.components.onsanitychange = onsanitychange inst.OnPreLoad = onpreload inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("gatira", prefabs, assets, common_postinit, master_postinit, start_inv) Gatira.rar Edited September 11, 2016 by leprucio Link to comment https://forums.kleientertainment.com/forums/topic/70070-solved-remake-wolfgang-skill-entityscript-error/ Share on other sites More sharing options...
CarlZalph Posted September 10, 2016 Share Posted September 10, 2016 (edited) function EntityScript:GetPersistData() local references = nil local data = nil for k,v in pairs(self.components) do if v.OnSave then This is where the topmost part of the stack points to. The error says that 'v' is a function value. So you have a function in your prefab.components when it shouldn't be. I see one, though there might be more: inst.components.onsanitychange = onsanitychange ^This is bad and should be changed. I think you're wanting to capture sanity changes, which is done via: inst:ListenForEvent( "sanitydelta", function(inst, data) -- Sanity changed here, either positive or negatively. end ) Edited September 10, 2016 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/70070-solved-remake-wolfgang-skill-entityscript-error/#findComment-812350 Share on other sites More sharing options...
leprucio Posted September 11, 2016 Author Share Posted September 11, 2016 (edited) Really Thx ahah i delete this and the LUA 1433 errot solved 17 hours ago, CarlZalph said: inst.components.onsanitychange = onsanitychange Spoiler local function onsanitychange(inst, data, forcesilent) if inst.sg:HasStateTag("nomorph") or inst:HasTag("playerghost") or inst.components.health:IsDead() then return end local silent = inst.sg:HasStateTag("silentmorph") or not inst.entity:IsVisible() or forcesilent if inst.strength == "sane" then if inst.components.sanity.current < 180 then if silent and inst.components.sanity.current < 50 then becomeinsane(inst, true) else becomenormal(inst, silent) end end elseif inst.strength == "insane" then if inst.components.sanity.current > 180 then if silent and inst.components.sanity.current > 50 then becomesane(inst, true) else becomenormal(inst, silent) end end elseif inst.components.sanity.current > 180 then becomesane(inst, silent) elseif inst.components.sanity.current < 50 then becomeinsane(inst, silent) end applysanityness(inst) end Now i trying to make it works properly (no errors but don't apply almost the new set of stats) because in any cases the sanity is cheked and the charackter spoke her lines but dont chage this stats and only say the lines one time i will try a little tings and if in a fews ours come back frustated here ask again haha T_T xD. I think this work properly but the last of "applysanityness(inst)" maybe don't work this supose to do the stats update... i will try my best and come here again ------------------EDIT: I full complete the skill here the code Spoiler Quote local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = { } -- Custom starting items local start_inv = { "sweatervest", "tophat", "bushhat", "sewing_kit", "sewing_kit", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", "green_cap", } -- When the character is revived from human -- When loading or spawning the character -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "gatira.tex" ) inst.Transform:SetScale(1.1, 1.1, 1.1) inst:AddTag("dappereffects") end local function sanityfn(inst) for k,v in pairs(inst.components.inventory.equipslots) do if AllRecipes[v.prefab].tab == RECIPETABS.DRESS then return TUNING.DAPPERNESS_LARGE -- Change this value after the "return " to change the sanity amount end end return 0 end local function applysanityness(inst) local damage_mult = 0.9 local hunger_rate = 1 local health_max = 150 local sane_scale = 1.2 local insane_scale = 0.9 local WALK_SPEED = 1.25 local RUN_SPEED = 1.25 if inst.strength == "sane" then damage_mult = 0.6 health_max = 170 hunger_rate = 1.2 WALK_SPEED = 1 RUN_SPEED = 1 inst._sanityness_scale =1 elseif inst.strength == "insane" then damage_mult = 1.1 health_max = 130 hunger_rate = 0.8 WALK_SPEED = 1.5 RUN_SPEED = 1.5 inst._sanityness_scale = 1 else inst._sanityness_scale = 1 end inst:ApplyScale("sanityness", inst._sanityness_scale) inst.components.hunger:SetRate(hunger_rate*TUNING.WILSON_HUNGER_RATE) inst.components.combat.damagemultiplier = damage_mult inst.components.locomotor.walkspeed = WALK_SPEED*TUNING.WILSON_WALK_SPEED inst.components.locomotor.runspeed = RUN_SPEED*TUNING.WILSON_RUN_SPEED local health_percent = inst.components.health:GetPercent() inst.components.health:SetMaxHealth(health_max) inst.components.health:SetPercent(health_percent, true) if inst.components.rider ~= nil and inst.components.rider:IsRiding() then OnMounted(inst) end end local function becomeinsane(inst, silent) if inst.strength == "insane" then return end if not silent then inst.sg:PushEvent("powerdown") inst.components.talker:Say("DEJAD DE GRITAR MALDITAS!!") end inst.strength = "insane" end local function becomenormal(inst, silent) if inst.strength == "normal" then return end if not silent then if inst.strength == "sane" then inst.components.talker:Say("El dolor de cabeza vuelve...") inst.sg:PushEvent("powerdown") elseif inst.strength == "insane" then inst.components.talker:Say("Callad voces estupidas!!") inst.sg:PushEvent("powerup") end end inst.hurtsoundoverride = nil inst.strength = "normal" end local function becomesane(inst, silent) if inst.strength == "sane" then return end if not silent then inst.components.talker:Say("Se callaron las voces.") inst.sg:PushEvent("powerup") end inst.hurtsoundoverride = nil inst.strength = "sane" end local function onsanitychange(inst, data, forcesilent) if inst.sg:HasStateTag("nomorph") or inst:HasTag("playerghost") or inst.components.health:IsDead() then return end local silent = inst.sg:HasStateTag("silentmorph") or not inst.entity:IsVisible() or forcesilent if inst.strength == "sane" then if inst.components.sanity.current < 180 then if silent and inst.components.sanity.current < 50 then becomeinsane(inst, true) else becomenormal(inst, silent) end end elseif inst.strength == "insane" then if inst.components.sanity.current > 50 then if silent and inst.components.sanity.current > 180 then becomesane(inst, true) else becomenormal(inst, silent) end end elseif inst.components.sanity.current > 180 then becomesane(inst, silent) elseif inst.components.sanity.current < 50 then becomeinsane(inst, silent) end applysanityness(inst) end local function onnewstate(inst) if inst._wasnomorph ~= inst.sg:HasStateTag("nomorph") then inst._wasnomorph = not inst._wasnomorph if not inst._wasnomorph then onsanitychange(inst) end end end local function onbecamehuman(inst) -- Set speed when reviving from ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "gatira_speed_mod", 1) if inst._wasnomorph == nil then inst.strength = "normal" inst._wasnomorph = inst.sg:HasStateTag("nomorph") inst.talksoundoverride = nil inst.hurtsoundoverride = nil inst:ListenForEvent("sanitydelta", onsanitychange) inst:ListenForEvent("newstate", onnewstate) onsanitychange(inst, nil, true) end end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "gatira_speed_mod") if inst._wasnomorph ~= nil then inst.strength = "normal" inst._wasnomorph = nil inst.talksoundoverride = nil inst.hurtsoundoverride = nil inst:RemoveEventCallback("sanitydelta", onsanitychange) inst:RemoveEventCallback("newstate", onnewstate) end end local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) local loadhealth = inst._loadhealth or inst.components.health.currenthealth inst._loadhealth = nil if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end inst.components.health:SetPercent(loadhealth / inst.components.health.maxhealth, true) end local function onpreload(inst, data) if data ~= nil and data.health ~= nil then inst._loadhealth = data.health.health end end 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/" inst.strength = "normal" inst._mightiness_scale = 1 inst._wasnomorph = nil inst.talksoundoverride = nil inst.hurtsoundoverride = nil -- Stats inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(200) -- Damage multiplier (optional) -- Hunger rate (optional) inst.components.sanity.night_drain_mult = 2 inst.components.sanity.neg_aura_mult = 2 inst.components.sanity.custom_rate_fn = sanityfn inst.components.sanity.dapperness = TUNING.DAPPERNESS_SMALL*-2 inst.OnPreLoad = onpreload inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("gatira", prefabs, assets, common_postinit, master_postinit, start_inv) Edited September 11, 2016 by leprucio Link to comment https://forums.kleientertainment.com/forums/topic/70070-solved-remake-wolfgang-skill-entityscript-error/#findComment-812633 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