mindsnacks/moai-dev — pull request #22 by aab29 (2013-06-18 17:06:19+00:00)
Title: Hacky hack to stop MOAIScriptNode from crashing Moai.

```MOAIScriptNode``` is pretty cool, but apparently it's seldom used. There's no documentation or tutorials to speak of on the Internets :information_source: . So when there's a bug that crashes Moai, like the one I just uncovered, it's hard to figure out the *right* way to fix it.

This is the *wrong* way to fix it, but it stops the game from crashing.

It looks like this is going on. Occasionally when a ```loop```, ```sequence```, or ```animate``` ActionHelper action is ```stop()```ped, it will attempt to pull values from attribute links one last time--even after the linked nodes (or perhaps even the node itself?!) have been garbage collected. :scream: I checked to see why this is happening, and apparently when ```onDepNodeUpdate``` gets called on a ```MOAIScriptNode```, the only thing it checks to determine whether or not to pull links is whether ```mOnUpdate``` (the reference to the ```MOAIScriptNode```'s callback function) is not ```NULL```. Frst I tried just setting the callback to ```NULL```, but that caused a bunch of error messages about trying to call a nil function. So I added another flag :us: : ```isAllowedToCallOnUpdate```, which gets set from Lua when you call ```setCallback()```, and cleared when you call ```clearCallback()```. ```MOAIScriptNode``` now checks this flag before pulling links, and it seems to fix the crashes.

I'd *really* like to figure out the *right* way to fix this. I'm going to tell the Moai maintainers about this, but I'm not holding my breath for a quick solution. In the meantime, this hack will allow us to ship Bloon. :balloon: