Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

How to run a function when any variable changes?

$
0
0
How can I be notified when a variable is set? In any of the languages. (Preferably Harlowe, but if I have to switch language I could)

I dug into the Harlowe code, and found that VarRef contains exactly what I want, because there's a hook that lets you do like:

VarRef.on('set', (obj, name, value) => {
if (obj === State.variables) {
// You know that variable $name has just been set to $value
}
})

But I can't find a way to get access to this VarRef object. Any ideas?

Thanks

Viewing all articles
Browse latest Browse all 1844

Trending Articles