Yagenius Posted December 31, 2018 Share Posted December 31, 2018 (edited) As the title said I still stuck at attempt to index field 'inventory' (a nil value) when I tried to Transforms into another from. ( + random method and located the file when it's crash. # Use Same Code ) 1. error in components / playercontroller : [00:14:24]: [string "scripts/components/playercontroller.lua"]:1080: attempt to index field 'inventory' (a nil value) LUA ERROR stack traceback: scripts/components/playercontroller.lua:1080 in (method) HasAOETargeting (Lua) <1079-1085> scripts/components/playeractionpicker.lua:293 in (method) DoGetMouseActions (Lua) <284-326> scripts/components/playercontroller.lua:1855 in (method) OnUpdate (Lua) <1718-2109> scripts/update.lua:192 in () ? (Lua) <149-228> 2. error in components / builder_replica : [00:25:21]: [string "scripts/components/builder_replica.lua"]:265: attempt to index field 'inventory' (a nil value) LUA ERROR stack traceback: scripts/components/builder_replica.lua:265 in (method) CanBuild (Lua) <256-284> scripts/widgets/crafttabs.lua:519 in (method) DoUpdateRecipes (Lua) <492-589> scripts/widgets/crafttabs.lua:404 in (method) OnUpdate (Lua) <364-406> scripts/frontend.lua:749 in (method) Update (Lua) <616-766> scripts/update.lua:92 in () ? (Lua) <33-129> 3. error in widgets / inventorybar : [00:08:57]: [string "scripts/widgets/inventorybar.lua"]:377: attempt to index local 'inventory' (a nil value) LUA ERROR stack traceback: scripts/widgets/inventorybar.lua:377 in (method) Rebuild (Lua) <353-399> scripts/widgets/inventorybar.lua:420 in (method) OnUpdate (Lua) <401-482> scripts/frontend.lua:749 in (method) Update (Lua) <616-766> scripts/update.lua:92 in () ? (Lua) <33-129> Full error Log : 1. client_log2.txt 2. client_log3.txt 3. client_log4.txt My full prefab script : Spoiler local stategraphs = require "stategraphs/SGpretiger" local Badge = require "widgets/badge" local easing = require "easing" local MakePlayerCharacter = require "prefabs/player_common" local start_inv = { "carrot", "carrot", "carrot", "carrot", "carrot", "carrot", "carrot", "carrot", "carrot", "rabbit", } local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/bearger.fsb" ), Asset( "ANIM", "anim/aikawa.zip" ), Asset( "ANIM", "anim/ghost_aikawa_build.zip" ), Asset( "ANIM", "anim/tiger_meter.zip"), Asset("ANIM", "anim/weretiger_build.zip"), Asset("ANIM", "anim/pretiger_build.zip"), Asset("ANIM", "anim/bearger_ground_fx.zip"), Asset("ANIM", "anim/bearger_ring_fx.zip"), Asset("ANIM", "anim/deerclops_icespike.zip"), Asset( "IMAGE", "images/filter/colour_cubes/tiger_vision_cc.tex" ), Asset("ATLAS", "images/filter/aikawa.xml"), Asset("IMAGE", "images/filter/aikawa.tex"), Asset("ATLAS", "images/map_icons/ai_tiger.xml"), Asset("IMAGE", "images/map_icons/ai_tiger.tex"), } local prefabs = {} -- WERETIGER FUNCTIONS -- local function TigerGetStatus(inst, viewer) return inst:HasTag("playerghost") and "WERETIGER" or "KITTY" end local TIGER_DIET = { FOODTYPE.MEAT, FOODTYPE.HORRIBLE, FOODTYPE.VEGGIE, FOODTYPE.SEEDS, FOODTYPE.GENERIC, FOODTYPE.RAW, FOODTYPE.GEARS, } local function CannotExamine(inst) return false end local function TigerActionString(inst, action) return (action.action == ACTIONS.EAT and STRINGS.ACTIONS.EAT) or STRINGS.ACTIONS.MEOWING end local function TigerActionButton(inst ,data) local action_target = FindEntity(inst, 1000, function(guy) return (guy.components.edible and inst.components.eater:CanEat(guy)) or (guy.components.combat and inst.components.combat:CanTarget(guy) or inst.replica.combat:CanTarget(guy)) or (guy.components.workable and inst.components.worker:CanDoAction(guy.components.workable.action)) end) if not inst.sg:HasStateTag("busy") and action_target then if (action_target.components.edible and inst.components.eater:CanEat(action_target)) then return BufferedAction(inst, action_target, ACTIONS.EAT) elseif (action_target.components.combat and inst.components.combat:CanTarget(action_target) or inst.replica.combat:CanTarget(action_target)) then return BufferedAction(inst, action_target, ACTIONS.ATTACK) elseif (action_target.components.workable and inst.components.worker:CanDoAction(action_target.components.workable.action)) then return BufferedAction(inst, action_target, action_target.components.workable.action) end end end local function LeftClickPicker(inst, target, position) if inst.components.combat then if inst.components.combat:CanTarget(target) then return inst.components.playeractionpicker:SortActionList({ACTIONS.ATTACK}, target, nil) end if target and target.components.edible and inst.components.eater:CanEat(target) then return inst.components.playeractionpicker:SortActionList({ACTIONS.EAT}, target, nil) end if target and target.components.workable and inst.components.worker:CanDoAction(target.components.workable.action) then return inst.components.playeractionpicker:SortActionList({target.components.workable.action}, target, nil) end return {} elseif inst.replica.combat then if inst.replica.combat:CanTarget(target) then return inst.components.playeractionpicker:SortActionList({ACTIONS.ATTACK}, target, nil) end if target and target:HasTag("meat") or target:HasTag("prey") or target:HasTag("smallcreature") then return inst.components.playeractionpicker:SortActionList({ACTIONS.EAT}, target, nil) end if target and (target:HasTag("DIG_workable") or target:HasTag("ATTACK_workable") or target:HasTag("CHOP_workable") or target:HasTag("MINE_workable") or target:HasTag("PICK_workable") or target:HasTag("HAMMER_workable")) then local action_workable = target:HasTag("DIG_workable") and ACTIONS.DIG or target:HasTag("ATTACK_workable") and ACTIONS.ATTACK or target:HasTag("PICK_workable") and ACTIONS.PICK or target:HasTag("CHOP_workable") and ACTIONS.CHOP or target:HasTag("MINE_workable") and ACTIONS.MINE or target:HasTag("HAMMER_workable") and ACTIONS.HAMMER return inst.components.playeractionpicker:SortActionList({action_workable}, target, nil) end return {} else return {} end end local function RightClickPicker(inst, target, position) if target ~= nil and target ~= inst then for i, v in ipairs(TIGER_DIET) do if target:HasTag("edible_"..v) then return inst.components.playeractionpicker:SortActionList({ ACTIONS.EAT }, target, nil) end end return (target:HasTag("HAMMER_workable") and inst.components.playeractionpicker:SortActionList({ ACTIONS.HAMMER }, target, nil)) or (target:HasTag("DIG_workable") and target:HasTag("sign") and inst.components.playeractionpicker:SortActionList({ ACTIONS.DIG }, target, nil)) or nil end end local function SetTigerActions(inst, enable) if enable then inst.ActionStringOverride = TigerActionString if inst.components.playercontroller ~= nil then inst.components.playercontroller.actionbuttonoverride = TigerActionButton end if inst.components.playeractionpicker ~= nil then inst.components.playeractionpicker.leftclickoverride = LeftClickPicker inst.components.playeractionpicker.rightclickoverride = RightClickPicker end else inst.ActionStringOverride = nil if inst.components.playercontroller ~= nil then inst.components.playercontroller.actionbuttonoverride = nil end if inst.components.playeractionpicker ~= nil then inst.components.playeractionpicker.leftclickoverride = nil inst.components.playeractionpicker.rightclickoverride = nil end end end ------------------------------------------------------------------------------------------------------------------------------ local function SetAikawaWorker(inst, enable) if enable then if inst.components.worker == nil then inst:AddComponent("worker") inst.components.worker:SetAction(ACTIONS.DIG, 4) inst.components.worker:SetAction(ACTIONS.REPAIR, 4) inst.components.worker:SetAction(ACTIONS.DROP, 4) inst.components.worker:SetAction(ACTIONS.COOK, 4) inst.components.worker:SetAction(ACTIONS.HAMMER, 4) inst.components.worker:SetAction(ACTIONS.CATCH, 4) inst.components.worker:SetAction(ACTIONS.BUILD, 4) --inst.components.worker:SetAction(ACTIONS.FEED, 4) inst.components.worker:SetAction(ACTIONS.CHOP, 4) inst.components.worker:SetAction(ACTIONS.MINE, 4) inst.components.worker:SetAction(ACTIONS.PICKUP, 4) end elseif inst.components.worker ~= nil then inst:RemoveComponent("worker") end end local function SetGroundPTags(inst, enable) if enable then if inst.components.groundpounder == nil then inst:AddComponent("groundpounder") inst.components.groundpounder.destroyer = true inst.components.groundpounder.groundpoundfx = "firesplash_fx" inst.components.groundpounder.damageRings = 7 inst.components.groundpounder.destructionRings = 7 inst.components.groundpounder.numRings = 7 end elseif inst.components.groundpounder ~= nil then inst:RemoveComponent("groundpounder") end end ------------------ -- CHANGE BADGE -- ------------------ local TigerBadge = Class(Badge, function(self, owner) Badge._ctor(self, "tiger_meter", owner) end) --------------------------------------------------- ------------------- -- SetTigerMode -- ------------------ local function SetHUDState(inst) if inst.HUD then if inst.components.tigerness:IsTiger() and not inst.HUD.controls.tigerbadge then inst.HUD.controls.tigerbadge = ThePlayer.HUD.controls.sidepanel:AddChild(TigerBadge(inst)) inst.HUD.controls.tigerbadge:SetPosition(0,-400,0) inst.HUD.controls.tigerbadge:SetPercent(1) inst.HUD.controls.tigerbadge.inst:ListenForEvent("tigernessdelta", function(_, data) inst.HUD.controls.tigerbadge:SetPercent(inst.components.tigerness:GetPercent(), inst.components.tigerness.max) if not data.overtime then if data.newpercent > data.oldpercent then inst.HUD.controls.tigerbadge:PulseGreen() TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/health_up") elseif data.newpercent < data.oldpercent then TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/health_down") inst.HUD.controls.tigerbadge:PulseRed() end end end, inst) inst.HUD.controls.tigerbadge:Show() elseif not inst.components.tigerness:IsTiger() and inst.HUD.controls.tiger then if inst.HUD.controls.tigerbadge then inst.HUD.controls.tigerbadge:Show() end inst.HUD.controls.crafttabs:Show() inst.HUD.controls.inv:Show() inst.HUD.controls.status:Show() inst.HUD.controls.tigerbadge:Show() inst.HUD.controls.mapcontrols.minimapBtn:Show() end end end local function SetTigerMode(inst, istiger) if istiger then if not TheWorld.ismastersim then inst.CanExamine = nil onbecameaikawa(inst) SetTigerActions(inst, false) if inst.components.locomotor ~= nil then inst.components.locomotor.runspeed = 14 end end else if not TheWorld.ismastersim then inst.CanExamine = inst.istigermode:value() and CannotExamine or nil onbecameaikawa(inst) SetTigerActions(inst, false) if inst.components.locomotor ~= nil then inst.components.locomotor.runspeed = 14 end end end end local function SetTigerSounds(inst, enable) if enable then inst.hurtsoundoverride = "dontstarve/characters/aikawa/hurtz" else inst.hurtsoundoverride = nil end end ------------------------------------------------------------------------------------------------------------------------------------------ local function GetTigerness(inst) if inst.components.tigerness ~= nil then return inst.components.tigerness:GetPercent() elseif inst.player_classified ~= nil then return inst.player_classified.currenttigerness:value() * .01 else return 1 end end local function ontigernesschange(inst) if inst.sg:HasStateTag("nomorph") or inst.sg:HasStateTag("silentmorph") or inst:HasTag("playerghost") or inst.components.health:IsDead() or not inst.entity:IsVisible() then return end if inst.istigermode:value() then if inst.components.tigerness:GetPercent() <= TUNING.WOODIE_TRANSFORM_TO_HUMAN then inst:PushEvent("transform_person") end elseif inst.components.tigerness:GetPercent() > TUNING.WOODIE_TRANSFORM_TO_BEAVER then inst:PushEvent("transform_werebeaver") end end local function CalcReflect(inst, attacker, damage, weapon, stimuli) if inst:HasTag("tiger") then return 500 end return 2 end local function tigerhurt(inst, delta) if delta < 0 then inst.sg:PushEvent("attacked") inst.components.tigerness:DoDelta(delta*0.2) TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/health_down") end end ----------------------------------------------------------------------------------------------------------------------------------- ----- BEARGER TEST ----- ------------------------------------------------------------------------------------------------------------------------------------------ local function ClearRecentlyCharged(inst, other) inst.recentlycharged[other] = nil end local function OnDestroyOther(inst, other) if other:IsValid() and inst:HasTag("IAMTIGER") and other.components.workable ~= nil and other.components.workable:CanBeWorked() and other.components.workable.action ~= ACTIONS.NET and not inst.recentlycharged[other] then SpawnPrefab("collapse_big").Transform:SetPosition(other.Transform:GetWorldPosition()) if other.components.lootdropper ~= nil and (other:HasTag("tree") or other:HasTag("boulder") or other:HasTag("DECOR")) then other.components.lootdropper:SetLoot({}) end other.components.workable:Destroy(inst) if other:IsValid() and other.components.workable ~= nil and other.components.workable:CanBeWorked() then inst.recentlycharged[other] = true inst:DoTaskInTime(3, ClearRecentlyCharged, other) end end end local function SetStandState(inst, state) --"quad" or "bi" state inst.StandState = string.lower(state) end local function IsStandState(inst, state) return inst.StandState == string.lower(state) end ------------------------------------------------------------SLEEP TEST ---------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------ ----- STATS ----- ------------------------------------------------------------------------------------------------------------------------------------------ ------------------------- Leveling System TEST ----------------------------------------- YEP♥ local function Catzisgrow(inst) local max_upgrades = 100000 local upgrades = math.min(inst.level, max_upgrades) local hunger_percent = inst.components.hunger:GetPercent() local health_percent = inst.components.health:GetPercent() local sanity_percent = inst.components.sanity:GetPercent() inst.components.hunger.max = math.ceil (5 + upgrades * 2) --50 inst.components.health.maxhealth = math.ceil (5 + upgrades * 2) --150 inst.components.sanity.max = math.ceil (5 + upgrades * 2) --50 inst.components.combat.damagemultiplier = math.ceil (1 + upgrades * 1) --11 inst.components.combat.damagebonus = math.ceil (1 + upgrades * 1) --50 inst.components.combat.defaultdamage = math.ceil (0.1 + upgrades * 0.1) --50 inst.components.talker:Say("Kitty is now Level : ♥ Keep Going ♥ ".. (inst.level)) if inst.level > 99999 then inst.components.talker:Say("Kitty is now Level MAX : Congratulation ^ q ^ ♥") end if inst.level > 150 then inst.components.health:StartRegen(50 , 2.5) inst.components.combat:SetRange(4.5) inst.components.combat:SetDefaultDamage(100*2.3) elseif inst.level > 250 then inst.components.combat:SetDefaultDamage(400*2.3) inst.components.hunger.hungerrate = 0.9* TUNING.WILSON_HUNGER_RATE -- 20 elseif inst.level > 500 then inst.components.health:StartRegen(1500 , 2.5) inst.components.combat:SetDefaultDamage(2500*2.1) elseif inst.level > 900 then inst.components.health:StartRegen(5000 , 3) inst.components.combat:SetDefaultDamage(7000*8) elseif inst.level > 2500 then inst.components.health:StartRegen(5000 , 2.5) inst.components.combat:SetDefaultDamage(70000*8) elseif inst.level > 5000 then inst.components.health:StartRegen(2500 , 1.5) inst.components.combat:SetDefaultDamage(90000*10) end inst.components.hunger:SetPercent(hunger_percent) inst.components.health:SetPercent(health_percent) inst.components.sanity:SetPercent(sanity_percent) end ------------------------- Main Stats. ----------------------------------------- ? local function onbecameaikawa(inst) if inst.prefab ~= nil and inst.sg.currentstate.name ~= "reviver_rebirth" then inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild("aikawa") end inst.tiger = false inst.Transform:SetScale(1.2, 1.2, 1.2, 1.2) inst.entity:AddDynamicShadow() inst.DynamicShadow:SetSize(1.2,1.2) inst.MiniMapEntity:SetIcon( "aikawa.tex" ) inst.ActionStringOverride = nil inst.components.talker:StopIgnoringAll("becametiger") inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild("aikawa") inst:SetStateGraph("SGpretiger") inst:RemoveComponent("groundpounder") inst:RemoveTag("IAMTIGER") inst:RemoveTag("IAMAIGER") inst:RemoveTag("scarytoprey") inst:AddTag("IAMAIKAWA") if not TheWorld.ismastersim then ------------------------------------------------------------------------------------------------------------------------------------------------ inst:AddComponent("waterproofer") inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE*8) ------------------------------------------------------------------------------------------------------------------------------------------------ inst.components.locomotor.walkspeed = 14 inst.components.locomotor.runspeed = 16 inst.components.temperature.maxtemp = 50 inst.components.temperature.mintemp = 20 inst.components.heater.heat = 100 inst.components.combat:SetAreaDamage(6*0.5, 6*0.5) inst.components.combat:SetRange(4) inst.components.health:SetAbsorptionAmount(0) inst.components.eater.eatwholestack = false inst.components.eater:SetDiet({ FOODGROUP.OMNI }) inst.components.temperature.inherentinsulation = 0 inst.components.temperature.inherentsummerinsulation = 0 if inst.components.playercontroller ~= nil then inst.components.playercontroller:SetCanUseMap(true) end inst.components.eater.strongstomach = false --inst.components.pinnable.canbepinned = true --if not GetGameModeProperty("no_hunger") then --inst.components.hunger:Resume() --end if inst.components.inspectable.getstatus == TigerGetStatus then inst.components.inspectable.getstatus = inst._getstatus inst._getstatus = nil end inst.CanExamine = nil --inst.components.sanity.ignore = false --inst.components.health.redirect = nil inst.components.tigerness:StartTimeEffect(1, -3) SetAikawaWorker(inst, true) SetTigerActions(inst, false) SetTigerSounds(inst, false) SetGroundPTags(inst, false) if inst.istigermode:value() then inst:RemoveTag("IAMTIGER") inst.Network:RemoveUserFlag(USERFLAGS.CHARACTER_STATE_1) inst.istigermode:set(false) inst:PushEvent("tigerend") --OnTigerModeDirty(inst) inst:DoTaskInTime(0.5, function() SetHUDState(inst) end) end inst.Light:Enable(false) --inst.SoundEmitter:KillSound("danger") return inst end end local function onbecametiger(inst) if inst.sg.currentstate.name ~= "reviver_rebirth" then inst.components.skinner:HideAllClothing(inst.AnimState) inst.AnimState:SetBank("WERETIGER") inst.AnimState:SetBuild("weretiger_build") end inst.tiger = true inst.entity:AddDynamicShadow() inst.DynamicShadow:SetSize(12, 6.5) inst.Transform:SetScale(2, 2, 2, 2) inst.MiniMapEntity:SetIcon( "ai_tiger.tex" ) inst.components.eater:SetDiet(TIGER_DIET) inst.components.talker:IgnoreAll("becametiger") inst:AddTag("IAMTIGER") inst:RemoveTag("IAMAIKAWA") inst:RemoveTag("IAMAIGER") inst.AnimState:SetBuild("weretiger_build") inst.AnimState:SetBank("WERETIGER") inst:SetStateGraph("SGpretiger") if not TheWorld.ismastersim then ------------------------------------------------------------------------------------- inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE*2) ------------------------------------------------------------------------------------- ------------------------------------------- inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 6 inst.components.sanity.night_drain_mult = 6 inst.components.sanity.neg_aura_mult = 5 inst.components.temperature.maxtemp = 50 inst.components.temperature.mintemp = 20 --inst.components.health.fire_damage_scale = 0 inst.components.health:SetAbsorptionAmount(1000) inst.components.eater.eatwholestack = true inst.components.health:StartRegen(100 , 2.5) inst.components.combat:SetDefaultDamage(5000*5) -- 20 inst.components.combat:SetAreaDamage(10, 10) if inst.components.playercontroller ~= nil then inst.components.playercontroller:SetCanUseMap(false) end inst.components.inventory:DropEverything(true) --inst.components.sanity:SetPercent(1) --inst.components.health:SetPercent(1) --inst.components.hunger:SetPercent(1) inst.components.pinnable.canbepinned = false --inst.components.hunger:Pause() --inst.components.sanity.ignore = true inst.components.health.redirect = tigerhurt inst.components.health.redirect_percent = 5 inst:AddComponent("inspectable") if inst.components.inspectable.getstatus ~= TigerGetStatus then inst._getstatus = inst.components.inspectable.getstatus inst.components.inspectable.getstatus = TigerGetStatus end inst.CanExamine = CannotExamine inst.components.eater.strongstomach = true inst.components.eater.monsterimmune = true SetAikawaWorker(inst, true) SetTigerActions(inst, true) SetTigerSounds(inst, false) SetGroundPTags(inst, true) if not inst.istigermode:value() then inst:AddTag("IAMTIGER") inst.Network:AddUserFlag(USERFLAGS.CHARACTER_STATE_1) inst.istigermode:set(true) inst:PushEvent("tigerstart") --OnTigerModeDirty(inst) inst:DoTaskInTime(0.5, function() SetHUDState(inst) end) end inst.Light:Enable(true) inst.SoundEmitter:KillSound("eating") --inst.SoundEmitter:PlaySound("dontstarve/music/music_epicfight_winter", "danger") return inst end end local function onbecamepretiger(inst) if inst.sg.currentstate.name ~= "reviver_rebirth" then inst.components.skinner:HideAllClothing(inst.AnimState) inst.AnimState:SetBank("pretiger") inst.AnimState:SetBuild("pretiger_build") end inst.tiger = false inst.Transform:SetScale(2, 2, 2, 2) inst.components.eater:SetDiet(TIGER_DIET) inst.MiniMapEntity:SetIcon( "aikawa.tex" ) inst:AddTag("IAMAIGER") inst:RemoveTag("IAMAIKAWA") inst:RemoveTag("IAMTIGER") inst.AnimState:SetBuild("pretiger_build") inst.AnimState:SetBank("pretiger") inst:SetStateGraph("SGpretiger") ----------------------------------------------------------------------------------------- if not TheWorld.ismastersim then ------------------------------------------------------------------------------------- inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE*20) ------------------------------------------------------------------------------------- ------------------------------------------- inst.components.locomotor.walkspeed = 11 inst.components.locomotor.runspeed = 12 inst.components.sanity.night_drain_mult = 0 inst.components.sanity.neg_aura_mult = 0 inst.components.temperature.maxtemp = 50 inst.components.temperature.mintemp = 20 --inst.components.health.fire_damage_scale = 0 inst.components.health:SetAbsorptionAmount(50) inst.components.eater.eatwholestack = true inst.components.health:StartRegen(100 , 2.5) inst.components.combat:SetDefaultDamage(50*5) -- 20 inst.components.combat:SetAreaDamage(7, 7) if inst.components.playercontroller ~= nil then inst.components.playercontroller:SetCanUseMap(true) end inst.CanExamine = CannotExamine inst.components.inventory:DropEverything(true) --inst.components.sanity:SetPercent(1) --inst.components.health:SetPercent(1) --inst.components.hunger:SetPercent(1) inst.components.pinnable.canbepinned = false --inst.components.hunger:Pause() --inst.components.sanity.ignore = true inst.components.health.redirect = tigerhurt inst.components.health.redirect_percent = 5 inst.components.eater.strongstomach = true inst.components.eater.monsterimmune = true SetAikawaWorker(inst, true) SetTigerActions(inst, true) SetTigerSounds(inst, true) SetGroundPTags(inst, false) inst.Light:Enable(true) inst.SoundEmitter:KillSound("eating") --inst.SoundEmitter:PlaySound("dontstarve/music/music_epicfight_winter", "danger") return inst end end --------------------------------------------------------------------------------------------------------------- local function TransformTiger(inst, istiger) if istiger then onbecamepretiger(inst) else onbecameaikawa(inst) end end ---------------------------------------------------------------------------------------------------------------- -------------------------------------FULLMOON TEST----------------------------------------------------------- YEP♥ local function OnIsFullmoon(inst, isfullmoon) if inst:HasTag("playerghost") then return end if inst.sg:HasStateTag("tent") then return end if inst.sg:HasStateTag("insomniac") then return end if inst.sg:HasStateTag("sleeping") then return end if inst.sg:HasStateTag("sleep")then return end if inst.sg:HasStateTag("bedroll") then return end if isfullmoon and inst:HasTag("IAMAIKAWA") then inst.components.tigerness:StartTimeEffect(1,15) SpawnPrefab("lightning").Transform:SetPosition(inst:GetPosition():Get()) onbecamepretiger(inst) elseif not isfullmoon and inst:HasTag("IAMAIGER") or inst:HasTag("IAMTIGER") then inst.components.tigerness:StartTimeEffect(1, -3) SpawnPrefab("lightning").Transform:SetPosition(inst:GetPosition():Get()) onbecameaikawa(inst) inst.sg:GoToState("knockout") inst:DoTaskInTime(15, function() inst.sg:GoToState("wakeup") end) end end -------------------- -- CHANGE TO MEAT -- -------------------- local function onaikawaeat(inst, food) -- 1 Delta is 1% -- Tigerness 80 if food.name == 'Meaty Stew' or food.name == 'Monster Meat' or food.name == 'Monster Tartare' or food.name == 'Turkey Dinner' or food.name == 'Long Pig Jerky' then inst.components.tigerness:DoDelta(8) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 2.5 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/aikawa/warn") -- Tigerness EXTRA elseif food.name == 'Long Pig' or food.name == 'Cooked Long Pig' or food.name == 'Long Pig Jerky' then inst.components.tigerness:DoDelta(8) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 5 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/aikawa/warn") -- Tigerness 42 elseif food.name == 'Meat' or food.name == 'Monster Lasagna' or food.name == 'Koalefant Trunk' or food.name == 'Winter Koalefant Trunk'or food.name == 'beefalo_wings' or food.name == 'beef_butter' or food.name == 'beef_maxwell' then inst.components.tigerness:DoDelta(4.2) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 2 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/aikawa/warn") -- Tigerness 35 elseif food.name == 'Bacon and Eggs' or food.name == 'Turkey Dinner' or food.name == 'Tallbird Egg' or food.name == 'Koalefant Trunk Steak' or food.name == 'Koalefant Trunk Steak' or food.name == 'monster_burger' then inst.components.tigerness:DoDelta(3.5) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 1.5 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/aikawa/meow") -- Tigerness 30 elseif food.name == 'Morsel' or food.name == 'Batilisk Wing' or food.name == 'Leafy Meat' then inst.components.tigerness:DoDelta(3) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 1.3 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pounce_pre") -- Tigerness 20 elseif food.name == 'Frog Legs' or food.name == 'Cooked Leafy Meat' then inst.components.tigerness:DoDelta(2) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 1.2 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pounce_pre") -- Tigerness 12 elseif food.name == 'Jerky' or food.name == 'Egg' or food.name == 'liquor' then inst.components.tigerness:DoDelta(1.2) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 1.1 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pounce_pre") -- Tigerness 10 elseif food.name == 'Cooked Meat' or food.name == 'Cooked Monster Meat' or food.name == 'Cooked Frog Legs' or food.name == 'Cooked Egg' then inst.components.tigerness:DoDelta(1) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 1 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pounce_pre") -- Tigerness 8 elseif food.name == 'Drumstick' or food.name == 'Small Jerky' then inst.components.tigerness:DoDelta(0.8) --------- GIVE THE CATZ A LEVEL!!! inst.level = inst.level + 0.5 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pounce_pre") -- Tigerness 5 elseif food.name == 'Fried Drumstick' or food.name == 'Meatballs' then inst.components.tigerness:DoDelta(0.5) --------- GIVE A CATZ A LEVEL!!! inst.level = inst.level + 0.5 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pickup") -- Tigerness 3 elseif food.name == 'Cooked Morsel' or food.name == 'Froggle Bunwich' or food.name == 'Honey Ham' or food.name == 'Human Eyes' or food.name == 'Kabobs' or food.name == 'Pierogi' or food.name == 'Eel' or food.name == 'Spicy Chili' or food.name == 'Guacamole' or food.name == 'Froggle Bunwich' then inst.components.tigerness:DoDelta(0.3) --------- GIVE A CATZ A LEVEL!!! inst.level = inst.level + 0.3 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pickup") -- Tigerness -2 : Favorite Food <3 elseif food.name == 'Fishsticks' or food.name == 'Cooked Fish' or food.name == 'Fish Tacos' or food.name == 'Salo Cespite' or food.name == 'Seafood Stufed Vegetable' or food.name == 'fish_n_chips' or food.name == 'Fish' or food.name == 'Electric Milk' or food.name == 'Cooked Eel' or food.name == 'Ice Cream' or food.name == 'cactus_soup' or food.name == 'coconut_milk' or food.name == 'juice_waterberry' or food.name == 'lobster_faked' or food.name == 'margarita' or food.name == 'coconut_milk' or food.name == 'juice_waterberry' or food.name == 'mushroom_stew' or food.name == 'salad_bloom' or food.name == 'salad_carrot' or food.name == 'salad_egg' or food.name == 'salad_grape' or food.name == 'salad_spiced' or food.name == 'salad_waldorf' or food.name == 'salad_yamion' or food.name == 'sandwich_banana' or food.name == 'sandwich_veggie' or food.name == 'shellfish_butter' or food.name == 'spiced_fish' or food.name == 'tea_floral' or food.name == 'tempura_shrimp' or food.name == 'yamion_rings' then inst.components.tigerness:DoDelta(-2) inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_FAVFOOD")) --------- GIVE A CATZ A LEVEL!!! inst.level = inst.level + 0.5 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/aikawa/meow") -- Tigerness : Other Foods Mods Support elseif food.name == 'ack_muffin' or food.name == 'aloo_tiki' or food.name == 'braciole' or food.name == 'cactus_cake' or food.name == 'cake_crab' or food.name == 'flour_ground' or food.name == 'fruit_muffin' or food.name == 'candied_bacon' or food.name == 'candied_fruit' or food.name == 'candied_nut' or food.name == 'coldcuts' or food.name == 'gazpacho' or food.name == 'fruit_leather' or food.name == 'limongelo' or food.name == 'fruit_syrup' or food.name == 'fruit_truffle' or food.name == 'gruel' or food.name == 'guavacado' or food.name == 'guavacado_cooked' or food.name == 'gumbo' or food.name == 'limonade' or food.name == 'cheese_log' or food.name == 'citrus_mushroom' or food.name == 'daiquiri' or food.name == 'dragon_roll' or food.name == 'hardtack' or food.name == 'limon' or food.name == 'limon_cooked' or food.name == 'meringue' or food.name == 'mush_melon' or food.name == 'mush_melon_cooked' or food.name == 'mushroom_burger' or food.name == 'mushroom_malody' or food.name == 'mushroom_medley' or food.name == 'mushy_eggs' or food.name == 'nana_bread' or food.name == 'nopalito' or food.name == 'nut_butter' or food.name == 'oleo' or food.name == 'omelette' or food.name == 'papayanapple' or food.name == 'picatta' or food.name == 'pina_colada' or food.name == 'pinot_noir' or food.name == 'porridge' or food.name == 'rocky_meat' or food.name == 'rocky_meat_cooked' or food.name == 'rollatini' or food.name == 'sandwich_croque' or food.name == 'sandwich_blt' or food.name == 'sandwich_jam' or food.name == 'sausage_gravy' or food.name == 'shamcakes' or food.name == 'soup_broth' or food.name == 'soup_chowder' or food.name == 'soup_squash' or food.name == 'soup_watercress' or food.name == 'spiced_cake' or food.name == 'spiced_ham' or food.name == 'spiced_rum' or food.name == 'spiced_sausage' or food.name == 'sticky_bun' or food.name == 'stuffed_tomango' or food.name == 'surf_n_turf' or food.name == 'sweet_n_sour' or food.name == 'tarte_tatin' or food.name == 'tentacicle' or food.name == 'tentacle_meat' or food.name == 'tentacle_meat_cooked' or food.name == 'tomango' or food.name == 'tomango_cooked' or food.name == 'tomango_dried' or food.name == 'twice_baked' or food.name == 'vino' or food.name == 'yamion' or food.name == 'yamion_cooked' or food.name == 'yamion_cooked' or food.name == 'zucchilli' or food.name == 'zucchilli_cooked' or food.name == 'cherry_cake' or food.name == 'cherry_pie' then inst.components.tigerness:DoDelta(-1) --------- GIVE A CATZ A LEVEL!!! inst.level = inst.level + 2 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pickup") -- Tigerness -10 : Most are Veggies elseif food.name == 'Berries' or food.name == 'Carrot' or food.name == 'Corn' or food.name == 'Pumpkin' or food.name == 'Eggplant' or food.name == 'Red Cap' or food.name == 'Roasted Carrot' or food.name == 'Green Cap' or food.name == 'Blue Cap' or food.name == 'Mandrake' or food.name == 'Cactus' or food.name == 'Cooked Cactus Flesh' or food.name == 'Cooked Mandrake' or food.name == 'Cooked Blue Cap' or food.name == 'Cooked Green Cap' or food.name == 'Cooked Red Cap' or food.name == 'Braised Eggplant' or food.name == 'Hot Pumpkin' or food.name == 'Petals' or food.name == 'Dark Petals' or food.name == 'Seeds' or food.name == 'Mandrake Soup' or food.name == 'Stuffed Eggplant' or food.name == 'Pomegranate' or food.name == 'Sliced Pomegranate' or food.name == 'Dragon Fruit' or food.name == 'Prepared Dragon Fruit' or food.name == 'Durian' or food.name == 'Extra Smelly Durian' or food.name == 'Roasted Berries' or food.name == 'Cave Banana' or food.name == 'Cooked Cave Banana' or food.name == 'Watermelon' or food.name == 'Grilled Watermelon' or food.name == 'Dragonpie' or food.name == 'Fist Full of Jam' or food.name == 'Fruit Medley' or food.name == 'Waffles' or food.name == 'Melonsicle' or food.name == 'Trail Mix' or food.name == 'Ice' or food.name == 'Butter' or food.name == 'Butterfly Wings' or food.name == 'Braised Eggplant' or food.name == 'Cactus Flower' or food.name == 'Glow Berry' or food.name == 'Foliage' or food.name == 'Lichen' or food.name == 'Toasted Seeds' or food.name == 'Honey Nuggets' or food.name == 'Butter Muffin' or food.name == 'Flower Salad' or food.name == 'Seaweed' or food.name == 'Honey' or food.name == 'garleek' or food.name == 'garleek_cooked' or food.name == 'grapricot' or food.name == 'grapricot_cooked' or food.name == 'grapricot_dried' or food.name == 'Roasted Seaweed' or food.name == 'Dried Seaweed' or food.name == 'Sweet Potato' or food.name == 'Cooked Sweet Potato' or food.name == 'California Roll' or food.name == 'Crop Seeds' or food.name == 'Ratatouille' or food.name == 'Sweet Potato Souffle' or food.name == 'Cooked Banana' or food.name == 'Popcorn' or food.name == 'Lesser Glow Berry' or food.name == 'Juicy Berries' or food.name == 'Roasted Juicy Berries' or food.name == 'rutabeeta' or food.name == 'rutabeeta_cooked' then inst.components.tigerness:DoDelta(-10) inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_NONE")) --------- GIVE A CATZ A LEVEL!!! inst.level = inst.level + 0.1 Catzisgrow(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/catcoon/pickup") end local caton = math.random() local timeout = math.random()+.5 --Catz Tier 3 if caton < 0.10 and inst.components.tigerness:GetPercent() > .99 and inst:HasTag("IAMAIGER") and not inst:HasTag("IAMAIKAWA") and not inst:HasTag("playerghost") or not inst.sg:HasStateTag("busy") then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_HIGHEST")) SpawnPrefab("lightning").Transform:SetPosition(inst:GetPosition():Get()) onbecametiger(inst) inst.sg:GoToState("targetstolen") --Catz Tier 2 elseif caton < 0.05 and inst.components.tigerness:GetPercent() > .8 and inst:HasTag("IAMAIKAWA") and not inst:HasTag("IAMTIGER") and not inst:HasTag("playerghost") or not inst.sg:HasStateTag("busy") then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_HIGHEST")) SpawnPrefab("lightning").Transform:SetPosition(inst:GetPosition():Get()) onbecamepretiger(inst) elseif inst.components.tigerness:GetPercent() > .7 and inst:HasTag("IAMAIKAWA") and not inst:HasTag("IAMTIGER") and not inst:HasTag("playerghost") or not inst.sg:HasStateTag("busy") then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_HIGHEST")) inst:DoTaskInTime(1, function() inst.AnimState:PlayAnimation("idle_hot_pre") inst.AnimState:PlayAnimation("idle_hot_loop") inst.AnimState:PushAnimation("idle_hot_loop",true) inst.AnimState:PushAnimation("idle_hot_pst",false) timeout = timeout*2 end) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- elseif inst.components.tigerness:GetPercent() >.1 and inst:HasTag("IAMAIGER") then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_GRAAOW")) elseif inst.components.tigerness:GetPercent() > .65 then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_HIGHER")) elseif inst.components.tigerness:GetPercent() > .5 then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_AVERAGE")) elseif inst.components.tigerness:GetPercent() > .4 then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_LOW")) elseif inst.components.tigerness:GetPercent() > .35 then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_LOWER")) elseif inst.components.tigerness:GetPercent() > .25 then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_LOWEST")) elseif inst.components.tigerness:GetPercent() < .10 and inst:HasTag("IAMTIGER") or inst:HasTag("IAMTIGER") then inst.components.talker:Say(GetString("aikawa", "ANNOUNCE_TIGERNESS_NO")) SpawnPrefab("lightning").Transform:SetPosition(inst:GetPosition():Get()) onbecameaikawa(inst) inst.components.talker:StopIgnoringAll("becametiger") print ('tigerness', inst.components.tigerness:GetPercent()) end end ------------------------------------------------------------------------ -------------------------------------------------------------------------- --Re-enter idle state right after loading because --idle animations are determined by beaver state. local function onpreload(inst, data) if data then if data.level then inst.level = data.level Catzisgrow(inst) --re-set these from the save data, because of load-order clipping issues if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end inst.components.health:DoDelta(0) inst.components.hunger:DoDelta(0) inst.components.sanity:DoDelta(0) end if data ~= nil and data.istiger then inst:SetStateGraph("SGpretiger") inst.AnimState:SetBank("pretiger") inst.AnimState:SetBuild("pretiger_build") inst.sg:GoToState("idle") end end end -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when reviving from ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "aikawa_speed_mod", 1) inst.components.locomotor.walkspeed = 14 inst.components.locomotor.runspeed = 16 inst.Light:Enable(false) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:SetExternalSpeedMultiplier(inst, "aikawa_speed_mod", 1) inst.components.locomotor.walkspeed = 14 inst.components.locomotor.runspeed = 16 inst.Light:Enable(true) end -- When loading or spawning the character local function OnCollide(inst, other) if other ~= nil and other:IsValid() and other.components.workable ~= nil and other.components.workable:CanBeWorked() and other.components.workable.action ~= ACTIONS.NET and Vector3(inst.Physics:GetVelocity()):LengthSq() >= 1 and not inst:HasTag("IAMTIGER") and not inst.recentlycharged[other] then inst:DoTaskInTime(2 * FRAMES, OnDestroyOther, other) end end local function onsave(inst, data) data.istiger = inst.istigermode:value() or nil data.level = inst.level data.charge_time = inst.charge_time end local function onload(inst) if inst.istigermode:value() and not inst:HasTag("playerghost") then inst.components.inventory:Show() end inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end -------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- WERETIGER FUNCTIONS END -- -- This initializes for both the server and client. Tags can be added here. local function common_postinit(inst) inst:AddTag("birdwhisperer") inst:RemoveTag("scarytoprey") inst:AddTag("tiger") inst:AddComponent("keyhandler") --inst.components.keyhandler:AddActionListener("aikawa", TUNING.AIKAWA.KEY , "TIGER") inst.components.keyhandler:AddActionListener("aikawa", TUNING.AIKAWA.KEY2 , "POUND") inst.components.keyhandler:AddActionListener("aikawa", TUNING.AIKAWA.KEY3 , "SLEEP") inst.components.keyhandler:AddActionListener("aikawa", TUNING.AIKAWA.KEY5 , "WAKE") inst.components.keyhandler:AddActionListener("aikawa", TUNING.AIKAWA.KEY6 , "TARGETSTOLEN") inst.components.keyhandler:AddActionListener("aikawa", TUNING.AIKAWA.KEY7 , "ATTACK") inst.components.keyhandler:AddActionListener("aikawa", TUNING.AIKAWA.KEY8 , "POUNCEATTACK") inst:AddTag("tigerness") inst.GetTigerness = GetTigerness inst.onbecametiger = onbecametiger inst.onbecamepretiger = onbecamepretiger inst.istigermode = net_bool(inst.GUID, "aikawa.istigermode", "istigermodedirty") --inst:ListenForEvent("playeractivated", OnPlayerActivated) --inst:ListenForEvent("playerdeactivated", OnPlayerDeactivated) end -- This initializes for the server only. Components are added here. local function master_postinit(inst) inst.level = 0 Catzisgrow(inst) -- Stats local Light = inst.entity:AddLight() inst.Light:Enable(false) inst.Light:SetRadius(50) inst.Light:SetFalloff(.75) inst.Light:SetIntensity(.75) inst.Light:SetColour(205/255,0/255,0/255) inst.entity:SetPristine() if not TheWorld.ismastersim then inst:AddComponent("sanityaura") inst.components.sanityaura.aura = 8.3-- 8.3 inst:AddComponent("heater") inst:AddComponent("lootdropper") inst:AddComponent("damagereflect") inst.components.damagereflect:SetReflectDamageFn(CalcReflect) -------------------------------------------------------------- inst.components.heater.heat = 100 inst.components.health:StartRegen(2, 2.5) inst.components.combat:SetDefaultDamage(2) inst.components.hunger.hungerrate = 0.8 * TUNING.WILSON_HUNGER_RATE inst.components.sanity.rate_modifier = 1 inst.components.sanity.night_drain_mult = 1.2 inst.components.sanity.neg_aura_mult = 0 inst.components.temperature.maxtemp = 50 inst.components.temperature.mintemp = 20 inst.components.combat.damagemultiplier = 2 inst.components.health.fire_damage_scale = 1 --inst.components.sanity.dapperness = 1 SetStandState(inst, "quad")--SetStandState(inst, "BI") inst.SetStandState = SetStandState inst.IsStandState = IsStandState inst.num_good_food_eaten = 0 inst.num_food_cherrypicked = 0 -- Custom Sound inst.soundsname = "willow" inst._getstatus = nil -- WERETIGER -- inst:AddComponent("tigerness") inst.components.tigerness.makeperson = onbecameaikawa inst.components.tigerness.maketiger = onbecametiger inst.components.tigerness.makepretiger = onbecamepretiger onbecameaikawa(inst) onbecamepretiger(inst) onbecametiger(inst) inst.components.eater:SetOnEatFn(onaikawaeat) inst:WatchWorldState("isfullmoon" , OnIsFullmoon) OnIsFullmoon(inst, TheWorld.state.isfullmoon) -- WERETIGER END -- inst.OnLoad = onload inst.OnPreLoad = onpreload inst.OnNewSpawn = onload inst.OnSave = onsave return inst end end return MakePlayerCharacter("aikawa", prefabs, assets, common_postinit, master_postinit , start_inv) My Full Files : aikawa.lua , Aika_Test.rar Edited January 5, 2019 by Yagenius Thanks to Ultroman and YakumoYukari for they Kindness Link to comment Share on other sites More sharing options...
Ultroman Posted January 2, 2019 Share Posted January 2, 2019 I think you bit off a bit too much on this one. This is a huuuge mod! First thing: Why do you call all of these on lines 1342-1344, when you've just hooked your tigerness-component up to them, which supposedly controls when the character becomes a tiger? onbecameaikawa(inst) onbecamepretiger(inst) onbecametiger(inst) Bonus: You also declare two variables on lines 1262 and 1263, and set them to point to onbecametiger and onbecamepretiger, but you never use them anywhere. Second thing: In your SetTigerMode(inst, istiger), you almost do exactly the same things whether istiger is true or false. The only difference is, whether inst.CanExamine is set to nil or an actual value. Third thing: All your errors seem to stem from your character not having an inventory component available to the replica. Double-check how this can be. All the errors you've posted, try to do something like self.inst.replica.inventory and your character's replica (client version) doesn't have one, for whatever reason. Link to comment Share on other sites More sharing options...
Yagenius Posted January 3, 2019 Author Share Posted January 3, 2019 ♥♥♥♥ Thank you for your reply !!! ♥♥♥♥ 4 hours ago, Ultroman said: I think you bit off a bit too much on this one. This is a huuuge mod! < omg .. I'm feel bad for making this trouble , i'm sorry D'X > I just want him to has LvL + Custom Food and Transforming skill.. , I'm so sorry I don't know How big It is--.. 4 hours ago, Ultroman said: First thing: Why do you call all of these on lines 1342-1344, when you've just hooked your tigerness-component up to them, which supposedly controls when the character becomes a tiger? onbecameaikawa(inst) onbecamepretiger(inst) onbecametiger(inst) I just want to fixed the Inventory error by put them in the MasterPosinit. ( Maybe just maybe it will fixed them. X'D ) 4 hours ago, Ultroman said: Bonus: You also declare two variables on lines 1262 and 1263, and set them to point to onbecametiger and onbecamepretiger, but you never use them anywhere. Oh.. Those Two Fn is on lines 558 and 701 .. Is it not declared ? Lines 558 - 699 : Spoiler local function onbecametiger(inst) if inst.sg.currentstate.name ~= "reviver_rebirth" then inst.components.skinner:HideAllClothing(inst.AnimState) inst.AnimState:SetBank("WERETIGER") inst.AnimState:SetBuild("weretiger_build") end inst.tiger = true inst.entity:AddDynamicShadow() inst.DynamicShadow:SetSize(12, 6.5) inst.Transform:SetScale(2, 2, 2, 2) inst.MiniMapEntity:SetIcon( "ai_tiger.tex" ) inst.components.eater:SetDiet(TIGER_DIET) inst.components.talker:IgnoreAll("becametiger") inst:AddTag("IAMTIGER") inst:RemoveTag("IAMAIKAWA") inst:RemoveTag("IAMAIGER") inst.AnimState:SetBuild("weretiger_build") inst.AnimState:SetBank("WERETIGER") inst:SetStateGraph("SGpretiger") if not TheWorld.ismastersim then ------------------------------------------------------------------------------------- inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE*2) ------------------------------------------------------------------------------------- ------------------------------------------- inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 6 inst.components.sanity.night_drain_mult = 6 inst.components.sanity.neg_aura_mult = 5 inst.components.temperature.maxtemp = 50 inst.components.temperature.mintemp = 20 --inst.components.health.fire_damage_scale = 0 inst.components.health:SetAbsorptionAmount(1000) inst.components.eater.eatwholestack = true inst.components.health:StartRegen(100 , 2.5) inst.components.combat:SetDefaultDamage(5000*5) -- 20 inst.components.combat:SetAreaDamage(10, 10) if inst.components.playercontroller ~= nil then inst.components.playercontroller:SetCanUseMap(false) end inst.components.inventory:DropEverything(true) --inst.components.sanity:SetPercent(1) --inst.components.health:SetPercent(1) --inst.components.hunger:SetPercent(1) inst.components.pinnable.canbepinned = false --inst.components.hunger:Pause() --inst.components.sanity.ignore = true inst.components.health.redirect = tigerhurt inst.components.health.redirect_percent = 5 inst:AddComponent("inspectable") if inst.components.inspectable.getstatus ~= TigerGetStatus then inst._getstatus = inst.components.inspectable.getstatus inst.components.inspectable.getstatus = TigerGetStatus end inst.CanExamine = CannotExamine inst.components.eater.strongstomach = true inst.components.eater.monsterimmune = true SetAikawaWorker(inst, true) SetTigerActions(inst, true) SetTigerSounds(inst, false) SetGroundPTags(inst, true) if not inst.istigermode:value() then inst:AddTag("IAMTIGER") inst.Network:AddUserFlag(USERFLAGS.CHARACTER_STATE_1) inst.istigermode:set(true) inst:PushEvent("tigerstart") --OnTigerModeDirty(inst) inst:DoTaskInTime(0.5, function() SetHUDState(inst) end) end inst.Light:Enable(true) inst.SoundEmitter:KillSound("eating") --inst.SoundEmitter:PlaySound("dontstarve/music/music_epicfight_winter", "danger") return inst end end local function onbecamepretiger(inst) if inst.sg.currentstate.name ~= "reviver_rebirth" then inst.components.skinner:HideAllClothing(inst.AnimState) inst.AnimState:SetBank("pretiger") inst.AnimState:SetBuild("pretiger_build") end inst.tiger = false inst.Transform:SetScale(2, 2, 2, 2) inst.components.eater:SetDiet(TIGER_DIET) inst.MiniMapEntity:SetIcon( "aikawa.tex" ) inst:AddTag("IAMAIGER") inst:RemoveTag("IAMAIKAWA") inst:RemoveTag("IAMTIGER") inst.AnimState:SetBuild("pretiger_build") inst.AnimState:SetBank("pretiger") inst:SetStateGraph("SGpretiger") ----------------------------------------------------------------------------------------- if not TheWorld.ismastersim then ------------------------------------------------------------------------------------- inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE*20) ------------------------------------------------------------------------------------- ------------------------------------------- inst.components.locomotor.walkspeed = 11 inst.components.locomotor.runspeed = 12 inst.components.sanity.night_drain_mult = 0 inst.components.sanity.neg_aura_mult = 0 inst.components.temperature.maxtemp = 50 inst.components.temperature.mintemp = 20 --inst.components.health.fire_damage_scale = 0 inst.components.health:SetAbsorptionAmount(50) inst.components.eater.eatwholestack = true inst.components.health:StartRegen(100 , 2.5) inst.components.combat:SetDefaultDamage(50*5) -- 20 inst.components.combat:SetAreaDamage(7, 7) if inst.components.playercontroller ~= nil then inst.components.playercontroller:SetCanUseMap(true) end inst.CanExamine = CannotExamine inst.components.inventory:DropEverything(true) --inst.components.sanity:SetPercent(1) --inst.components.health:SetPercent(1) --inst.components.hunger:SetPercent(1) inst.components.pinnable.canbepinned = false --inst.components.hunger:Pause() --inst.components.sanity.ignore = true inst.components.health.redirect = tigerhurt inst.components.health.redirect_percent = 5 inst.components.eater.strongstomach = true inst.components.eater.monsterimmune = true SetAikawaWorker(inst, true) SetTigerActions(inst, true) SetTigerSounds(inst, true) SetGroundPTags(inst, false) inst.Light:Enable(true) inst.SoundEmitter:KillSound("eating") --inst.SoundEmitter:PlaySound("dontstarve/music/music_epicfight_winter", "danger") return inst end end line 701 - 787 : Spoiler local function onbecamepretiger(inst) if inst.sg.currentstate.name ~= "reviver_rebirth" then inst.components.skinner:HideAllClothing(inst.AnimState) inst.AnimState:SetBank("pretiger") inst.AnimState:SetBuild("pretiger_build") end inst.tiger = false inst.Transform:SetScale(2, 2, 2, 2) inst.components.eater:SetDiet(TIGER_DIET) inst.MiniMapEntity:SetIcon( "aikawa.tex" ) inst:AddTag("IAMAIGER") inst:RemoveTag("IAMAIKAWA") inst:RemoveTag("IAMTIGER") inst.AnimState:SetBuild("pretiger_build") inst.AnimState:SetBank("pretiger") inst:SetStateGraph("SGpretiger") ----------------------------------------------------------------------------------------- if not TheWorld.ismastersim then ------------------------------------------------------------------------------------- inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE*20) ------------------------------------------------------------------------------------- ------------------------------------------- inst.components.locomotor.walkspeed = 11 inst.components.locomotor.runspeed = 12 inst.components.sanity.night_drain_mult = 0 inst.components.sanity.neg_aura_mult = 0 inst.components.temperature.maxtemp = 50 inst.components.temperature.mintemp = 20 --inst.components.health.fire_damage_scale = 0 inst.components.health:SetAbsorptionAmount(50) inst.components.eater.eatwholestack = true inst.components.health:StartRegen(100 , 2.5) inst.components.combat:SetDefaultDamage(50*5) -- 20 inst.components.combat:SetAreaDamage(7, 7) if inst.components.playercontroller ~= nil then inst.components.playercontroller:SetCanUseMap(true) end inst.CanExamine = CannotExamine inst.components.inventory:DropEverything(true) --inst.components.sanity:SetPercent(1) --inst.components.health:SetPercent(1) --inst.components.hunger:SetPercent(1) inst.components.pinnable.canbepinned = false --inst.components.hunger:Pause() --inst.components.sanity.ignore = true inst.components.health.redirect = tigerhurt inst.components.health.redirect_percent = 5 inst.components.eater.strongstomach = true inst.components.eater.monsterimmune = true SetAikawaWorker(inst, true) SetTigerActions(inst, true) SetTigerSounds(inst, true) SetGroundPTags(inst, false) inst.Light:Enable(true) inst.SoundEmitter:KillSound("eating") --inst.SoundEmitter:PlaySound("dontstarve/music/music_epicfight_winter", "danger") return inst end end ( If I misunderstood something, i'm so sorry.) 4 hours ago, Ultroman said: Second thing: In your SetTigerMode(inst, istiger), you almost do exactly the same things whether istiger is true or false. The only difference is, whether inst.CanExamine is set to nil or an actual value. Does that mean .. I need to erase one of those lines in SetTigerMode like this right ? Spoiler local function SetTigerMode(inst, istiger) if istiger then if not TheWorld.ismastersim then inst.CanExamine = inst.istigermode:value() and CannotExamine or nil onbecameaikawa(inst) SetTigerActions(inst, false) if inst.components.locomotor ~= nil then inst.components.locomotor.runspeed = 14 end end end end 5 hours ago, Ultroman said: Third thing: All your errors seem to stem from your character not having an inventory component available to the replica. Double-check how this can be. All the errors you've posted, try to do something like self.inst.replica.inventory and your character's replica (client version) doesn't have one, for whatever reason. I have checked my SGweretiger / Modmain / Tigerness Components and they never touched the inventory replica. except my aikawa.lua that has one lines about inventory. ( not a Replica ) onbecametiger , onbecamepretiger Fn. inst.components.inventory:DropEverything(true) I also tried to Disable It. And It seems it still has Inventory error. ( I have similar error about replica before :: Sanity.Replica, Health.Replica, Hunger.Replica :: I have disabled it on lines 657 - 659 and it's fixed ) Another one is my Custom Sgwilson, that has so many inventory. < I just replacing " Beaver " to " Pretiger " Tags and replacing Beaver build. > Honestly.. I really don't know how to fix the replica ... If you don't mind Could you tech me how to fix it, please? Link to comment Share on other sites More sharing options...
Ultroman Posted January 3, 2019 Share Posted January 3, 2019 (edited) I'm sorry in advance. This is going to sound a little rough, but I think you need to hear these things. I have no idea what's going on in your mod. It seems like it was thrown together by a hurricane. Fixing an error by commenting out the code generating it and forgetting about it, is not a good way to do things. I can't even begin to fathom what is going on. The one person who's supposed to know what is going on, is you. You have to know what's going on, so you can ask specific questions about how to do a specific thing. You have thousands of lines of code, giving you grief about several different things at once; the mouse/player actions, the replica, and all the things in your other threads. It would take at least a full day or two for me to properly inspect your code, to learn exactly what you're doing, and even then, it would be hard to get and retain a complete overview, in order to know which lines of code should or should not be where they are. If all of these features are giving you so much trouble when you combine them, you should stop and step back. Take the code you have now, and put it aside. Recognize that you have learned A LOT since you started. Give yourself a pat on the back. Take a deep breath...and start over. From the very beginning. It hurts, I know. "Kill your darlings" is one of the first lessons most programmers learn, and it is the toughest. Don't be afraid to throw out code. Start from scratch. Get your character moving around with your graphics. Simple stuff. Get it done in a way that's nice and neat code-wise. Put in comments for things that are out of the ordinary for your mod, so you can see later why you put that code there (remember, assume that the person reading the comments is not yourself...since you will be asking for help, other people need to know why your code is made the way it is made, especially when you're doing complicated stuff, like you are). Now that you have the basics, take one feature and implement it fully. Don't just take the code from your old project. Rethink every step. Remember, you've learned since last time. You're better this time. You can steal code from your old version, but rethink the structure all the way through. Whenever you think "oh, I might as well just copy all of this over as well...", stop yourself. Get each and every little thing working by itself first. Don't go for "the big bang" where everything works at the same time. E.g. if you're implementing the transformation, instead of doing everything at once, implement the trigger first, and simply print() to the log that the transformation happened, and set a bool or something. Then make sure that it works for doing the transformation backwards. This way you'll be completely sure that that part works as intended. Test it on servers with and without caves. When you're sure it works, take another little piece, and implement and test that. At some point, you'll see that you run into the problem you have now, and since it can ONLY be the fault of the code you've JUST done, since you tested everything else, you will have a much easier time figuring out where the problem is, and you can ask questions much better, because you can tell us exactly what you were trying to do, when you ran into the problem. I'm sorry, but it's just too big for me to spend my spare time on. I will gladly help with bits and pieces, but I will not consult on full projects, especially not when they're huge, and the creator cannot help narrow down the area from which the errors are coming. I really hope you fix the problems, because the mod sounds super awesome! Good luck with everything. Don't give up! Edited January 3, 2019 by Ultroman Link to comment Share on other sites More sharing options...
YakumoYukari Posted January 3, 2019 Share Posted January 3, 2019 Seems you have exceeded the entity tags size limit. In DST, an entity's tags must not have more than 31 tags. If exceeds, the client will fail to deserialize data from the server and cause crashes just like yours. Tags are the fastest method to identify something that will be synced to the client easily. As you can see the game code, tags are used in 'Optimization' because it's the fastest. But therefore, It is used in many cases especially the player prefab. Even vanilla Wilson has 19 tags by default. If you simply abuse tags, this will be exceeded really quick. Debug tags by entity:GetDebugString() i.e) print(ThePlayer.entity:GetDebugString()) Try to remove some tags that aren't necessary. Basically, tags are recommended to use in these cases in DST: 1) To check when you want to identify a certain type of prefabs(that is in a certain state) really quickly. 2) To find entities with filters. (See simutil for more information) 3) To filter actions or recipes condition which should be synced with the client. 4) To function the entity by tag(like "umbrella", "fastbuilder" things) that is already well(or hard)-coded in the game. Since Klei doesn't want to update tags size, you should always be aware of this issue. If you have to add tags inevitably, try to make custom classified and attach netvars into it.https://github.com/HimekaidouHatate/YakumoYukari-DST This is a good example(which is my mod :P) of using netvars attached to a custom classified. I didn't write that much explanation overall but PM me if you have something that is unable to implement just with my mod. GL with modding Link to comment Share on other sites More sharing options...
Yagenius Posted January 4, 2019 Author Share Posted January 4, 2019 @YakumoYukari @Ultroman ♥♥♥ OMG !! THANK YOU VERY MUCH FOR YOUR KINDNESS !! ♥♥♥ @YakumoYukari Ummm.... Too many Size limit Tags? Okay , I have tried to checked my Tags today. ( I have 17 - 18 Tags. ) BTW , I don't know really how this game counts the Tags. :'D Link to comment Share on other sites More sharing options...
Ultroman Posted January 4, 2019 Share Posted January 4, 2019 (edited) Did you do what YakumoYukari said? Put in print(ThePlayer.entity:GetDebugString()) at the bottom of your initialization function for your character, and possibly also at the bottom of some of the functions you have which add tags. Then play and trigger those functions, and check your logs. You should find your prints in there, where it lists a lot of stuff about the player, including the tags it has. Count those. What do you mean you have 17-18 tags? Is that the number of custom tags you use for your character? If so, as he said, vanilla Wilson has 19 tags, and 31 is the limit. Players have a bunch of tags inherently, so you might be over that limit. If you're not over the limit, then I'm not sure what's wrong. Edited January 4, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Yagenius Posted January 4, 2019 Author Share Posted January 4, 2019 [00:25:08]: Serializing user: session/39521E4CC0FA031E/C7GSC53084I801G0653I8O8/0000000001 [00:25:17]: SendRemoteExecute(print(ThePlayer.entity:GetDebugString()), 391.301605, -686.893982) [00:25:21]: GUID:100560 Name: Tags: tiger _sheltered birdwhisperer trader _health FROMNUM FROMNUM player idle _builder _sanity _inventory FROMNUM FROMNUM _combat FROMNUM _moisture FROMNUM FROMNUM debuffable FROMNUM _hunger _rider character lightningtarget tigerness Prefab: aikawa AnimState: bank: wilson build: aikawa anim: idle_loop anim/player_idles.zip:idle_loop Frame: 34.00/66 Facing: 3 Transform: Pos=(386.00,0.00,-686.00) Scale=(1.20,1.20,1.20) Heading=0.00 DynamicShadow: Network: NetworkID=4748 Owner=6903582000048810625 NetSleep=0000000000000000000000000000000000000000000000000000000000000000 LightWatcher: IN LIGHT: 19.10-->1.48/0.08 Light: MiniMapEntity: Physics: Collision Group: 1024 Mask: 64,128, (ACTIVE) Vel: 0.00 SoundEmitter: Yes I do , as YakumoYukari said. If I including the FROMNUM Tags Things , It will has around 26 Tags. and .. It doesn't seems like over 31 limit. or Did i miss something? Link to comment Share on other sites More sharing options...
Ultroman Posted January 4, 2019 Share Posted January 4, 2019 Well, then it's probably not that. With all the stuff you have going on, there must be something missing, that messes up the client's replica...or something that makes it look like that. I have no idea. I would start over, and go slowly, piece by piece. Link to comment Share on other sites More sharing options...
YakumoYukari Posted January 4, 2019 Share Posted January 4, 2019 (edited) You can count tags with that method. (Actually, you can just count by your eyes though :p) But, seems your case is odd. multiple same tags have existed which should not. I assume that's because of the uppercase..? or not. I don't have any clues where FROMNUM is coming from unless I see your full code. Edited January 4, 2019 by YakumoYukari Link to comment Share on other sites More sharing options...
Yagenius Posted January 5, 2019 Author Share Posted January 5, 2019 (edited) !! WOAH--- !! The problem of FROMNUM , is really the UPPERCASE !!! Thank you !! BTW , I still have one of FRONUM Tags , when I trying to Trigger other form. :: I have change all of my Uppercase tags to lowercase and I'm not sure now why I still getting this FRONUM. X''D :: : Tags result : Trigger first form : Spoiler [00:04:44]: GUID:101325 Name: Tags: tiger VEGGIE_eater _sheltered birdwhisperer trader _health inspectable FROMNUM freezable player RAW_eater idle _builder _sanity _inventory HASHEATER HORRIBLE_eater iamaiger _combat MEAT_eater locomotor _moisture nolight debuffable waterproofer _hunger _rider character lightningtarget tigerness Prefab: aikawa AnimState: bank: FROMNUM build: pretiger_build anim: idle_loop ../mods/Aika_Test/anim/pretiger_build.zip:idle_loop Frame: 157.33/29 Facing: 3 : Tags result : Trigger second form : Spoiler [00:05:43]: GUID:101325 Name: Tags: tiger VEGGIE_eater _sheltered birdwhisperer trader _health inspectable FROMNUM freezable player RAW_eater ignoretalking idle _builder _sanity _inventory HASHEATER HORRIBLE_eater _combat MEAT_eater locomotor IAMTIGER _moisture nolight debuffable waterproofer _hunger _rider character lightningtarget tigerness Prefab: aikawa AnimState: bank: FROMNUM build: weretiger_build anim: idle_loop ../mods/Aika_Test/anim/weretiger_build.zip:idle_loop Frame: 225.33/85 Facing: 3 : Tags result : back to hoomane form : Spoiler [00:06:57]: GUID:101325 Name: Tags: busy tiger _sheltered birdwhisperer trader _health inspectable freezable nopredict player ignoretalking _builder _sanity _inventory HASHEATER iamaikawa _combat locomotor _moisture OMNI_eater nolight debuffable waterproofer sleeping _hunger _rider character lightningtarget tigerness Prefab: aikawa AnimState: bank: wilson build: aikawa anim: sleep_loop anim/player_knockedout.zip:sleep_loop Frame: 26.00/59 Facing: 3 The result is I's not crash anymore!!!! !!! OMGGGGGGGGG !!!! ♥♥ !!!! You are the life savior !!!! ♥♥ !! ♥ Thank you Thank you very very much ♥ !! oh... umm.. I have a little problem with some animations invisible, I known I didn't have some of those animations for player. If you don't mind could you tell me how to add the Custom animations , ( for my mod only but other player can see it. ) or disable some actions for my First and Second form? ( I don't want to use player actions when in other form. ) FULL LASTEST FILE : Aika_Test.rar Edited January 5, 2019 by Yagenius Forgot to save SG file Link to comment Share on other sites More sharing options...
YakumoYukari Posted January 5, 2019 Share Posted January 5, 2019 I haven't really tried to add custom animations but you can follow this thread. FROMNUM is.. I don't know. my character also has one. But I don't know what that exactly do. If you want to make preventing-action in a specific situation, look for ACTION fn you want to change. Link to comment 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