Allow developers to use the Plugin Item and Invoke API

Currently, it is very difficult to transfer data between copies of the same plugin that exist in isolated DataModels.

For a basic example:
When you play a game, four Studio DataModels are active

  • Start Page (Cant be utilised by Developers since a recent change)
  • Edit Mode
  • Server
  • Client

These datamodels are isolated, and so, data cannot be sent between them using Bindables or Remotes (afaik, this may work for Server<->Client) since each Plugin is it’s own unique instance, regardless, Plugins that were started in the edit mode remain active.

Now, if I wanted to transfer data from the game back into the plugin running on the Edit state, currently, the only way to do this is hackily using Plugin Settings to fetch the state. This requires calling GetSetting every frame since the Edit plugin cant actually detect when the DataModel is killed (since it’s different to the Server DataModel)

However, another API exists that is locked behind RobloxScriptSecurity, this is known as the Item API. This API allows you to save temporary singleton data between DataModels, but its currently only usable for Standalone Builtins. Another API that exists is Invoke and OnInvoke. This allows you to register callbacks, similar to how BindableFunctions work that can also send data between DataModel instances (see example.)

This feature requests suggest opening up these two APIs for developers to also send data between the active datamodels.

EDIT: There’s no API to detect when a new Item is available, that would be useful for the SetItem/GetItem functions to be useful.

If Roblox were to address this issue, it would improve my development experience since I could then develop plugins that react to game state after the game is stopped without having to hackily rely on reading plugin settings every frame.

5 Likes

Here’s a simple usecase, detecting when the game is stopped, since there’s no RunService event for it (even though that could also be implemented, yet you wouldn’t be able to send data back to the Edit Plugin)

Binding this when in Edit mode:

plugin:OnInvoke("game-stopped", function(deathTime)
  print("Server was stopped at " .. deathTime)
end

Then, when the Plugin is started up in the Server DataModel, we can set this up

game:BindToClose(function()
  plugin:Invoke("game-stopped", os.time())
end)

if I remember how it works correctly, this will send data back to the Edit DataModel when the server was killed.

1 Like

The feature request (title) should focus on the problem that you describe in this sentence. Not about the specific proposed solution (unlocking some API that happens to solve the issue, this is just one specific solution for your issue).