Skip to content

Adding Function Arguments with Data Storage #15

@Stevertus

Description

@Stevertus

Originally created for mcscript by @WilliamRagstad here: Stevertus/mcscript#23

There is a poly-fill trick for supporting arguments to functions using the new /data get storage [name] [path].
Format example:

mcscriptfunctions
|___ [function name]
        |___ [meta data]
        |___ [arguments]
               |___ [0]
               |___ [1]
               |___ ...
               |___ [N]

This will allow for real-time function calls if you create a macro that generates commands similar to the following code: (simulating using C#)

void callToFunction(string name, object[] args) {
   string r = "/data modify storage MCScriptFunctions " + name + ".arguments set value [";
   for(int i = 0; i < args.length; i++) r += args[i];
   r += "]\n"
   r += "/function " + name;
}

This could probably be optimized in many ways regarding to recursion etc (can be solved by storing arguments in temp variables), but this is the overall picture.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions