From b0ca506688a57cda62f38803749f4ab67b7825b1 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 2 Jul 2021 01:03:25 +0200 Subject: [PATCH] basic proof of concept --- mods/CORE/mcl_commands/PROOF_OF_CONCEPT.md | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 mods/CORE/mcl_commands/PROOF_OF_CONCEPT.md diff --git a/mods/CORE/mcl_commands/PROOF_OF_CONCEPT.md b/mods/CORE/mcl_commands/PROOF_OF_CONCEPT.md new file mode 100644 index 000000000..3a9816979 --- /dev/null +++ b/mods/CORE/mcl_commands/PROOF_OF_CONCEPT.md @@ -0,0 +1,55 @@ +### `mcl_commands.register_command(name, def)` + +#### Complex commands (WIP): + +``` +mcl_commands.register_command("test", { + type = "complex", + priv_level = 4, + func = function(context) + if self.match_type("int", {min=1, max=255} then + print(self.last_type) + end + end, +}) +``` + +#### Basic commands: + +* `context.type` is the context of execution: `player` or `commandblock` +* `context.commander` is the executor/commander of the command +* `context.pos` is the position where the command is executed + +This param allow the use of position target selectors + +``` +mcl_commands.register_command("test", { + type = "basic", + priv_level = 4, + func = function(context) + if context.commander then + print(context.pos) + print("--------") --this "concept" param allow to run command correctly + --(with target selector and logging) from mods or command blocks + return true, S("Succesfull") + end + end, +}) +``` + +### `mcl_commands.execute_command(name, params, context)` + +#### As a player: +``` +mcl_commands.execute_command("test", "foo bar true 1", {commander=player, pos=player:get_pos()}) +``` +#### As a command block: +``` +mcl_commands.execute_command("test", "foo bar true 1", {commander=commander, pos=node_pos}) +``` + +### `mcl_commands.get_target_selector(target_selector)` + +This function allow mods and commands to get the result of a given target selector in that form: `@e[gamemode=creative,limit=5]` + +This function returns a code indicating the success and a table of ObjectRefs (can be empty) \ No newline at end of file