Added: SystemThreadedBenchmark SystemThreadedQueue Fixed a bunch of bugs in the intergrations and regular multi objects Fixed Error management in threads All errors trigger the multi.OnError connection Module creation support improved added more examples added Type to threaded objects
12 lines
380 B
Lua
12 lines
380 B
Lua
-- Tick Tock Example
|
|
require("multi")
|
|
alarm=multi:newAlarm(1)
|
|
alarm.state=-1 -- set the state to -1
|
|
alarm.sounds={[-1]="Tick",[1]="Tock"} -- this makes changing between states easy and fast
|
|
alarm:OnRing(function(self)
|
|
print(self.sounds[self.state])
|
|
self.state=self.state*-1 -- change the state in one line
|
|
self:Reset() -- Reset the alarm so it runs again
|
|
end)
|
|
multi:mainloop()
|