Jump to content

Recommended Posts

local function ResistGrogginess(inst, owner, isworking)
    if not owner.components.grogginess then return end
    if isworking then
        inst._enablespeedmod = owner.components.grogginess.enablespeedmod
        inst._knockouttestfn = owner.components.grogginess.knockouttestfn
        print("watchpoint 1")
        print(inst._enablespeedmod) -- true
        owner.components.grogginess.knockouttestfn = function() return false end
        owner.components.grogginess:SetEnableSpeedMod(false)
    else
        owner.components.grogginess:ResetGrogginess()
        owner.components.grogginess:SetKnockOutTest(inst._knockouttestfn)
        print("watchpoint 2")
        print(inst._enablespeedmod) -- false
        owner.components.grogginess:SetEnableSpeedMod(inst._enablespeedmod)
    end
end

I wrote something like above, but I found inst._enablespeedmod changed to false unexpectedly when unequipped.
I'm quite sure the variable isn't changed outside the function, how come ...  :wilson_facepalm:

_enablespeedmod might've ended up becoming a reference to enablespeedmod instead of simply taking it's value, you could try replacing

inst._enablespeedmod = owner.components.grogginess.enablespeedmod

with

inst._enablespeedmod = not (not owner.components.grogginess.enablespeedmod)
Edited by grm9
38 minutes ago, grm9 said:

_enablespeedmod可能最终成为 enablespeedmod 的引用,而不是简单地获取它的值,您可以尝试将

inst._enablespeedmod = owner.components.grogginess.enablespeedmod

inst._enablespeedmod = not (not owner.components.grogginess.enablespeedmod)

Oh, thanks. I finally find the ResistGrogginess function called twice somewhere else, so finish it :grin: 

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...