API to create/eval old-style commands?

  • boxmein
    4th Sep 2013 Former Staff 1 Permalink
    What about having an API (idk maybe commands and cmd for its short version) to create old-style commands that can invoke Lua? Maybe even having the Lua API go reverse on itself and have commands for evaluating old-style commands and getting their return values?

    Basically,

    commands.create(name, callback, argtypes)
    --> Creates a command and sets the types of arguments to be passed to it, also declaring the count.
    -- Example: commands.create("stkm", function(args) sim.partCreate("stkm", args.xy.x, args.xy.y) end, "xy")
    commands.eval(command)
    --> Evaluates old-style commands, without the exclamation point.
    -- Example: commands.eval("bubble 100,100")


    + More flexibility over the old-style command API
    + More Lua functionality
    + Can define macros that the user is already used to type when using the console
    + Ease of use for the end user

    - Old style interface needs heavy modifications to support dynamic addition
    - Users could compose Lua scripts of commands.eval


    What do you think?
    ~boxmein
    Edited once by boxmein. Last: 4th Sep 2013
  • xetalim
    4th Sep 2013 Member 0 Permalink

    @boxmein (View Post)

     no


    Yes.

     

    Good idea. I like it.

    Edited 2 times by xetalim. Last: 4th Sep 2013
  • boxmein
    4th Sep 2013 Former Staff 0 Permalink
    @xetalim (View Post)
    would the no have been in place if i was like some random user like @PackedBread?
  • mniip
    5th Sep 2013 Developer 0 Permalink
    i don't see a nice implementation of .create in terms of current code (CommmandInterface, TPTScriptInterface, LuaScriptInterface)
    Edited once by mniip. Last: 5th Sep 2013