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 https://forums.kleientertainment.com/forums/topic/70888-cant-access-spell-targets-inventory/ 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 https://forums.kleientertainment.com/forums/topic/70888-cant-access-spell-targets-inventory/#findComment-825471 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 https://forums.kleientertainment.com/forums/topic/70888-cant-access-spell-targets-inventory/#findComment-825534 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 https://forums.kleientertainment.com/forums/topic/70888-cant-access-spell-targets-inventory/#findComment-825566 Share on other sites More sharing options...
whismerhill Posted October 16, 2016 Share Posted October 16, 2016 too much components Link to comment https://forums.kleientertainment.com/forums/topic/70888-cant-access-spell-targets-inventory/#findComment-825646 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