Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Method that sets a boolean in self crashes when played?

Asked by 5 years ago

Hi,

I've been working freelance on new opensource technology for war clans to use; however, I've also stumbled upon problems while trying to instill new habits in myself. I attempted playing around with methods for compact code and more dynamic tables, but every-time I hit play-test using the code below server-side, it crashes.

local terminal = {
    Safe = false;

    Stability = 1000, -- time before win
    Rollback = 2;

    ServerElapsed = 3600;
    ------------
    StatusChange = function(self, planted)
        self.Safe = (not planted)

        while (self.Safe == (not planted) and wait()) do
            self.Stability = (self.Stability < 1000 and self.Stability + (self.Safe and self.Rollback or -1))
            print('Timer:', self.Stability)
            if (self.ServerElapsed <= 0 or self.Stability <= 1000) then
                self.Stability = 1000
                break
            end
            wait(1)
        end

        print('Bomb has been', (planted and 'planted' or 'defused'))
    end,
};

terminal:StatusChange(true)

I've narrowed it down to this line right here:

self.Secure = (not planted)

So does this mean I can't set previous values in a table through a method? I'm really confused and would appreciate help!

0
Why are you wrapping lines 10, 12-13, 15, and 22 wrapped in brackets? User#19524 175 — 5y
0
Just a habit. Is that a concern? HollowMariofan 104 — 5y

Answer this question