Is there a "proxy_enabled" message or function?

Is there a message or init function that can be called when a proxy is enabled? Similar to loading a proxy and getting a “proxy_loaded” message back, or doing msg.post(proxy, init) and triggering the init function.

I managed to accomplish the same by posting another message after msg.post(proxy, enable) and using on_message on the reciever, but it feels like there should be a better way?

Why do you need this?

I’ve got a cursor sprite in each proxy, and it ‘jumps’ when I change scene. Let’s say I’m going from Scene A to B, and my mouse moved from (5,5) to (10, 10). When I change back to Scene A, the cursor will jump from (10,10) to (5,5) until I move my mouse. I have the get & set function in init(), so its not a problem when I load the scene for the first time.

According to the documentation there is no “proxy_enabled” messsage but you can send your own “proxy_enabled” message. I’m thinking something similar to this:

msg.post(proxy_component,”enable”)
msg.post(cursor_url, “proxy_enabled”)

Personally I would try to avoid the need to update cursor position on enable by creating a single cursor GO in the bootstrap collection instead of having a cursor GO in each loaded collection.

Or centralise your cursor state in a lua module, make on_input function just set this data and on_update functions just read this data. So every collections use the same state everywhere. You can still keep your cursor GO in each collections (I guess you use a cursor with collision shape to interact with gameobjects, so you need it in every collection proxies)

1 Like

Thanks for the suggestion! I am using a collision object with my cursor hence why I need a cursor GO in every collection.

I have thought about using on_update but it feels like it’ll take more resource compared to on_input? Anyway I’m already doing msg.post and on_message to make my on “proxy enabled” function, so I guess I’ll keep doing that, thanks.