Difference between revisions of "var.monitor"

From Inspired-Lua Wiki
Jump to navigation Jump to search
(Created page with "Category:var")
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
var.'''monitor''' is a function that is part of the Var Library.
 +
 +
<br>
 +
 +
This function turns on monitoring of a variable (given in the arguments). When another script/program modifies the variable it will trigger [[on.varChange|on.varChange]].<br>
 +
 +
== Syntax  ==
 +
 +
var.'''monitor(varname)'''<br> starts monitoring the variable varname (must not be of an exotic type or it will return an error).<br />
 +
See example below.
 +
 +
== Example  ==
 +
 +
<source lang="lua">
 +
function on.create()
 +
var.monitor("sol")
 +
--turn monitoring on for the variable "sol"
 +
end
 +
 +
function on.varChange(list)
 +
--The variable got changed!
 +
return 0 -- allow the change
 +
end
 +
</source>
 +
 +
== See also  ==
 +
 +
*[[var.list]]<br>
 +
*[[var.recall]]<br>
 +
*[[var.recallstr]]<br>
 +
*[[var.store]]<br>
 +
*[[var.unmonitor]]<br>
 +
 
[[Category:var]]
 
[[Category:var]]

Latest revision as of 14:07, 2 November 2011

var.monitor is a function that is part of the Var Library.


This function turns on monitoring of a variable (given in the arguments). When another script/program modifies the variable it will trigger on.varChange.

Syntax

var.monitor(varname)
starts monitoring the variable varname (must not be of an exotic type or it will return an error).
See example below.

Example

function on.create()
	var.monitor("sol")
	--turn monitoring on for the variable "sol"
end

function on.varChange(list)
	--The variable got changed!
	return 0 -- allow the change
end

See also