Open awilliamson opened 9 years ago
I had to deal with this in my panel library that I have yet to finish. Gimme a sec to find it.
Here is what I did.
We could modify the __newindex to make it so that if the user changes "startTouch", "touch" or "endTouch" keys the actual functions will set the instance, run the function and reset the instance.
See: http://wiki.garrysmod.com/page/Entity/SetTrigger
Problem is GM-code would look for those functions on the GM(underlying) entity. We can't pre-modify 'all' entities with those functions. We would have to have some method for creating those functions on entities adhoc, which bind to the SF-layer. SF has GM as underlying, so we've have to go backwards, make SF code generate GM code on-the-fly and still be sandboxed and safe.
I have a rough idea of how to achieve this. All the work would be in the library function for setting up these 'trigger' GM callbacks, but the user-provided callback would be vetted and checked. The interface functions under those 'trigger' GM callbacks would 'force' SF to parse the user-provided callback in SF-space.
Am I making any sense? Any suggestions/Ideas? I think these functions would be damn cool for users, as they'd able to hook into the physics system on entities ( including holograms! ), perhaps even able to get velocity and physics information for simulations?
@Xandaros, @Jazzelhawk, @EpicG Thoughts?