InvarkuI Posted June 29, 2020 Share Posted June 29, 2020 Yet another error I'm facing again and again. I fixed this thing 3 or 4 times at my previous chars, but now it's hands down. I'm so fed up with trying to find the solution myself so I came to ask for help. The error image is below. I know it's about item being non inventory or smth like that, but I have the code so simple that I can't find what's wrong exactly Quote local assets= { Asset("ANIM", "anim/COH_bw.zip"), Asset("ANIM", "anim/COH_swap.zip"), Asset("ATLAS", "images/inventoryimages/COH_bw.xml"), Asset("IMAGE", "images/inventoryimages/COH_bw.tex"), } local prefabs = { } local function fn() local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("COH_swap", "COH_swap", "COH_swap") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAIR") end end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAIR") end end local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() MakeInventoryPhysics(inst) MakeInventoryFloatable(inst) anim:SetBank("COH_bw") anim:SetBuild("COH_bw") anim:PlayAnimation("idle") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "COH_bw" inst.components.inventoryitem.atlasname = "images/inventoryimages/COH_bw.xml" inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HEAD inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) return inst end STRINGS.NAMES.CORKHAT = "Curse Of Hatred" STRINGS.CHARACTERS.GENERIC.DESCRIBE.CORKHAT = "Sadness and Hatred" return Prefab("common/inventory/COH_bw", fn, assets, prefabs) Link to comment Share on other sites More sharing options...
-LukaS- Posted June 29, 2020 Share Posted June 29, 2020 Some clean up needed! First of all, prefabs table is useless in this case. ( That's not what causes the crash of course, but that's just a tip ) local prefabs = {} Not having anything in your prefabs table is the same as not having it entirely so there's no need for it. And secondly, your local fn() has these functions in it: ( Now this is causing the crash ) local function fn() local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("COH_swap", "COH_swap", "COH_swap") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAIR") end end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAIR") end end end These shouldn't be in the main function. They should be outside. Like this: local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("COH_swap", "COH_swap", "COH_swap") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAIR") end end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAIR") end end local function fn() local inst = CreateEntity() ... end You can still use them in the fn() function. If there are any other errors tell me. 2 Link to comment Share on other sites More sharing options...
InvarkuI Posted June 30, 2020 Author Share Posted June 30, 2020 16 hours ago, IThatGuyI said: Some clean up needed! First of all, prefabs table is useless in this case. ( That's not what causes the crash of course, but that's just a tip ) local prefabs = {} Not having anything in your prefabs table is the same as not having it entirely so there's no need for it. And secondly, your local fn() has these functions in it: ( Now this is causing the crash ) local function fn() local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("COH_swap", "COH_swap", "COH_swap") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAIR") end end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAIR") end end end These shouldn't be in the main function. They should be outside. Like this: local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("COH_swap", "COH_swap", "COH_swap") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAIR") end end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAIR") end end local function fn() local inst = CreateEntity() ... end You can still use them in the fn() function. If there are any other errors tell me. ok. I was super dumb not to notice func inside func thing, ty for that, but the problem remain. If I spawn as my char with that item it gives the same error. If I spawn my char without this item and trying to give it via console it says that. And according to console the item prefab DO exist somehow but cannot be summoned nor put into the inv.. Link to comment Share on other sites More sharing options...
-LukaS- Posted June 30, 2020 Share Posted June 30, 2020 Did you add your prefab to the modmain.lua with PrefabFiles = {"COH_bw"}? 1 Link to comment Share on other sites More sharing options...
InvarkuI Posted June 30, 2020 Author Share Posted June 30, 2020 7 minutes ago, IThatGuyI said: Did you add your prefab to the modmain.lua with PrefabFiles = {"COH_bw"}? Yes, I did Quote PrefabFiles = { "esctemplate", "esctemplate_none", "COH", } Assets = { Asset( "IMAGE", "images/saveslot_portraits/esctemplate.tex" ), Asset( "ATLAS", "images/saveslot_portraits/esctemplate.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/esctemplate.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/esctemplate.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/esctemplate_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/esctemplate_silho.xml" ), Asset( "IMAGE", "bigportraits/esctemplate.tex" ), Asset( "ATLAS", "bigportraits/esctemplate.xml" ), Asset( "IMAGE", "images/map_icons/esctemplate.tex" ), Asset( "ATLAS", "images/map_icons/esctemplate.xml" ), Asset( "IMAGE", "images/avatars/avatar_esctemplate.tex" ), Asset( "ATLAS", "images/avatars/avatar_esctemplate.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_esctemplate.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_esctemplate.xml" ), Asset( "IMAGE", "images/avatars/self_inspect_esctemplate.tex" ), Asset( "ATLAS", "images/avatars/self_inspect_esctemplate.xml" ), Asset( "IMAGE", "images/names_esctemplate.tex" ), Asset( "ATLAS", "images/names_esctemplate.xml" ), Asset( "IMAGE", "images/names_gold_esctemplate.tex" ), Asset( "ATLAS", "images/names_gold_esctemplate.xml" ), Asset( "IMAGE", "bigportraits/esctemplate_none.tex" ), Asset( "ATLAS", "bigportraits/esctemplate_none.xml" ), } AddMinimapAtlas("images/map_icons/esctemplate.xml") local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS -- The character select screen lines STRINGS.CHARACTER_TITLES.esctemplate = "The Sample Character" STRINGS.CHARACTER_NAMES.esctemplate = "Esc" STRINGS.CHARACTER_DESCRIPTIONS.esctemplate = "*Perk 1\n*Perk 2\n*Perk 3" STRINGS.CHARACTER_QUOTES.esctemplate = "\"Quote\"" -- Custom speech strings STRINGS.CHARACTERS.ESCTEMPLATE = require "speech_esctemplate" -- The character's name as appears in-game STRINGS.NAMES.ESCTEMPLATE = "Esc" -- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL. AddModCharacter("esctemplate", "FEMALE") I renamed COH_bw for COH with all the additional things so don't be confused Link to comment Share on other sites More sharing options...
-LukaS- Posted June 30, 2020 Share Posted June 30, 2020 It seems like everything should be ok. Could you provide me with your COH and modmain files? I'll try to find the error. 1 Link to comment Share on other sites More sharing options...
InvarkuI Posted June 30, 2020 Author Share Posted June 30, 2020 11 minutes ago, IThatGuyI said: It seems like everything should be ok. Could you provide me with your COH and modmain files? I'll try to find the error. Seems like I figure it out. Turns out that it's n ot possible to have item names in CAPS. It misses some names but now I can see it on the ground and pick it although without inv image yet 1 Link to comment Share on other sites More sharing options...
-LukaS- Posted June 30, 2020 Share Posted June 30, 2020 The item might be invisible because you don't have its assets in the modmain.lua. 1 Link to comment Share on other sites More sharing options...
InvarkuI Posted June 30, 2020 Author Share Posted June 30, 2020 (edited) 3 minutes ago, IThatGuyI said: The item might be invisible because you don't have its assets in the modmain.lua. No no. Everything is fine now. It was invisible cuz I didn't make an icon for it. Anyway ty for pointing at fn() mistake. Now if we encounter sm1 with such error first of all we should check if his items name isn't in caps Have a nice day Edited June 30, 2020 by InvarkuI 1 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