Is it possible to 'listen' in lua?

I’m just wondering, because it seems a pain to have to send a message telling the server to save the players data every time I change a relevant value, is it possible to monitor/listen to a value and perform an action, automatically, when it is changed? Much like an event listener in other languages.

If this isn’t possible, maybe it should be, would be quite cool I guess…

You can send net messages to the server. But you have to explain a bit more.

Couldn’t you wrap whatever you want to change in your own networking library?

For example,

local a = 0
function GM:Think()
a = a + 1

function a:OnValueChanged()
print("a is now "…a)

I want to know if it’s possible to add a listener to the value a, and if not I think it should be possible.

[editline]5th March 2013[/editline]

What do you mean?

Use a function to set the variable, have that function sync it to clients

You know what, that seems so much simpler than listening for a change for each value.

Cheers for the insight.