Sign in to follow this  
FaZZa

Item that can haunt - need help please

Recommended Posts

FaZZa    23

ah my mistake, sorry

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

the zero between the two brackets at the end

Share this post


Link to post
Share on other sites
Aquaterion    821
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)

Share this post


Link to post
Share on other sites
FaZZa    23

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

Share this post


Link to post
Share on other sites
Aquaterion    821
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

Share this post


Link to post
Share on other sites
FaZZa    23
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

Share this post


Link to post
Share on other sites
Aquaterion    821
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

Share this post


Link to post
Share on other sites
FaZZa    23

i did yes

and its under the fuel function for the soul ammo, is that not where it should be? i may have misread the message

Edited by FaZZa

Share this post


Link to post
Share on other sites
Aquaterion    821
2 minutes ago, FaZZa said:

i did yes

and its under the fuel function for the soul ammo, is that not where it should be? i may have misread the message

no its for the lantern under the onfueldelta function

Share this post


Link to post
Share on other sites
FaZZa    23

    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? :(

Share this post


Link to post
Share on other sites
Aquaterion    821
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

Share this post


Link to post
Share on other sites
Aquaterion    821

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

Share this post


Link to post
Share on other sites
Aquaterion    821
31 minutes ago, FaZZa said:

nope, still caused a crash

can u post ur code again, and was it the SAME crash or different? if so post the new crash

Edited by Aquaterion

Share this post


Link to post
Share on other sites
Aquaterion    821
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"

 

Share this post


Link to post
Share on other sites
FaZZa    23

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

Share this post


Link to post
Share on other sites
Aquaterion    821

hmm maybe

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

--instead of

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

 

Share this post


Link to post
Share on other sites
FaZZa    23

still crashing on 0 durability

not having too much luck with this are we? :?

Edited by FaZZa

Share this post


Link to post
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
Sign in to follow this