yanecc Posted October 3, 2024 Share Posted October 3, 2024 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 ... Link to comment https://forums.kleientertainment.com/forums/topic/160058-help-try-to-make-a-sleep-immune-equipment/ Share on other sites More sharing options...
grm9 Posted October 3, 2024 Share Posted October 3, 2024 (edited) _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 October 3, 2024 by grm9 Link to comment https://forums.kleientertainment.com/forums/topic/160058-help-try-to-make-a-sleep-immune-equipment/#findComment-1751640 Share on other sites More sharing options...
yanecc Posted October 3, 2024 Author Share Posted October 3, 2024 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 Link to comment https://forums.kleientertainment.com/forums/topic/160058-help-try-to-make-a-sleep-immune-equipment/#findComment-1751643 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