From 90f2fcb2abf6a58eb94b49f0535969ac6c245923 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:00:51 -0700 Subject: [PATCH] added UAS Parse --- CHANGELOG.md | 1 + Chat-Command-Reference.md | 10 +++++++ README.md | 5 ++-- .../commands/uasparse.lua | 29 +++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 worldeditadditions_commands/commands/uasparse.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 93c1e68..b134f09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Note to self: See the bottom of this file for the release template text. - Added `//sgrow` and `//sshrink` commands to enlarge and shrink selection regions and aliased them over WorldEdit equivalents (`//expand`, `//outset` and `//contract`, `//inset` respectively). - Added Unified Axis Syntax (UAS) parser. - Implementation by @VorTechnix - See [UAS System reference] for details. (Note to self hook up hyperlink) +- Added `//uasparse` command to show the vectors produced by a given UAS expression. - Implementation by @VorTechnix ### Bugfixes and changes - Don't warn on failed registration of `//flora` → [`//bonemeal`](https://worldeditadditions.mooncarrot.space/Reference/#bonemeal) if the `bonemeal` mod isn't installed (e.g. in MineClone2) - thanks @VorTechnix in #106 diff --git a/Chat-Command-Reference.md b/Chat-Command-Reference.md index 6ae04c8..d6cffde 100644 --- a/Chat-Command-Reference.md +++ b/Chat-Command-Reference.md @@ -1118,6 +1118,16 @@ This command is intended for debugging and development purposes, but if you're i //ndef glass ``` +### `//uasparse ` +Short for *Unified Axis Syntax Parse*. Parses the given UAS expression and prints the resulting vectors to the chat window. + +```weacmd +//uasparse front right 5 +//uasparse y 12 h -2 +//uasparse left 3 up 5 -front 7 +//uasparse -z 12 -y -2 x -2 +``` + ## Selection diff --git a/README.md b/README.md index 5c03eda..71287e4 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ The detailed explanations have moved! Check them out [here](https://worldeditadd - [`//count`](https://worldeditadditions.mooncarrot.space/Reference/#count) - [`//basename `](https://worldeditadditions.mooncarrot.space/Reference/#basename) - [`//ngroups [v[erbose]]`](https://worldeditadditions.mooncarrot.space/Reference/#ngroups) + - [`//uasparse `](https://worldeditadditions.mooncarrot.space/Reference/#uasparse) _(new in v1.15)_ ### Selection - [~~`//scol`~~ DEPRECATED](https://worldeditadditions.mooncarrot.space/Reference/#scol) @@ -80,10 +81,10 @@ The detailed explanations have moved! Check them out [here](https://worldeditadd - [~~`//scube`~~ DEPRECATED](https://worldeditadditions.mooncarrot.space/Reference/#scube) - [`//scloud <0-6|stop|reset>`](https://worldeditadditions.mooncarrot.space/Reference/#scloud) - [`//scentre`](https://worldeditadditions.mooncarrot.space/Reference/#scentre) - - [`//sgrow `](https://worldeditadditions.mooncarrot.space/Reference/#sgrow) + - [`//sgrow `](https://worldeditadditions.mooncarrot.space/Reference/#sgrow) _(new in v1.15)_ - [`//srel `](https://worldeditadditions.mooncarrot.space/Reference/#srel) - [`//smake [ []]`](https://worldeditadditions.mooncarrot.space/Reference/#smake) - - [`//sshrink `](https://worldeditadditions.mooncarrot.space/Reference/#sshrink) + - [`//sshrink `](https://worldeditadditions.mooncarrot.space/Reference/#sshrink) _(new in v1.15)_ - [`//sstack`](https://worldeditadditions.mooncarrot.space/Reference/#sstack) - [`//spush`](https://worldeditadditions.mooncarrot.space/Reference/#spush) - [`//spop`](https://worldeditadditions.mooncarrot.space/Reference/#spop) diff --git a/worldeditadditions_commands/commands/uasparse.lua b/worldeditadditions_commands/commands/uasparse.lua new file mode 100644 index 0000000..44f0015 --- /dev/null +++ b/worldeditadditions_commands/commands/uasparse.lua @@ -0,0 +1,29 @@ +local wea_c = worldeditadditions_core +-- local Vector3 = wea_c.Vector3 + +-- ██ ██ █████ ███████ ██████ █████ ██████ ███████ ███████ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ███████ ███████ ██████ ███████ ██████ ███████ █████ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██████ ██ ██ ███████ ██ ██ ██ ██ ██ ███████ ███████ + +worldeditadditions_core.register_command("uasparse", { + params = "", + description = "Returns min and max vectors for given inputs", + privs = { worldedit = true }, + -- require_pos = 2, + parse = function(params_text) + local ret = wea_c.split(params_text) + if #ret < 1 then return false, "UASPARSE: No params found!" + else return true, ret end + end, + func = function(name, params_text) + local facing = wea_c.player_dir(name) + local min, max = wea_c.parse.directions(params_text, facing) + if not min then + return false, max + else + return true, "Min: "..min.." Max: "..max + end + end +})