Script -> Plugin Bindable Events/Functions

Currently, it is difficult for Server Scripts to communicate with Plugins. They both can see and observe the game model, so they can communicate by mutating it; However, bindable events / functions do not seem to work when the script wants to invoke a protected plugin callback.

My use case is a stack tree plugin. I’m developing a pathfinder which runs into bugs far into its calculations. I have the application nearly correct, but it runs into edge cases every once in awhile. When it does, I must set a break point where the error happened, attempt to reproduce the bug, see what could have caused it, and set another breakpoint and run again. This is due to some information being lost later in the script when the breakpoint was set.

I would like to make a safe call (protected by pcall) so that when an error occurs, the message is printed and a toolbar button is made which when clicked will resume from the last safe call. This way, I set a breakpoint in the offending function, and directly re-run it when desired, obtaining more information. If I so desire, I can even re-run parent safe calls. This all assumes the functions are pure functions with no side effects.

To make the plugin button requires plugin access. The rest (including the StackTree) can be maintained in a module script made by the plugin. Currently, I had to make a special folder in which the module can create bindable events. When a bindable event is created in the folder, then the plugin detects it and a button is made with the same name. When the button is clicked, the event is fired by the plugin and the button destroyed.

5 Likes

Hold the coroutine of the script that is attempting to connect to the plugin until the plugin has set up it’s bind.

I’ve done this myself with a closed-access tool that I’m not releasing yet.

1 Like