var.monitor

From Inspired-Lua Wiki
Jump to: navigation, search

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[edit]

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[edit]

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[edit]