net/mulit/examples/alarmTest.lua
Ryan a20dfa2b8f Add 'mulit/' from commit '285fa7e933d1986bcbd354294c05cee40ef43cea'
git-subtree-dir: mulit
git-subtree-mainline: 69233e59c8a641ceb835daae961ebce1127faa79
git-subtree-split: 285fa7e933d1986bcbd354294c05cee40ef43cea
2017-07-28 11:17:18 -04:00

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()