Jump to content

Recommended Posts

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.

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.

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. 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...