Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function newMonitoredVariable(name, value)
- Runtime:dispatchEvent{name="Variable"; variable=name, value=value}
- return function(...)
- if select('#', ...) == 0 then
- return value
- end
- local old = value
- value = ...
- Runtime:dispatchEvent{name="Variable"; variable=name, value=value, oldValue=old}
- return old
- end
- end
- Runtime:addEventListener("Variable", function (event) _G[event.variable] = event.value end)
- set_fnord = newMonitoredVariable("fnord", 5)
- print(fnord) -- prints 5
- set_fnord("kumquat")
- print(fnord) -- prints kumquat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement