Franke004 Posted June 29, 2018 Share Posted June 29, 2018 Hey , is there any way i could make the item appear on top of the character ? , so the character's fist doesnt go in front of the fist item i made for him. Thanks. Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted June 30, 2018 Share Posted June 30, 2018 You use setmultisymbolexchange like the example below local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_wand_wristbow", "wand") owner.AnimState:SetMultiSymbolExchange("swap_object", "hand") end local function OnUnequip(inst, owner) owner.AnimState:ClearSymbolExchanges() end Link to comment Share on other sites More sharing options...
Franke004 Posted June 30, 2018 Author Share Posted June 30, 2018 thank you , and do you know by any chance how do i make the character spawn with the item and only him be able to equip it or he cant drop it Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted June 30, 2018 Share Posted June 30, 2018 For characters to spawn with the item usually you put the prefab name in the start_inv in the character lua like this: local start_inv = { "wand_weapon", } and for the item only to have the character only equip it put this in the weapon lua: inst.components.inventoryitem.onputininventoryfn = function(inst, player) if not player:HasTag("acharactertaginyourcharacterlua") then inst:DoTaskInTime(0.1, function() player.components.inventory:DropItem(inst) end) end end last he can't drop it well Idk how to do, heard the golem mod has something your looking for. Link to comment Share on other sites More sharing options...
Franke004 Posted June 30, 2018 Author Share Posted June 30, 2018 attempt to index field 'inventoryitem' (a nil value) LUA ERROR stack traceback: Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted June 30, 2018 Share Posted June 30, 2018 You'll have to put that code after theworld.ismastersim. Last note is I forgot you need this code: inst.components.inventoryitem.cangoincontainer = false I like to put it in my onequip function. Link to comment Share on other sites More sharing options...
Franke004 Posted June 30, 2018 Author Share Posted June 30, 2018 i put it after that and its still not working , same error Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted June 30, 2018 Share Posted June 30, 2018 Well I need the weapon lua at this point I don't want to keep guessing what the problem is. Link to comment Share on other sites More sharing options...
Franke004 Posted June 30, 2018 Author Share Posted June 30, 2018 gauntlets.lua Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted June 30, 2018 Share Posted June 30, 2018 Man I hate this format, either way you have quite a bit of errors especially that components are being called when they haven't been initialized. local function MakeSword(gauntlets, damage) local assets = { Asset("ANIM", "anim/gauntlets.zip"), Asset("ANIM", "anim/swap_gauntlets.zip"), Asset("IMAGE", "images/inventoryimages/gauntlets.tex"), Asset("ATLAS", "images/inventoryimages/gauntlets.xml"), Asset("ANIM", "anim/gloves_leather.zip") } local function onequip(inst, owner) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst.components.inventoryitem.cangoincontainer = false if inst.skin_build_name ~= nil then owner.AnimState:OverrideSymbol("hand", inst.skin_build_name, "hand" ) else owner.AnimState:OverrideSymbol("hand", "gloves_leather", "hand") end owner:AddTag("thorny_protection") inst.equipped = true inst.owner = owner.userid --owner.components.combat:SetAttackPeriod(15) end local function onunequip(inst, owner) owner.AnimState:ClearOverrideSymbol("hand") owner:RemoveTag("thorny_protection") inst.equipped = false inst.owner = nil --owner.components.combat:SetAttackPeriod(.1) end local function onattack(inst, attacker, target) if attacker.components.health then attacker.components.health:DoDelta(-20) end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("gloves") inst.AnimState:SetBuild("gloves_leather") inst.AnimState:PlayAnimation("idle") inst:AddTag("gloves") inst:AddTag("punch") inst:AddTag("gloves") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("weapon") inst.components.weapon:SetDamage(200) --the code is used to set damage inst.components.weapon:SetOnAttack(onattack) inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/gauntlets.xml" inst.components.inventoryitem.imagename = "gauntlets" inst.components.inventoryitem.onputininventoryfn = function(inst, player) if not player:HasTag("acharactertaginyourcharacterlua") then inst:DoTaskInTime(0.1, function() player.components.inventory:DropItem(inst) end) end end inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) MakeHauntableLaunch(inst) return inst end return Prefab( "common/inventory/gauntlets", fn, assets) end return MakeSword("gauntlets",20) Link to comment Share on other sites More sharing options...
Franke004 Posted June 30, 2018 Author Share Posted June 30, 2018 im dropping the item as soon as i give it in my inventory Link to comment Share on other sites More sharing options...
Franke004 Posted June 30, 2018 Author Share Posted June 30, 2018 nvm fixed it 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