Sleitnick / AeroGameFramework

AeroGameFramework is a Roblox game framework that makes development easy and fun. The framework is designed to simplify the communication between modules and seamlessly bridge the gap between the server and client.
https://sleitnick.github.io/AeroGameFramework/
MIT License
215 stars 57 forks source link

Access controller/service from standalone scripts #150

Closed tacheometry closed 4 years ago

tacheometry commented 4 years ago

Is there a way to access a controler/service's functions from a Script/LocalScript that isn't related at all to AGF? More details:

I'm trying to make a command with Cmdr (a neat command line in-game), but the problem is that you can only make commands using separate ModuleScripts, where you specify a function for each command, like this:

ClientRun = function(_, argument)
  local myController = ?

  return myController:DoSomethingWith(argument)
end
Sleitnick commented 4 years ago

Yup, this is possible by using _G.Aero! In your case, it could be like this:

while (not _G.Aero) do wait() end
ClientRun = function(_, argument)
    local myController = _G.Aero.Controllers.MyController
    return myController:DoSomethingWith(argument)
end

See the documentation on external use: https://sleitnick.github.io/AeroGameFramework/execution_model/#external-use