git-subtree-dir: multi git-subtree-mainline: 14f186d8e1f36b38f6816dfa4d004dd023b882ce git-subtree-split: 285fa7e933d1986bcbd354294c05cee40ef43cea
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()
|