Sqweepsss Posted June 24, 2019 Share Posted June 24, 2019 I had started work on a character mod, I managed to get it to work and stuff how I wanted but then I tried making a custom item via following a tutorial and now whenever I start a world with the character enabled the game crashes with this error: Spoiler [string "scripts/prefabs/player_common.lua"]:1281: bad argument #1 to 'ipairs' (table expected, got function) LUA ERROR stack traceback: =[C] in function 'ipairs' scripts/prefabs/player_common.lua(1281,1) =(tail call) ? scripts/mainfunctions.lua(153,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(600,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(277,1) in function 'LoadAssets' scripts/gamelogic.lua(860,1) in function 'cb' scripts/saveindex.lua(285,1) This is the item's lua: Spoiler local assets = { Asset("ANIM", "anim/REBOUND.zip"), Asset("ATLAS", "images/inventoryimages/REBOUND.xml") } local function OnFinished(inst) inst.AnimState:PlayAnimation("used") inst:ListenForEvent("animover", inst.Remove) end local function OnEquip(inst, owner) local skin_build = inst:GetSkinBuild() if skin_build ~= nil then owner:PushEvent("equipskinneditem", inst:GetSkinName()) owner.AnimState:OverrideItemSkinSymbol("swap_object", skin_build, "swap_REBOUND", inst.GUID, "swap_REBOUND") else owner.AnimState:OverrideSymbol("swap_object", "swap_REBOUND", "swap_REBOUND") end owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function OnDropped(inst) inst.AnimState:PlayAnimation("idle") end local function OnUnequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") local skin_build = inst:GetSkinBuild() if skin_build ~= nil then owner:PushEvent("unequipskinneditem", inst:GetSkinName()) end end local function OnThrown(inst, owner, target) if target ~= owner then owner.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_throw") end inst.AnimState:PlayAnimation("spin_loop", true) end local function OnCaught(inst, catcher) if catcher ~= nil and catcher.components.inventory ~= nil and catcher.components.inventory.isopen then if inst.components.equippable ~= nil and not catcher.components.inventory:GetEquippedItem(inst.components.equippable.equipslot) then catcher.components.inventory:Equip(inst) else catcher.components.inventory:GiveItem(inst) end catcher:PushEvent("catch") end end local function ReturnToOwner(inst, owner) if owner ~= nil and not (inst.components.finiteuses ~= nil and inst.components.finiteuses:GetUses() < 1) then owner.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_return") inst.components.projectile:Throw(owner, owner) end end local function OnHit(inst, owner, target) if owner == target or owner:HasTag("playerghost") then OnDropped(inst) else ReturnToOwner(inst, owner) end if target ~= nil and target:IsValid() then local impactfx = SpawnPrefab("impact") if impactfx ~= nil then local follower = impactfx.entity:AddFollower() follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0) impactfx:FacePoint(inst.Transform:GetWorldPosition()) end end end local function OnMiss(inst, owner, target) if owner == target then OnDropped(inst) else ReturnToOwner(inst, owner) end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) RemovePhysicsColliders(inst) inst.AnimState:SetBank("boomerang") inst.AnimState:SetBuild("boomerang") inst.AnimState:PlayAnimation("idle") inst.AnimState:SetRayTestOnBB(true) inst:AddTag("thrown") --weapon (from weapon component) added to pristine state for optimization inst:AddTag("weapon") --projectile (from projectile component) added to pristine state for optimization inst:AddTag("projectile") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("weapon") inst.components.weapon:SetDamage(TUNING.BOOMERANG_DAMAGE-2) inst.components.weapon:SetRange(TUNING.BOOMERANG_DISTANCE, TUNING.BOOMERANG_DISTANCE+2) ------- inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(TUNING.BOOMERANG_USES+20) inst.components.finiteuses:SetUses(TUNING.BOOMERANG_USES+20) inst.components.finiteuses:SetOnFinished(OnFinished) inst:AddComponent("inspectable") inst:AddComponent("projectile") inst.components.projectile:SetSpeed(11) inst.components.projectile:SetCanCatch(true) inst.components.projectile:SetOnThrownFn(OnThrown) inst.components.projectile:SetOnHitFn(OnHit) inst.components.projectile:SetOnMissFn(OnMiss) inst.components.projectile:SetOnCaughtFn(OnCaught) inst:AddComponent("inventoryitem") inst.components.inventoryitem:SetOnDroppedFn(OnDropped) inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) MakeHauntableLaunch(inst) return inst end inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/rebound.xml" return Prefab("rebound", fn, assets) This is the character's lua" Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting inventory local start_inv = {"lantern","panflute","rebounderang",}local fn = function(inst) end -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when not a ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "liam_speed_mod", 1.05) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "liam_speed_mod") end -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "liam.tex" ) end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aura = TUNING.SANITYAURA_TINY inst.components.temperature.hurtrate = 2.5 inst.components.sanity.neg_aura_mult = 0 if inst.components.freezable then -- Makes you never freeze. inst:RemoveComponent("freezable") end -- choose which sounds this character will play inst.soundsname = "maxwell" -- 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(250) inst.components.sanity:SetMax(80) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1.4 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1.3 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("liam", nil, prefabs, assets, fn, common_postinit, master_postinit, start_inv) I'm really new to modding and have no understanding of what is going wrong with it and I need someone's help... Link to comment Share on other sites More sharing options...
Ultroman Posted June 25, 2019 Share Posted June 25, 2019 You have accidentally copy/pasted something into the wrong place. Look at your character's LUA near the top where it says: -- Custom starting inventory local start_inv = {"lantern","panflute","rebounderang",}local fn = function(inst) end That should just be: -- Custom starting inventory local start_inv = {"lantern", "panflute", "rebounderang",} Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 25, 2019 Author Share Posted June 25, 2019 3 minutes ago, Ultroman said: You have accidentally copy/pasted something into the wrong place. Look at your character's LUA near the top where it says: -- Custom starting inventory local start_inv = {"lantern","panflute","rebounderang",}local fn = function(inst) end That should just be: -- Custom starting inventory local start_inv = {"lantern", "panflute", "rebounderang",} Ok I managed to fix the problem that it was having thanks to you! Thank you! but... now their's a new error message... Spoiler [00:01:03]: [string "../mods/liam/scripts/prefabs/liam.lua"]:71: variable 'fn' is not declared LUA ERROR stack traceback: =[C] in function 'error' scripts/strict.lua(23,1) ../mods/liam/scripts/prefabs/liam.lua(71,1) in function 'fn' scripts/mainfunctions.lua(153,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(600,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(277,1) in function 'LoadAssets' scripts/gamelogic.lua(860,1) in function 'cb' scripts/saveindex.lua(285,1) ... =[C] in function 'GetPersistentString' scripts/saveindex.lua(250,1) in function 'Load' scripts/gamelogic.lua(1066,1) in function 'callback' scripts/playerprofile.lua(966,1) in function 'Set' scripts/playerprofile.lua(821,1) =[C] in function 'GetPersistentString' scripts/playerprofile.lua(819,1) in function 'Load' scripts/gamelogic.lua(1065,1) in main chunk =[C] in function 'require' scripts/mainfunctions.lua(925,1) [00:01:03]: [string "../mods/liam/scripts/prefabs/liam.lua"]:71: variable 'fn' is not declared LUA ERROR stack traceback: =[C] in function 'error' scripts/strict.lua(23,1) ../mods/liam/scripts/prefabs/liam.lua(71,1) in function 'fn' scripts/mainfunctions.lua(153,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(600,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(277,1) in function 'LoadAssets' scripts/gamelogic.lua(860,1) in function 'cb' scripts/saveindex.lua(285,1) ... =[C] in function 'GetPersistentString' scripts/saveindex.lua(250,1) in function 'Load' scripts/gamelogic.lua(1066,1) in function 'callback' scripts/playerprofile.lua(966,1) in function 'Set' scripts/playerprofile.lua(821,1) =[C] in function 'GetPersistentString' scripts/playerprofile.lua(819,1) in function 'Load' scripts/gamelogic.lua(1065,1) in main chunk =[C] in function 'require' scripts/mainfunctions.lua(925,1) o.o and I have no clue what is causing it this time... something to do with my prefab files? Link to comment Share on other sites More sharing options...
Ultroman Posted June 25, 2019 Share Posted June 25, 2019 You are welcome I will need to see your liam.lua file to help you any further. Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 25, 2019 Author Share Posted June 25, 2019 1 Just now, Ultroman said: You are welcome I will need to see your liam.lua file to help you any further. Here's the liam lua and the rebound lua just in case rebound.lua liam.lua Link to comment Share on other sites More sharing options...
Ultroman Posted June 25, 2019 Share Posted June 25, 2019 (edited) Go to your liam.lua and at the very bottom, change this: return MakePlayerCharacter("liam", nil, prefabs, assets, fn, common_postinit, master_postinit, start_inv) to this: return MakePlayerCharacter("liam", prefabs, assets, common_postinit, master_postinit, start_inv) I think you ended up merging the two MakePlayerCharacter functions from DS and DST respectively. Edited June 25, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 25, 2019 Author Share Posted June 25, 2019 Just now, Ultroman said: Go to your liam.lua and at the very bottom, change this: return MakePlayerCharacter("liam", nil, prefabs, assets, fn, common_postinit, master_postinit, start_inv) to this: return MakePlayerCharacter("liam", prefabs, assets, common_postinit, master_postinit, start_inv) Ok... now it is giving me an error that has to do with my rebound prefab... Spoiler [string "../mods/liam/scripts/prefabs/rebound.lua"]:148: variable 'inst' is not declared LUA ERROR stack traceback: =[C] in function 'error' scripts/strict.lua(23,1) ../mods/liam/scripts/prefabs/rebound.lua(148,1) in function 'fn' scripts/mainfunctions.lua(153,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(600,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(277,1) in function 'LoadAssets' scripts/gamelogic.lua(860,1) in function 'cb' scripts/saveindex.lua(285,1) ... =[C] in function 'GetPersistentString' scripts/saveindex.lua(250,1) in function 'Load' scripts/gamelogic.lua(1066,1) in function 'callback' scripts/playerprofile.lua(966,1) in function 'Set' scripts/playerprofile.lua(821,1) =[C] in function 'GetPersistentString' scripts/playerprofile.lua(819,1) in function 'Load' scripts/gamelogic.lua(1065,1) in main chunk =[C] in function 'require' scripts/mainfunctions.lua(925,1) How do yall just like almost instantly know what line of code the problem lies in... Link to comment Share on other sites More sharing options...
Ultroman Posted June 25, 2019 Share Posted June 25, 2019 (edited) 1 hour ago, Sqweepsss said: How do yall just like almost instantly know what line of code the problem lies in... Do we have a Texan in the house? Jokes aside, it actually tells you exactly which line of code is creating the problem, and the whole call-stack. The call-stack is the series of function calls that led to where the error was encountered. Let's take the example from before. [00:01:03]: [string "../mods/liam/scripts/prefabs/liam.lua"]:71: variable 'fn' is not declared LUA ERROR stack traceback: =[C] in function 'error' scripts/strict.lua(23,1) ../mods/liam/scripts/prefabs/liam.lua(71,1) in function 'fn' scripts/mainfunctions.lua(153,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(600,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(277,1) in function 'LoadAssets' scripts/gamelogic.lua(860,1) in function 'cb' scripts/saveindex.lua(285,1) It's in reverse order, so the calls actually start from the bottom, but we're mostly interested in where the error occurred. On the first line it tells your the file where the error was encountered ("../mods/liam/scripts/prefabs/liam.lua"), and the line number (71) (you can see the line numbers in your file, if you're using Notepad++ or similar). In this case, it tells us it cannot find a variable called fn. Then I went and looked at your code, searched for fn in it, and found it in your last line there and NOWHERE ELSE. Any variable you use has to come from somewhere, and this one was nowhere to be found. I then studied your line, and it had both the fn, master_postinit and common_postinit parameters. The first is usually used for prefabs, while the latter two are used for player characters. I also didn't remember ever seeing "nil" as the second parameter, so something was wrong. Then I opened the code of another character, and checked its corresponding line, and it was very different. Fix found! Here's your other problem. You added two lines OUTSIDE your fn function (notice that since we're working in an item and not a player, we are now using the "fn" nomenclature, instead of the paired common_postinit and master_postinit functions which are used for players. Technically, you can name them whatever you like, but for consistency and easier reading for other modders, it's nice to keep a recognizable structure and nomenclature. Anyway, you may not even need the atlasname-line, but if you need it, it needs to go where the empty red box is, and the other line you have above it (which I have crossed out) should be removed. Edited June 25, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 25, 2019 Author Share Posted June 25, 2019 6 7 minutes ago, Ultroman said: Do we have a Texan in the house? Jokes aside, it actually tells you exactly which line of code is creating the problem, and the whole call-stack. The call-stack is the series of function calls that led to where the error was encountered. Let's take the example from before. 12 minutes ago, Ultroman said: [00:01:03]: [string "../mods/liam/scripts/prefabs/liam.lua"]:71: variable 'fn' is not declared LUA ERROR stack traceback: =[C] in function 'error' scripts/strict.lua(23,1) ../mods/liam/scripts/prefabs/liam.lua(71,1) in function 'fn' scripts/mainfunctions.lua(153,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(600,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(277,1) in function 'LoadAssets' scripts/gamelogic.lua(860,1) in function 'cb' scripts/saveindex.lua(285,1) It's in reverse order, so the calls actually start from the bottom, but we're mostly interested in where the error occurred. On the first line it tells your the file where the error was encountered, and the line number (you can see those in your file, if you're using Notepad++ or similar). In this case, it tells us it cannot find a variable called fn. Then I went and looked at your code, searched for fn in it, and found it in your last line there and NOWHERE ELSE. Any variable you use has to come from somewhere, and this one was nowhere to be found. I then studied your line, and it had both the fn, master_postinit and common_postinit parameters. The first is usually used for prefabs, while the latter two are used for player characters. I also didn't remember ever seeing "nil" as the second parameter, so something was wrong. Then I opened the code of another character, and checked its corresponding line, and it was very different. Fix found! Here's your other problem. You added two lines OUTSIDE your fn function (notice that since we're working in an item and not a player, we are now using the "fn" nomenclature, instead of the paired common_postinit and master_postinit functions which are used for players. Technically, you can name them whatever you like, but for consistency and easier reading for other modders, it's nice to keep a recognizable structure and nomenclature. Anyway, you may not even need the atlasname-line, but if you need it, it needs to go where the empty red box is, and the other line you have above it (which I have crossed out) should be removed. Thank you id never be able to figure that out lol. But there is a new error and I think it might be that I don't have a correct file path set up... but im gonna try and fix this one on my own cause I think I can have a crack at it! (If not expect me to be back here in a few minutes... lol) but could you go more into depth when you said: 3 10 minutes ago, Ultroman said: It's in reverse order, so the calls actually start from the bottom, but we're mostly interested in where the error occurred. On the first line it tells your the file where the error was encountered, and the line number (you can see those in your file, if you're using Notepad++ or similar). In this case, it tells us it cannot find a variable called fn. Then I went and looked at your code, searched for fn in it, and found it in your last line there and NOWHERE ELSE. Any variable you use has to come from somewhere, and this one was nowhere to be found. I then studied your line, and it had both the fn, master_postinit and common_postinit parameters. The first is usually used for prefabs, while the latter two are used for player characters. I also didn't remember ever seeing "nil" as the second parameter, so something was wrong. Then I opened the code of another character, and checked its corresponding line, and it was very different. Fix found! Because trust me, I read it, but did I fully understand it: nope. uhhmmm what happened to my post why is there such a big space at the start... o.o Ok... So I Altered This Line in my Rebound Lua local assets = Spoiler { Asset("ANIM", "anim/REBOUND.zip"), Asset("ATLAS", "images/inventoryimages/REBOUND.xml") } To: Spoiler local assets = { Asset("ANIM", "anim/rebounderang_build.zip"), Asset("ATLAS", "images/inventoryimages/REBOUND.xml") } Because I thought that was what I needed to do... But now the game just shuts down when I try entering a world with the mod enabled... Here's what I could find in the log: Spoiler [00:00:46]: Could not preload undefined prefab (rebounderang) [00:00:46]: LOAD BE [00:00:48]: ..\source\animlib\animmanager.cpp(504) :: Tried to add build [boomerang] from file [anim/boomerang.zip] but we've already added a build with that name! Any clues as to what I did wrong..? Am I like... missing a file I'm supposed to have or something... cause that's all I can come up with... Link to comment Share on other sites More sharing options...
Ultroman Posted June 25, 2019 Share Posted June 25, 2019 I have no idea about your file structure. I would need a zip of your mod to help you with these things. The assets are...your assets, as in animations and images you've created for your character and item. To reference (point to) which files to use, we use what's called "relative path", so the given file-path, e.g., "anim/rebounderang_build.zip", is you telling the game "Please use the file called 'rebounderang_build.zip' in the folder 'anim' in my mod-folder." That you only give it the path relative to your mod-folder, is why we call it a relative path. If it worked before you changed the file-path of your reference, then it's because you are now referencing files that are no longer there or have the wrong name. Also, these paths and filenames are CASE-SENSITIVE! So, for a file named "REBOUND.zip" a reference like "anim/rebound.zip" will not work. I can clarify my description of the call-stack, if you tell me at which point I lost you It might be easier if you remember that this is not a multi-threaded game. Everything runs in a loop, one function call after the other, one line after the other. When one function ends, the function that called it continues, and when that function ends the function that called it continues, etc. So, the call-stack is just the game taking a few steps back in time, telling you where it came from. Sort of how crime scene investigators investigate, e.g., a solo-accident in a car. The car crashed...what caused that crash? Is it that it hit the tree? No, it hit the tree, because it slid off the road. By why did it slip off the road? It slid off the road, because someone had spilled oil all over the road. (This is where the example should stop, because I think you get it by now, but this is so perfect a setup for a description of the life of a programmer, that I can't help myself). So you're saying there was actually nothing wrong with the car or the driver? Well, where's the problem, then? Who knows? Let's see if we can dig through the logs and find out where that oil spill came from. Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 25, 2019 Author Share Posted June 25, 2019 ... I think I'm just going to make a copy of the mod and make the current version without the Rebounderang... because I am too tired to get it to work, But hey At least you managed to help me fix my formatting errors, I'll post in here if I ever manage to get the rebounder to work... Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 25, 2019 Author Share Posted June 25, 2019 Ok This is officially the area im going to just ask for help with my mod... because I need a lot of it... Basically my problem right now is that im TRYING to introduce a new crafting tab, with new recipes for already existing items... just for the character... The mod doesn't crash at all... but the tab is nowhere to be seen... Here's the Lua with the new stuff for the recipes: Spoiler PrefabFiles = { "liam", "liam_none", } Assets = { Asset( "IMAGE", "images/saveslot_portraits/liam.tex" ), Asset( "ATLAS", "images/saveslot_portraits/liam.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/liam.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/liam.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/liam_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/liam_silho.xml" ), Asset( "IMAGE", "bigportraits/liam.tex" ), Asset( "ATLAS", "bigportraits/liam.xml" ), Asset( "IMAGE", "images/map_icons/liam.tex" ), Asset( "ATLAS", "images/map_icons/liam.xml" ), Asset( "IMAGE", "images/avatars/avatar_liam.tex" ), Asset( "ATLAS", "images/avatars/avatar_liam.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_liam.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_liam.xml" ), Asset( "IMAGE", "images/avatars/self_inspect_liam.tex" ), Asset( "ATLAS", "images/avatars/self_inspect_liam.xml" ), Asset( "IMAGE", "images/names_liam.tex" ), Asset( "ATLAS", "images/names_liam.xml" ), Asset( "IMAGE", "images/names_gold_liam.tex" ), Asset( "ATLAS", "images/names_gold_liam.xml" ), Asset( "IMAGE", "bigportraits/liam_none.tex" ), Asset( "ATLAS", "bigportraits/liam_none.xml" ), Asset( "ATLAS", "images/inventoryimages/bluerprint.xml" ), Asset( "IMAGE", "images/inventoryimages/bluerprint.tex" ), } AddMinimapAtlas("images/map_icons/liam.xml") local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS -- The character select screen lines STRINGS.CHARACTER_TITLES.liam = "The Eveready" STRINGS.CHARACTER_NAMES.liam = "Liam" STRINGS.CHARACTER_DESCRIPTIONS.liam = "*Perk 1\n*Perk 2\n*Perk 3" STRINGS.CHARACTER_QUOTES.liam = "\"I'm ready! I think...\"" -- Custom speech strings STRINGS.CHARACTERS.LIAM = require "speech_liam" -- The character's name as appears in-game STRINGS.NAMES.LIAM = "Esc" -- adds custom build tab local sort_key = 99 local prepared_tab = AddRecipeTab( "Preparation", -- Display Name. sort_key, -- Sort Key. "images/inventoryimages/bluerprint.xml", -- Atlas File. "bluerprint.tex", -- Icon File. "liam" -- Builder Tag. ) ----START RECIPES ADD AddRecipe("lantern", { Ingredient("cutgrass", 3), Ingredient("cutreeds", 3), Ingredient("lightbulb", 1) }, prepared_tab) -- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL. AddModCharacter("liam", "MALE") -- Positive sanity aura for frog ponds. function AddSanityAura(inst) inst:AddComponent("sanityaura") --inst.components.sanityaura.aura = -TUNING.SANITYAURA_LARGE inst.components.sanityaura.aura = TUNING.SANITYAURA_LARGE --AddPrefabPostInit("researchlab", AddSanityAura) --print("TEST 3") end AddPrefabPostInit("pond", AddSanityAura) AddPrefabPostInit("pond_mos", AddSanityAura) AddPrefabPostInit("pond_cave", AddSanityAura) Any idea what I am doing Wrong? Link to comment Share on other sites More sharing options...
Ultroman Posted June 25, 2019 Share Posted June 25, 2019 (edited) I get the infatuation people have for custom crafting tabs, but IMO they're overrated. Mostly because they can block or be blocked by the other crafting tabs fighting for the bottom slot. But you do you Just mentioning it, in case you're testing in a situation where your tab is being blocked by, e.g., Sculpting Table, Rock Den, Mad Scientist Lab, etc. In order for the crafting tab to only be available to your character, you have to put the code for it into the character's master_postinit function. For making the recipes character-specific, take a look here, and make sure to look at the DST version). And you can't create duplicate recipes that way. Making a new recipe with the same name (the first parameter) as an existing recipe, removes the original recipe. Here's the code for creating duplicate recipes (look at the "spoiler" at the bottom of that post). The way you've done your sanity auras make the aura work for everyone in the game, since they're put on the ponds instead of on the character. You can use this code to do what you want. Just replace "bee" with "watersource", and then add a check within the for-loop (which runs over all the found entities) for whether the prefab name of the entity starts with "pond". if str:sub(1, 4) == "pond" then Like this: -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- I have set the radius to be 10. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, 10, {"watersource"}, {"player","INLIMBO","FX","DECOR"}, nil) for i,v in ipairs(ents) do if str:sub(1, 4) == "pond" then inst.components.sanity.DoDelta(TUNING.SANITYAURA_LARGE, true) return end end end) Edited June 25, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 26, 2019 Author Share Posted June 26, 2019 21 hours ago, Ultroman said: if str:sub(1, 4) == "pond" then Like this: -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- I have set the radius to be 10. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, 10, {"watersource"}, {"player","INLIMBO","FX","DECOR"}, nil) for i,v in ipairs(ents) do if str:sub(1, 4) == "pond" then inst.components.sanity.DoDelta(TUNING.SANITYAURA_LARGE, true) return end end end) this line of the code keeps giving me an error on the first part saying "inst is not declared" inst:DoPeriodicTask(1.0, function(inst) IT HAPPENED AGAIN WITH THE LOG MESSAGE long* Spoiler [string "../mods/liam/scripts/prefabs/liam.lua"]:43: variable 'inst' is not declared LUA ERROR stack traceback: =[C] in function 'error' scripts/strict.lua(23,1) ../mods/liam/scripts/prefabs/liam.lua(43,1) in function 'fn' scripts/mainfunctions.lua(153,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(600,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(277,1) in function 'LoadAssets' scripts/gamelogic.lua(860,1) in function 'cb' scripts/saveindex.lua(285,1) ... Error btw ^^^ Link to comment Share on other sites More sharing options...
Ultroman Posted June 26, 2019 Share Posted June 26, 2019 Show me your whole file or a zip of your mod. You must have pasted the code into the wrong place. Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 26, 2019 Author Share Posted June 26, 2019 Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting inventory local start_inv = {"panflute", "boomerang", "lightbulb", "lightbulb", "lantern_blueprint", "panflute_blueprint", "boomerang_blueprint", "fishingrod_blueprint", "backpack_blueprint", "armorwood_blueprint",} -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when not a ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "liam_speed_mod", 1.05) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "liam_speed_mod") end -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "liam.tex" ) end -- This initializes for the server only. Components are added here. -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- I have set the radius to be 10. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, 10, {"watersource"}, {"player","INLIMBO","FX","DECOR"}, nil) for i,v in ipairs(ents) do if str:sub(1, 4) == "pond" then inst.components.sanity.DoDelta(TUNING.SANITYAURA_LARGE, true) return end end end) if inst.components.freezable then -- Makes you never freeze. inst:RemoveComponent("freezable") end -- choose which sounds this character will play inst.soundsname = "maxwell" -- 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(250) inst.components.sanity:SetMax(80) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1.4 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1.3 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.OnNewSpawn = onload return MakePlayerCharacter("liam", prefabs, assets, common_postinit, master_postinit, start_inv) The Lua I put it into. ^^^ Also, I understand what you mean by crafting tabs being hella glitchy... So I just kinda gave up on it and I decided I'm just gonna have the character spawn with some blueprints and have their third perk be: "Starts with some blueprints." Link to comment Share on other sites More sharing options...
Ultroman Posted June 26, 2019 Share Posted June 26, 2019 (edited) This should work. You had deleted your master_postinit function, but left 80% of the code hanging, Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting inventory local start_inv = {"panflute", "boomerang", "lightbulb", "lightbulb", "lantern_blueprint", "panflute_blueprint", "boomerang_blueprint", "fishingrod_blueprint", "backpack_blueprint", "armorwood_blueprint",} -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when not a ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "liam_speed_mod", 1.05) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "liam_speed_mod") end -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "liam.tex" ) 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 = "maxwell" -- 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(250) inst.components.sanity:SetMax(80) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1.4 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1.3 * TUNING.WILSON_HUNGER_RATE if inst.components.freezable then -- Makes you never freeze. inst:RemoveComponent("freezable") end inst.OnLoad = onload inst.OnNewSpawn = onload -- This initializes for the server only. Components are added here. -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- I have set the radius to be 10. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, 10, {"watersource"}, {"player","INLIMBO","FX","DECOR"}, nil) for i,v in ipairs(ents) do if v.prefab:sub(1, 4) == "pond" then inst.components.sanity:DoDelta(TUNING.SANITYAURA_LARGE, true) return end end end) end return MakePlayerCharacter("liam", prefabs, assets, common_postinit, master_postinit, start_inv) Edited June 27, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 27, 2019 Author Share Posted June 27, 2019 Sweet it seems to be working fin- ... nvm when I go near the frog ponds I crash... lol (I wish there weren't this many errors.) The Error of Chaos. v v v Spoiler [00:01:51]: [string "../mods/liam/scripts/prefabs/liam.lua"]:81: variable 'str' is not declared LUA ERROR stack traceback: =[C]:-1 in (global) error (C) <-1--1> scripts/strict.lua:23 in () ? (Lua) <21-26> t = table: 2C88EE88 n = str ../mods/liam/scripts/prefabs/liam.lua:81 in (field) fn (Lua) <69-86> inst = 113639 - liam (valid:true) x = -236.22708129883 y = 0 z = -115.70321655273 ents = table: 435B2720 i = 1 v = 100423 - pond (valid:true) scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207> self = running = table: 11AFA698 waitingfortick = table: 11AFA760 tasks = table: 11AFA580 waking = table: 7823F4A0 attime = table: 11AFA918 hibernating = table: 11AFA8C8 tick = 1999 k = PERIODIC 113639: 1.000000 v = true already_dead = nil scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377> tick = 1999 scripts/update.lua:170 in () ? (Lua) <149-228> dt = 0.033333335071802 tick = 1999 i = 1999 [00:01:51]: [string "../mods/liam/scripts/prefabs/liam.lua"]:81: variable 'str' is not declared LUA ERROR stack traceback: =[C]:-1 in (global) error (C) <-1--1> scripts/strict.lua:23 in () ? (Lua) <21-26> ../mods/liam/scripts/prefabs/liam.lua:81 in (field) fn (Lua) <69-86> scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207> scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377> scripts/update.lua:170 in () ? (Lua) <149-228> I feel kinda bad that I am taking up this much of your time... Imma test my mods other features while I wait for your reply (Pray nothing else is bugged lol.) Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 27, 2019 Author Share Posted June 27, 2019 OK I NEED LIKE ACTUAL HELP NOW... BASICALLY WHILE I WAS ADJUSTING TEXTURES AND WAS EDITING SOMETHING, THE ANIM liam.zip FILE'S ATLAS FILES STOPPED WORKING AND I TRIED TO FIX IT AND I JUST BROKE EM MORE! DOES ANYONE HAVE ANY CLUE HOW TO REMAKE ONE OF THOSE ATLAS FILES!? PLEASE... Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 27, 2019 Author Share Posted June 27, 2019 Ok. I've fixed the error with the anim compiling. Turns out the software I was using randomly set the Bit size to 8Bit instead of 32Bit of two of my images. Now to just figure out the frog pond crash... Link to comment Share on other sites More sharing options...
Ultroman Posted June 27, 2019 Share Posted June 27, 2019 (edited) Sorry, that's my fault. Replace this: if str:sub(1, 4) == "pond" then with this: if v.prefab:sub(1, 4) == "pond" then I've fixed the code in the previous comment, as well. Edited June 27, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 27, 2019 Author Share Posted June 27, 2019 Hmm... Now there is an error in line 82..??? Error: Spoiler [00:01:29]: [string "scripts/components/sanity.lua"]:188: attempt to index local 'self' (a number value) LUA ERROR stack traceback: scripts/components/sanity.lua:188 in (field) DoDelta (Lua) <187-232> self = 1.6666666666667 delta = true overtime = nil ../mods/liam/scripts/prefabs/liam.lua:82 in (field) fn (Lua) <69-86> inst = 110172 - liam (valid:true) x = 158.50836181641 y = 0 z = -114.11143493652 ents = table: 7BE34168 i = 1 v = 111322 - pond (valid:true) scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207> self = running = table: 11BCB7F8 waitingfortick = table: 11BCB460 tasks = table: 11BCB578 waking = table: 7BE32CA0 attime = table: 11BCB5C8 hibernating = table: 11BCB320 tick = 494 k = PERIODIC 110172: 1.000000 v = true already_dead = nil scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377> tick = 494 scripts/update.lua:170 in () ? (Lua) <149-228> dt = 0.033333335071802 tick = 494 i = 494 [00:01:29]: [string "scripts/components/sanity.lua"]:188: attempt to index local 'self' (a number value) LUA ERROR stack traceback: scripts/components/sanity.lua:188 in (field) DoDelta (Lua) <187-232> ../mods/liam/scripts/prefabs/liam.lua:82 in (field) fn (Lua) <69-86> scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207> scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377> scripts/update.lua:170 in () ? (Lua) <149-228> something about a number value? Link to comment Share on other sites More sharing options...
Ultroman Posted June 27, 2019 Share Posted June 27, 2019 That's me again. Replace this: inst.components.sanity.DoDelta(TUNING.SANITYAURA_LARGE, true) with this: inst.components.sanity:DoDelta(TUNING.SANITYAURA_LARGE, true) Whenever it says that it can't find self and it's in a function that's not yours, it's usually because you forgot to use : to call a function which has been declared with a :. Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 27, 2019 Author Share Posted June 27, 2019 Sweet everything appears to work fine! Imma still test EVERYTHING tho just to be sure lol. Ok there was a bug. BUT IT WAS MY FAULT! I had forgotten to remove some of my old frog pond code from the MODMAIN lua and it was causing other characters to regen sanity... LOL Link to comment Share on other sites More sharing options...
Sqweepsss Posted June 27, 2019 Author Share Posted June 27, 2019 ... Is there a tag that can detect if an entity gets hurt? Kinda like "entity_death" 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