Cyde042 Posted October 15, 2016 Share Posted October 15, 2016 Basically I want to apply an insulation effect on the character upon using an item, but I need to create a transparent equipment piece and then equip it first, so I resorted to using glow berrie's code. Here is the relevant part: local function insulation_start(inst) local spell = inst.components.spell spell.target.inventory:Equip(inst) --It says that inventory is nil, even though the target is "100021 - wilson" print(spell.target) end -- local function insulationfn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst:AddTag("FX") inst:AddTag("NOCLICK") local spell = inst:AddComponent("spell") inst.components.spell.spellname = "whaleoil" inst.components.spell:SetVariables(insulation_variables) inst.components.spell.duration = 10 inst.components.spell.ontargetfn = insulation_ontarget inst.components.spell.onstartfn = insulation_start inst.components.spell.onfinishfn = insulation_onfinish inst.components.spell.fn = insulation_spellfn inst.components.spell.resumefn = insulation_resume inst.components.spell.removeonfinish = true inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.EXTRA inst.components.equippable:SetOnEquip( onequip ) inst.components.equippable:SetOnUnequip( onunequip ) inst:AddComponent("insulator") inst.components.insulator:SetInsulation(TUNING.INSULATION_LARGE) return inst end Now the weirdest thing is that the print part, returns "100021 - wilson", so I don't understand, is that not the character, why would it return inventory as nil if it is Wilson? I don't understand what's wrong.and it's driving me crazy. Link to comment Share on other sites More sharing options...
CarlZalph Posted October 16, 2016 Share Posted October 16, 2016 2 hours ago, Cyde042 said: Basically I want to apply an insulation effect on the character upon using an item, but I need to create a transparent equipment piece and then equip it first, so I resorted to using glow berrie's code. Here is the relevant part: -code- Now the weirdest thing is that the print part, returns "100021 - wilson", so I don't understand, is that not the character, why would it return inventory as nil if it is Wilson? I don't understand what's wrong.and it's driving me crazy. spell.target.components.inventory It's a component. Link to comment Share on other sites More sharing options...
Mobbstar Posted October 16, 2016 Share Posted October 16, 2016 4 hours ago, CarlZalph said: spell.target.components.inventory It's a component. Yep, that's the problem here. Happens to the best of us. Link to comment Share on other sites More sharing options...
Cyde042 Posted October 16, 2016 Author Share Posted October 16, 2016 1 hour ago, Mobbstar said: Yep, that's the problem here. Happens to the best of us. 6 hours ago, CarlZalph said: spell.target.components.inventory It's a component. Omg I can't believe this... I even checked player-common for components because I thought I spelled it wrong. Thanks. Link to comment Share on other sites More sharing options...
whismerhill Posted October 16, 2016 Share Posted October 16, 2016 too much components Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.