oh…oOHHH I see what you mean now.
Use a callback resource, like this one: [RELEASE] Lua Callback system