mollersuite / mollermethod

A utility script from the future.
https://mollermethod.pages.dev
8 stars 1 forks source link

Methods #50

Open Jack5079 opened 2 years ago

Jack5079 commented 2 years ago

The Methods API brings a typed API for creating commands and actions. With Adapters, the Methods API will allow developers to write once then deploy with any (supported) UI lib.

local api = ...
local Method = api.Method
local all = api.all -- something like Promise.all but for Lua

local part = Method {
  Name = "part",
  DisplayName = "Part at player",
  Description = "Spawns a part at a player",
  Replicates = true,
  Run = function (args)
      all(args.People, function (player)
            Instance.new('Part', workspace):SetPivot(player.Character:GetPivot())
      end)
  end,
  Arguments = {
      People = {
          Required = true,
          Type = 'players'
       }
  }
}

-- you'll be able to run Methods programatically
part {
  People = game:GetService('Players'):GetPlayers()
}

-- you'll be able to modify properties of your Methods as well
part.Disabled = math.random() > 0.5

return {
  Name = "Methods API demo",

  -- to export a method put it in the table
  part,
}
Jack5079 commented 2 years ago

need to fix bracket next

Jack5079 commented 2 years ago

fuck this we need to make it a standard supported by every admin script

Jack5079 commented 2 years ago

or maybe not let's call Exports Methods too