Jump to content

Item that can haunt - need help please


Recommended Posts

10 minutes ago, FaZZa said:

ah my mistake, sorry

onfueldelta(inst, inst.components.fueled:GetPercent(0))

the zero between the two brackets at the end

well that's the normal version you had.. adding 0 does nothing

onfueldelta(inst, {percent = inst.components.fueled:GetPercent()})

^ that should work, unless im missing something(same as I sent before)

Link to comment
Share on other sites

That does work, it isnt crashing the game, but the item still will haunt even when its at 0 durability.

Ive attached an image showing the code for the lamp, maybe youll see something ive miss-spelled or put in the wrong place.

SL code.png

Edited by FaZZa
Link to comment
Share on other sites

7 minutes ago, FaZZa said:

That does work, it isnt crashing the game, but the item still cast even when its at 0 durability.

Ive attached an image showing the code for the lamp, maybe youll see something ive miss-spelled or put in the wrong place.

can u try removing

inst:AddComponent("spellcaster")
inst.components.spellcaster:SetSpellFn(onsoulahunt)
inst.components.spellcaster.islantern = true

from under

inst:AddTag("soullantern")

and move the "onsoulhaunt" function to above "onfueldelta" function

Edited by Aquaterion
Link to comment
Share on other sites

6 minutes ago, Aquaterion said:

can u try removing


inst:AddComponent("spellcaster")
inst.components.spellcaster:SetSpellFn(onsoulahunt)
inst.components.spellcaster.islantern = true

This stops the haunt casting altogether, cant use the lantern on anything now

Link to comment
Share on other sites

3 minutes ago, FaZZa said:

This stops the haunt casting altogether, cant use the lantern on anything now

did you try on both empty and non empty lanterns?

also where is

onfueldelta(inst, {percent = inst.components.fueled:GetPercent()}) 

in that screenshot?

Edited by Aquaterion
Link to comment
Share on other sites

    local function onfueldelta(inst, pct)
    onfueldelta(inst, {percent = inst.components.fueled:GetPercent()})
    if pct.percent == 0 then
        inst:RemoveComponent("spellcaster")
    else
        if inst.components.spellcaster == nil then
            inst:AddComponent("spellcaster")
            inst.components.spellcaster:SetSpellFn(onsoulhaunt)
            inst.components.spellcaster.islantern = true
        end
    end
end

I have it like this and it still haunts at 0

man, this thing just doesnt want to work does it? :(

Link to comment
Share on other sites

3 minutes ago, FaZZa said:

    local function onfueldelta(inst, pct)
    onfueldelta(inst, {percent = inst.components.fueled:GetPercent()})
    if pct.percent == 0 then
        inst:RemoveComponent("spellcaster")
    else
        if inst.components.spellcaster == nil then
            inst:AddComponent("spellcaster")
            inst.components.spellcaster:SetSpellFn(onsoulhaunt)
            inst.components.spellcaster.islantern = true
        end
    end
end

I have it like this and it still haunts at 0

man, this thing just doesnt want to work does it? :(

local function onfueldelta(inst, pct)
    if pct.percent == 0 then
        inst:RemoveComponent("spellcaster")
    else
        if inst.components.spellcaster == nil then
            inst:AddComponent("spellcaster")
            inst.components.spellcaster:SetSpellFn(onsoulhaunt)
            inst.components.spellcaster.islantern = true
        end
    end
end

onfueldelta(inst, {percent = inst.components.fueled:GetPercent()})

when I say below, I mean below the whole block :p

also make sure you move over the

inst:ListenForEvent("percentusedchange", onfueldelta)

 

Edited by Aquaterion
Link to comment
Share on other sites

Change this part:

if pct.percent == 0 then
        inst:RemoveComponent("spellcaster")
    else

to:

if pct.percent == 0 then
        if inst.components.spellcaster then
            inst:RemoveComponent("spellcaster")
        end
    else

that should be the last and final issue

Edited by Aquaterion
Link to comment
Share on other sites

6 minutes ago, FaZZa said:

This happens when i haunt with 0 durability left

Try

bc9d4bd0ccde5c4664414d1c07dbf32b.png

removing those 3 lines

if it still doesnt work try changing line 99 in modmain.lua to;

return actions.invobject.components.spellcaster and actions.invobject.components.spellcaster.castingstate or "castspell"

 

Link to comment
Share on other sites

Removing those three lines still causes a crash on the haunt with 0 durability

return actions.invobject.components.spellcaster and actions.invobject.components.spellcaster.castingstate or "castspell"

this causes the game to crash the moment i try to haunt something, showing this crash message:

crash3.png

Link to comment
Share on other sites

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
 Share

×
  • Create New...