Compare commits
105 Commits
1.2
...
341014f94a
Author | SHA1 | Date | |
---|---|---|---|
341014f94a | |||
b84aa8508a | |||
17df0bbf71 | |||
36b14413e0 | |||
1fc6d93112 | |||
ccfb6b4d61 | |||
8f60e6f729 | |||
8f86a2120c | |||
b4202ea779 | |||
689ff90a78 | |||
bf55f52197 | |||
79e5e64c44 | |||
375fbf3c68 | |||
cc3aab00bc | |||
eff01bc8e7 | |||
099d5047bd | |||
7f7e928dd9 | |||
1a9f66f091 | |||
7a5d76a9bc | |||
5260f595c6 | |||
7a645eba05 | |||
9417f2bbf1 | |||
abc9efeeb8 | |||
c223ca4cec | |||
c8afa95542 | |||
670e421f57 | |||
770601dd5d | |||
2f2f5a7def | |||
7f87f1658e | |||
4378750498 | |||
2f26fb7645 | |||
f1b6da3c20 | |||
418a30c89e | |||
2f535dd053 | |||
867cd6edc7 | |||
4918610c43 | |||
edd27636a6 | |||
7d0811fd47 | |||
4d08a1cc55 | |||
34844b2d38 | |||
0f5dcc790d | |||
37de177f72 | |||
f285a55dd5 | |||
9b26034aea | |||
963a9f6b96 | |||
5e8bfd5166 | |||
06a3b63578 | |||
5e47af8773 | |||
da51c688d2 | |||
ab93871877 | |||
116ae25ebd | |||
18444379a1 | |||
974dcaa918 | |||
abdecd4239 | |||
9c38b9f6ad | |||
7833b68c85 | |||
03bef18272 | |||
91d02f6f5b | |||
8feaf8a21d | |||
5bab991e0b | |||
9bb0ad0442 | |||
63a7069671 | |||
79097dc6c8 | |||
3bc7a0f97d | |||
45acf09e4a | |||
adab528f8a | |||
26b6682587 | |||
b4826aa821 | |||
a0181ea897 | |||
2a4aaae8a2 | |||
f6298d7b87 | |||
68f7bcc728 | |||
0919f7cab3 | |||
de566d2e3e | |||
cc897150f2 | |||
f39a8e264d | |||
da5abec273 | |||
ff53a71d58 | |||
0edcd1a59d | |||
a1b6a34e61 | |||
f589c988b1 | |||
f28d9b8d35 | |||
b8453a0e0b | |||
0a16f11d93 | |||
b50294d10c | |||
324eb556f6 | |||
3ffecdd9c4 | |||
40b49ee9bc | |||
4f2c7b18cc | |||
b2e086f9ec | |||
d1cbd420bb | |||
0aeee79af6 | |||
f242f2f722 | |||
f8e57559ec | |||
b2b2b9364d | |||
b37605943b | |||
f7256633c0 | |||
99fa0ebd75 | |||
a97cccd2a1 | |||
3322ef90c4 | |||
b259906fd0 | |||
12270dc094 | |||
415000e797 | |||
7b1deb1b61 | |||
4605596215 |
15
.github/workflows/check.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
name: "Check"
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: "Luacheck"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: apt
|
||||
run: sudo apt-get install -y luarocks
|
||||
- name: luacheck install
|
||||
run: luarocks install --local luacheck
|
||||
- name: luacheck run
|
||||
run: $HOME/.luarocks/bin/luacheck ./
|
11
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
name: "Test"
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: "Unittests"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run tests
|
||||
run: MINETEST_VER=latest ./.util/run_tests.sh
|
7
.luacheckrc
Normal file
@ -0,0 +1,7 @@
|
||||
read_globals = {"minetest", "vector", "VoxelArea", "ItemStack",
|
||||
"table",
|
||||
"unified_inventory", "sfinv", "smart_inventory", "inventory_plus"
|
||||
}
|
||||
globals = {"worldedit"}
|
||||
-- Ignore these errors until someone decides to fix them
|
||||
ignore = {"212", "213", "411", "412", "421", "422", "431", "432", "631"}
|
30
.util/run_tests.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
tempdir=/tmp/mt
|
||||
confpath=$tempdir/minetest.conf
|
||||
worldpath=$tempdir/world
|
||||
|
||||
use_docker=y
|
||||
[ -x ../../bin/minetestserver ] && use_docker=
|
||||
|
||||
rm -rf $tempdir
|
||||
mkdir -p $worldpath
|
||||
# the docker image doesn't have devtest
|
||||
[ -n "$use_docker" ] || printf '%s\n' gameid=devtest >$worldpath/world.mt
|
||||
printf '%s\n' mg_name=singlenode '[end_of_params]' >$worldpath/map_meta.txt
|
||||
printf '%s\n' worldedit_run_tests=true max_forceloaded_blocks=9999 >$confpath
|
||||
|
||||
if [ -n "$use_docker" ]; then
|
||||
chmod -R 777 $tempdir
|
||||
docker run --rm -i \
|
||||
-v $confpath:/etc/minetest/minetest.conf \
|
||||
-v $tempdir:/var/lib/minetest/.minetest \
|
||||
-v "$PWD/worldedit":/var/lib/minetest/.minetest/world/worldmods/worldedit \
|
||||
registry.gitlab.com/minetest/minetest/server:${MINETEST_VER}
|
||||
else
|
||||
mkdir $worldpath/worldmods
|
||||
ln -s "$PWD/worldedit" $worldpath/worldmods/worldedit
|
||||
../../bin/minetestserver --config $confpath --world $worldpath --logfile /dev/null
|
||||
fi
|
||||
|
||||
test -f $worldpath/tests_ok || exit 1
|
||||
exit 0
|
161
ChatCommands.md
@ -29,24 +29,26 @@ Many commands also have shorter names that can be typed faster. For example, if
|
||||
|
||||
### `//about`
|
||||
|
||||
Get information about the mod.
|
||||
Get information about the WorldEdit mod.
|
||||
|
||||
//about
|
||||
|
||||
### `//inspect on/off/1/0/true/false/yes/no/enable/disable/<blank>`
|
||||
### `//help [all/<cmd>]`
|
||||
|
||||
Get help for WorldEdit commands. `all` shows all WorldEdit commands, `<cmd>`
|
||||
the help text for the given command.
|
||||
|
||||
//help
|
||||
//help all
|
||||
//help hollowpyramid
|
||||
|
||||
|
||||
### `//inspect [on/off/1/0/true/false/yes/no/enable/disable]`
|
||||
|
||||
Enable or disable node inspection.
|
||||
|
||||
//inspect on
|
||||
//inspect off
|
||||
//inspect 1
|
||||
//inspect 0
|
||||
//inspect true
|
||||
//inspect false
|
||||
//inspect yes
|
||||
//inspect no
|
||||
//inspect enable
|
||||
//inspect disable
|
||||
//inspect
|
||||
|
||||
### `//reset`
|
||||
@ -81,18 +83,19 @@ Set WorldEdit region position 2 to the player's location.
|
||||
|
||||
### `//p set/set1/set2/get`
|
||||
|
||||
Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region.
|
||||
Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by
|
||||
punching nodes, or print the current WorldEdit region.
|
||||
|
||||
//p set
|
||||
//p set1
|
||||
//p set2
|
||||
//p get
|
||||
|
||||
### `//fixedpos set1 x y z`
|
||||
### `//fixedpos set1/set2 <x> <y> <z>`
|
||||
|
||||
Set a WorldEdit region position to the position at (`<x>`, `<y>`, `<z>`).
|
||||
Set the WorldEdit region position 1 or 2 to the position (`<x>`, `<y>`, `<z>`).
|
||||
|
||||
//fixedpos set1 0 0 0
|
||||
//fixedpos set1 0 0 0
|
||||
//fixedpos set1 -30 5 28
|
||||
//fixedpos set2 1004 -200 432
|
||||
|
||||
@ -121,14 +124,19 @@ Set the current WorldEdit region to `<node>`.
|
||||
|
||||
Set the param2 value of all nodes in the current WorldEdit region to `<param2>`.
|
||||
|
||||
### `//mix <node1> ...`
|
||||
//param2 8
|
||||
|
||||
Fill the current WorldEdit region with a random mix of `<node1>`, `...`.
|
||||
### `//mix <node1> [count1] <node2> [count2] ...`
|
||||
|
||||
Fill the current WorldEdit region with a random mix of `<node1>`, `<node2>`, `...`.
|
||||
Weightings can be optionally specified via the `[count1]`, `[count2]`, `...` parameters after a node name.
|
||||
|
||||
//mix air
|
||||
//mix cactus stone glass sandstone
|
||||
//mix Bronze
|
||||
//mix default:cobble air
|
||||
//mix stone 3 dirt 2
|
||||
//mix cobblestone 8 stoneblock 2 stonebrick
|
||||
|
||||
### `//replace <search node> <replace node>`
|
||||
|
||||
@ -150,13 +158,15 @@ Replace all nodes other than `<search node>` with `<replace node>` in the curren
|
||||
|
||||
### `//hollowcube <width> <height> <length> <node>`
|
||||
|
||||
Adds a hollow cube with its ground level centered at WorldEdit position 1 with dimensions `<width>` x `<height>` x `<length>`, composed of `<node>`.
|
||||
Adds a hollow cube with its ground level centered at WorldEdit position 1 with
|
||||
dimensions `<width>` x `<height>` x `<length>`, composed of `<node>`.
|
||||
|
||||
//hollowcube 6 5 6 Diamond Block
|
||||
|
||||
### `//cube <width> <height> <length> <node>`
|
||||
|
||||
Adds a cube with its ground level centered at WorldEdit position 1 with dimensions `<width>` x `<height>` x `<length>`, composed of `<node>`.
|
||||
Adds a cube with its ground level centered at WorldEdit position 1 with
|
||||
dimensions `<width>` x `<height>` x `<length>`, composed of `<node>`.
|
||||
|
||||
//cube 6 5 6 Diamond Block
|
||||
//cube 7 2 1 default:cobble
|
||||
@ -195,7 +205,8 @@ Add dome centered at WorldEdit position 1 with radius `<radius>`, composed of `<
|
||||
|
||||
### `//hollowcylinder x/y/z/? <length> <radius1> [radius2] <node>`
|
||||
|
||||
Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length `<length>`, base radius `<radius1>` (and top radius `[radius2]`), composed of `<node>`.
|
||||
Add hollow cylinder at WorldEdit position 1 along the given axis with length `<length>`,
|
||||
base radius `<radius1>` (and top radius `[radius2]`), composed of `<node>`.
|
||||
|
||||
Despite its name this command allows you to create cones (`radius2` = 0) as well as any shapes inbetween (0 < `radius2` < `radius1`).
|
||||
Swapping `radius1` and `radius2` will create the same object but upside-down.
|
||||
@ -211,7 +222,8 @@ Swapping `radius1` and `radius2` will create the same object but upside-down.
|
||||
|
||||
### `//cylinder x/y/z/? <length> <radius1> [radius2] <node>`
|
||||
|
||||
Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length `<length>`, base radius `<radius1>` (and top radius `[radius2]`), composed of `<node>`.
|
||||
Add cylinder at WorldEdit position 1 along the given axis with length `<length>`,
|
||||
base radius `<radius1>` (and top radius `[radius2]`), composed of `<node>`.
|
||||
Can also create shapes other than cylinders, e.g. cones (see documentation above).
|
||||
|
||||
//cylinder x +5 8 Bronze Block
|
||||
@ -223,18 +235,18 @@ Can also create shapes other than cylinders, e.g. cones (see documentation above
|
||||
//cylinder x 6 0 5 Dirt
|
||||
//cylinder z 20 10 20 default:desert_stone
|
||||
|
||||
### `//hollowpyramid x/y/z? <height> <node>`
|
||||
### `//hollowpyramid x/y/z/? <height> <node>`
|
||||
|
||||
Add hollow pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height `<height>`, composed of `<node>`.
|
||||
Add hollow pyramid centered at WorldEdit position 1 along the given axis with height `<height>` composed of `<node>`.
|
||||
|
||||
//hollowpyramid x 8 Diamond Block
|
||||
//hollowpyramid y -5 glass
|
||||
//hollowpyramid z 2 mesecons:wire_00000000_off
|
||||
//hollowpyramid ? 12 mesecons:wire_00000000_off
|
||||
|
||||
### `//pyramid x/y/z? <height> <node>`
|
||||
### `//pyramid x/y/z/? <height> <node>`
|
||||
|
||||
Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height `<height>`, composed of `<node>`.
|
||||
Add pyramid centered at WorldEdit position 1 along the given axis with height `<height>` composed of `<node>`.
|
||||
|
||||
//pyramid x 8 Diamond Block
|
||||
//pyramid y -5 glass
|
||||
@ -243,7 +255,8 @@ Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height
|
||||
|
||||
### `//spiral <length> <height> <spacer> <node>`
|
||||
|
||||
Add spiral centered at WorldEdit position 1 with side length `<length>`, height `<height>`, space between walls `<spacer>`, composed of `<node>`.
|
||||
Add spiral centered at WorldEdit position 1 with side length `<length>`,
|
||||
height `<height>`, space between walls `<spacer>`, composed of `<node>`.
|
||||
|
||||
//spiral 20 5 3 Diamond Block
|
||||
//spiral 5 2 1 glass
|
||||
@ -251,7 +264,7 @@ Add spiral centered at WorldEdit position 1 with side length `<length>`, height
|
||||
|
||||
### `//copy x/y/z/? <amount>`
|
||||
|
||||
Copy the current WorldEdit region along the x/y/z/? axis by `<amount>` nodes.
|
||||
Copy the current WorldEdit region along the given axis by `<amount>` nodes.
|
||||
|
||||
//copy x 15
|
||||
//copy y -7
|
||||
@ -260,7 +273,7 @@ Copy the current WorldEdit region along the x/y/z/? axis by `<amount>` nodes.
|
||||
|
||||
### `//move x/y/z/? <amount>`
|
||||
|
||||
Move the current WorldEdit positions and region along the x/y/z/? axis by `<amount>` nodes.
|
||||
Move the current WorldEdit positions and region along the given axis by `<amount>` nodes.
|
||||
|
||||
//move x 15
|
||||
//move y -7
|
||||
@ -269,7 +282,7 @@ Move the current WorldEdit positions and region along the x/y/z/? axis by `<amou
|
||||
|
||||
### `//stack x/y/z/? <count>`
|
||||
|
||||
Stack the current WorldEdit region along the x/y/z/? axis `<count>` times.
|
||||
Stack the current WorldEdit region along the given axis `<count>` times.
|
||||
|
||||
//stack x 3
|
||||
//stack y -1
|
||||
@ -283,35 +296,34 @@ Stack the current WorldEdit region `<count>` times by offset `<x>`, `<y>`, `<z>`
|
||||
//stack2 5 3 8 2
|
||||
//stack2 1 -1 -1 -1
|
||||
|
||||
### `//scale <factor>`
|
||||
### `//stretch <stretchx> <stretchy> <stretchz>`
|
||||
|
||||
Scale the current WorldEdit positions and region by a factor of positive integer `<factor>` with position 1 as the origin.
|
||||
Scale the current WorldEdit positions and region by a factor of
|
||||
`<stretchx>`, `<stretchy>`, `<stretchz>` along the X, Y, and Z axes,
|
||||
respectively, with position 1 as the origin.
|
||||
|
||||
//scale 2
|
||||
//scale 1
|
||||
//scale 10
|
||||
//stretch 2 2 2
|
||||
//stretch 1 2 1
|
||||
//stretch 10 20 1
|
||||
|
||||
### `//transpose x/y/z/? x/y/z/?`
|
||||
|
||||
Transpose the current WorldEdit positions and region along the x/y/z/? and x/y/z/? axes.
|
||||
Transpose the current WorldEdit positions and region along given axes.
|
||||
|
||||
//transpose x y
|
||||
//transpose x z
|
||||
//transpose y z
|
||||
//transpose ? y
|
||||
|
||||
### `//flip x/y/z/?`
|
||||
|
||||
Flip the current WorldEdit region along the x/y/z/? axis.
|
||||
Flip the current WorldEdit region along the given axis.
|
||||
|
||||
//flip x
|
||||
//flip y
|
||||
//flip z
|
||||
//flip ?
|
||||
|
||||
### `//rotate x/y/z/? <angle>`
|
||||
|
||||
Rotate the current WorldEdit positions and region along the x/y/z/? axis by angle `<angle>` (90 degree increment).
|
||||
Rotate the current WorldEdit positions and region along the given axis by angle `<angle>` (90 degree increment).
|
||||
|
||||
//rotate x 90
|
||||
//rotate y 180
|
||||
@ -339,6 +351,13 @@ Removes any fluid node within the current WorldEdit region.
|
||||
|
||||
//drain
|
||||
|
||||
### `//clearcut`
|
||||
|
||||
Removes any plant, tree or foilage-like nodes in the selected region.
|
||||
The idea is to remove anything that isn't part of the terrain, leaving a "natural" empty space ready for building.
|
||||
|
||||
//clearcut
|
||||
|
||||
### `//hide`
|
||||
|
||||
Hide all nodes in the current WorldEdit region non-destructively.
|
||||
@ -347,7 +366,7 @@ Hide all nodes in the current WorldEdit region non-destructively.
|
||||
|
||||
### `//suppress <node>`
|
||||
|
||||
Suppress all <node> in the current WorldEdit region non-destructively.
|
||||
Suppress all `<node>` in the current WorldEdit region non-destructively.
|
||||
|
||||
//suppress Diamond Block
|
||||
//suppress glass
|
||||
@ -355,7 +374,7 @@ Suppress all <node> in the current WorldEdit region non-destructively.
|
||||
|
||||
### `//highlight <node>`
|
||||
|
||||
Highlight <node> in the current WorldEdit region by hiding everything else non-destructively.
|
||||
Highlight `<node>` in the current WorldEdit region by hiding everything else non-destructively.
|
||||
|
||||
//highlight Diamond Block
|
||||
//highlight glass
|
||||
@ -399,8 +418,8 @@ Executes `<code>` as a Lua chunk in the global namespace.
|
||||
|
||||
Executes `<code>` as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region.
|
||||
|
||||
//luatransform minetest.add_node(pos, {name="default:stone"})
|
||||
//luatransform if minetest.get_node(pos).name == "air" then minetest.add_node(pos, {name="default:water_source"})
|
||||
//luatransform minetest.swap_node(pos, {name="default:stone"})
|
||||
//luatransform if minetest.get_node(pos).name == "air" then minetest.add_node(pos, {name="default:water_source"}) end
|
||||
|
||||
### `//mtschemcreate <file>`
|
||||
|
||||
@ -429,37 +448,61 @@ Clears all objects within the WorldEdit region.
|
||||
|
||||
//clearobjects
|
||||
|
||||
### `//shift x/y/z/?/up/down/left/right/front/back [+|-]<amount>`
|
||||
### `//shift x/y/z/?/up/down/left/right/front/back [+/-]<amount>`
|
||||
|
||||
Shifts the selection area by `[+|-]<amount>` without touching its contents. The shifting axis can be absolute (`x/y/z`) or
|
||||
relative (`up/down/left/right/front/back`).
|
||||
Shifts the selection area by `[+|-]<amount>` without moving its contents.
|
||||
The shifting axis can be absolute (`x/y/z`) or relative (`up/down/left/right/front/back`).
|
||||
|
||||
//shift left 5
|
||||
|
||||
### `//expand [+|-]x/y/z/?/up/down/left/right/front/back <amount> [reverse-amount]`
|
||||
### `//expand [+/-]x/y/z/?/up/down/left/right/front/back <amount> [reverse amount]`
|
||||
|
||||
Expands the selection by `<amount>` in the selected absolute or relative axis. If specified, the selection can be expanded in the
|
||||
opposite direction over the same axis by `[reverse-amount]`.
|
||||
Expands the selection by `<amount>` in the selected absolute or relative axis.
|
||||
If specified, the selection can be expanded in the opposite direction over the same axis by `[reverse amount]`.
|
||||
|
||||
//expand right 7 5
|
||||
|
||||
### `//contract [+|-]x/y/z/?/up/down/left/right/front/back <amount> [reverse-amount]`
|
||||
### `//contract [+/-]x/y/z/?/up/down/left/right/front/back <amount> [reverse amount]`
|
||||
|
||||
Contracts the selection by `<amount>` in the selected absolute or relative axis. If specified, the selection can be contracted in the
|
||||
opposite direction over the same axis by `[reverse-amount]`.
|
||||
Contracts the selection by `<amount>` in the selected absolute or relative axis.
|
||||
If specified, the selection can be contracted in the opposite direction over the same axis by `[reverse amount]`.
|
||||
|
||||
//expand right 7 5
|
||||
|
||||
### `//outset [hv] <amount>`
|
||||
### `//outset [h/v] <amount>`
|
||||
|
||||
Expands the selection in all directions by `<amount>`. If specified, the selection can be expanded horizontally in the x and z axes `[h]`
|
||||
or vertically in the y axis `[v]`.
|
||||
Expands the selection in all directions by `<amount>`. If specified,
|
||||
the selection can be expanded horizontally in the x and z axes using `h`
|
||||
or vertically in the y axis using `v`.
|
||||
|
||||
//outset v 5
|
||||
|
||||
### `//inset [hv] <amount>`
|
||||
### `//inset [h/v] <amount>`
|
||||
|
||||
Contracts the selection in all directions by `<amount>`. If specified, the selection can be contracted horizontally in the x and z axes `[h]`
|
||||
or vertically in the y axis `[v]`.
|
||||
Contracts the selection in all directions by `<amount>`. If specified,
|
||||
the selection can be contracted horizontally in the x and z axes using `h`
|
||||
or vertically in the y axis using `v`.
|
||||
|
||||
//outset v 5
|
||||
//inset h 5
|
||||
|
||||
### `//brush none/(<command> [parameters])`
|
||||
|
||||
Assigns the given `<command>` to the currently held brush item, it will be ran with the first pointed solid node (as determined via raycast) as
|
||||
WorldEdit position 1 when using that specific brush item.
|
||||
Passing `none` instead clears the command assigned to the currently held brush item.
|
||||
Note that this functionality requires the `worldedit_brush` mod enabled.
|
||||
|
||||
//brush cube 8 8 8 Cobblestone
|
||||
//brush spr 12 glass
|
||||
//brush none
|
||||
|
||||
### `//cubeapply <size>/(<sizex> <sizey> <sizez>) <command> [parameters]`
|
||||
|
||||
Selects a cube with side length of `<size>` around the WorldEdit position 1 and runs the given `<command>` on the newly selected region.
|
||||
If `<sizex>`, `<sizey>` and `<sizez>` are given, they instead specify the length of the cuboid in X, Y, Z direction.
|
||||
This is mostly useful for brushes since it allows commands such as `//replace` to be ran, but it can also be used standalone.
|
||||
|
||||
//cubeapply 10 replaceinverse air default:water_source
|
||||
//brush cubeapply 15 drain
|
||||
//brush cubeapply 12 3 12 drain
|
||||
//brush cubeapply 1 deleteblocks
|
||||
|
99
README.md
@ -1,4 +1,4 @@
|
||||
WorldEdit v1.2
|
||||
WorldEdit v1.3
|
||||
==============
|
||||
The ultimate in-game world editing tool for [Minetest](http://minetest.net/)! Tons of functionality to help with building, fixing, and more.
|
||||
|
||||
@ -11,47 +11,52 @@ For more information, see the [forum topic](https://forum.minetest.net/viewtopic
|
||||
Installing
|
||||
----------
|
||||
|
||||
If you are using Windows, consider installing this mod using [MODSTER](https://forum.minetest.net/viewtopic.php?id=6497), a super simple mod installer that will take care of everything for you. If you are using MODSTER, skip directly to step 6 in the instructions below.
|
||||
|
||||
There is a nice installation guide over at the [Minetest Wiki](http://wiki.minetest.com/wiki/Installing_mods). Here is a short summary:
|
||||
|
||||
1. Download the mod from the [official releases page](https://github.com/Uberi/Minetest-WorldEdit/releases). The download links are labelled "Source Code". If you are using Windows, you will probably want to download the ZIP version.
|
||||
2. You should have a file named `SOMETHING.zip` or `SOMETHING.tar.gz`.
|
||||
1. Download the mod from the [official releases page](https://github.com/Uberi/Minetest-WorldEdit/releases). The download links are labelled "Source Code". If you are using Windows, you'll want to download the ZIP version.
|
||||
2. You should have a file named `Minetest-WorldEdit-x.x.zip`.
|
||||
3. Extract this file using your archiver of choice. If you are using Windows, open the ZIP file and move the folder inside to a safe place outside of the ZIP file.
|
||||
4. Make sure that you now have a folder with a file named README.md inside it. If you just have another folder inside this folder, use this nested folder instead.
|
||||
4. Make sure that you now have a folder with a file named README.md inside it. If you just have another folder inside this folder, use the nested folder instead.
|
||||
5. Move this folder into the `MINETEST_FOLDER/mods` folder, where `MINETEST_FOLDER` is the folder Minetest is located in.
|
||||
6. Open Minetest to a world selection screen.
|
||||
7. Select a world you want to use WorldEdit in by left clicking on it once, and press the **Configure** button.
|
||||
8. You should have a mod selection screen. Select the one named something like `Minetest-WorldEdit` by left clicking once and press the **Enable MP** button.
|
||||
7. Select a world you want to use WorldEdit in by left clicking on it once and press the **Configure** button.
|
||||
8. You should have a mod selection screen. Select the one named something like `Minetest-WorldEdit` by left clicking once and press the **Enable Modpack** button.
|
||||
9. Press the **Save** button. You can now use WorldEdit in that world. Repeat steps 7 to 9 to enable WorldEdit for other worlds too.
|
||||
|
||||
If you are having trouble, try asking for help in the [IRC channel](http://webchat.freenode.net/?channels=#minetest) (faster but may not always have helpers online) or ask on the [forum topic](https://forum.minetest.net/viewtopic.php?id=572) (slower but more likely to get help).
|
||||
If you are having trouble, try asking for help in the [IRC channel](https://web.libera.chat/#minetest) (faster but may not always have helpers online)
|
||||
or ask on the [forum topic](https://forum.minetest.net/viewtopic.php?id=572) (slower but more likely to get help).
|
||||
|
||||
Usage
|
||||
-----
|
||||
WorldEdit works primarily through the WorldEdit GUI and chat commands. Depending on your key bindings, you can invoke chat entry with the "t" key, and open the chat console with the "F10" key.
|
||||
WorldEdit works primarily through the WorldEdit GUI and chat commands. Depending on your key bindings, you can invoke chat entry with the "T" key and open the chat console with the "F10" key.
|
||||
|
||||
WorldEdit has a huge potential for abuse by untrusted players. Therefore, users will not be able to use WorldEdit unless they have the `worldedit` privelege. This is available by default in single player, but in multiplayer the permission must be explicitly given by someone with the right credentials, using the follwoing chat command: `/grant <player name> worldedit`. This privelege can later be removed using the following chat command: `/revoke <player name> worldedit`.
|
||||
WorldEdit has a huge potential for abuse by untrusted players. Therefore, users will not be able to use WorldEdit unless they have the `worldedit` privilege.
|
||||
This is available by default in singleplayer, but in multiplayer the permission must be explicitly given by someone with the right credentials,
|
||||
using the following chat command: `/grant <player name> worldedit`. This privilege can later be removed using the following chat command: `/revoke <player name> worldedit`.
|
||||
|
||||
Certain functions/commands such as WorldEdit `//lua` and `//luatransform` chat commands additionally require the `server` privilege. This is because it is extremely dangerous to give access to these commands to untrusted players, since they essentially are able to control the computer the server is running on. Give this privilege only to people you trust with your computer.
|
||||
Certain functions/commands such as WorldEdit `//lua` and `//luatransform` chat commands additionally require the `server` privilege.
|
||||
This is because it is extremely dangerous to give access to these commands to untrusted players, since they essentially are able to control the computer the server is running on.
|
||||
Give this privilege only to people you trust with your computer.
|
||||
|
||||
For in-game information about these commands, type `/help <command name>` in the chat. For example, to learn more about the `//copy` command, simply type `/help /copy` to display information relevant to copying a region.
|
||||
For in-game information about these commands, type `//help <command name>` in the chat. For example, to learn more about the `//copy` command, simply type `//help copy` to display information relevant to copying a region.
|
||||
|
||||
Interface
|
||||
---------
|
||||
WorldEdit is accessed in-game in two main ways.
|
||||
|
||||
The GUI adds a screen to each player's inventory that gives access to various WorldEdit functions. The [tutorial](Tutorial.md) and the [Chat Commands Reference](ChatCommands.md) may be helpful in learning to use it.
|
||||
The GUI adds a screen to each player's inventory that gives access to various WorldEdit functions. The [tutorial](Tutorial.md) may be helpful in learning to use it.
|
||||
|
||||
The chat interface adds many chat commands that perform various WorldEdit powered tasks. It is documented in the [Chat Commands Reference](ChatCommands.md).
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
This mod supports Minetest versions 0.4.8 and newer. Older versions of WorldEdit may work with older versions of Minetest, but are not recommended or supported.
|
||||
This mod supports Minetest versions 5.0 and newer. Older versions of WorldEdit may work with older versions of Minetest, but are not recommended or supported.
|
||||
|
||||
WorldEdit works quite well with other mods, and does not have any known mod conflicts.
|
||||
WorldEdit works quite well with other mods and does not have any known mod conflicts.
|
||||
|
||||
WorldEdit GUI requires one of [sfinv](https://github.com/minetest/minetest_game/tree/master/mods/sfinv) (included in minetest_game since 0.4.15), [Unified Inventory](https://forum.minetest.net/viewtopic.php?id=3933) or [Inventory++](https://forum.minetest.net/viewtopic.php?id=6204).
|
||||
WorldEdit GUI requires one of [sfinv](https://github.com/minetest/minetest_game/tree/master/mods/sfinv) (included in minetest_game),
|
||||
[Unified Inventory](https://forum.minetest.net/viewtopic.php?t=12767),
|
||||
[Inventory++](https://forum.minetest.net/viewtopic.php?id=6204) or [Smart Inventory](https://forum.minetest.net/viewtopic.php?t=16597).
|
||||
|
||||
If you use any other inventory manager mods, note that they may conflict with the WorldEdit GUI. If this is the case, it may be necessary to disable them.
|
||||
|
||||
@ -59,9 +64,9 @@ WorldEdit API
|
||||
-------------
|
||||
WorldEdit exposes all significant functionality in a simple Lua interface.
|
||||
|
||||
Adding WorldEdit to the file "depends.txt" in your mod gives you access to all of the `worldedit` functions. The API is useful for tasks such as high-performance node manipulation, alternative interfaces, and map creation.
|
||||
Adding WorldEdit as a dependency to your mod gives you access to all of the `worldedit` functions. The API is useful for tasks such as high-performance node manipulation, alternative interfaces and map creation.
|
||||
|
||||
AGPLv3 compatible mods may further include WorldEdit files in their own mods. This may be useful if a modder wishes to completely avoid any dependencies on WorldEdit. Note that it is required to give credit to the authors.
|
||||
AGPLv3 compatible mods may further include WorldEdit files in their own mods. This can be useful if a modder wishes to completely avoid any dependency on WorldEdit. Note that it is required to give credit to the authors in this case.
|
||||
|
||||
This API is documented in the [WorldEdit API Reference](WorldEdit%20API.md).
|
||||
|
||||
@ -79,13 +84,16 @@ Nodes
|
||||
-----
|
||||
Node names are required for many types of commands that identify or modify specific types of nodes. They can be specified in a number of ways.
|
||||
|
||||
First, by description - the tooltip that appears when hovering over the item in an inventory. This is case insensitive and includes values such as "Cobblestone" and "bronze block". Note that certain commands (namely, `//replace` and `//replaceinverse`) do not support descriptions that contain spaces in the `<searchnode>` field.
|
||||
First, by description - the tooltip that appears when hovering over the item in an inventory. This is case insensitive and includes values such as "Cobblestone" and "bronze block".
|
||||
Note that certain commands (namely, `//replace` and `//replaceinverse`) do not support descriptions that contain spaces in the `<searchnode>` field.
|
||||
|
||||
Second, by name - the node name that is defined by code, but without the mod name prefix. This is case sensitive and includes values such as "piston_normal_off" and "cactus". Nodes defined in the `default` mod always take precedence over other nodes when searching for the correct one, and if there are multiple possible nodes (such as "a:celery" and "b:celery"), one is chosen in no particular order.
|
||||
Second, by name - the node name that is defined by code, but without the mod name prefix. This is case sensitive and includes values such as "piston_normal_off" and "cactus".
|
||||
If there are multiple possible nodes (such as "a:celery" and "b:celery"), one is chosen in no particular order.
|
||||
|
||||
Finally, by full name - the unambiguous identifier of the node, prefixes and all. This is case sensitive and includes values such as "default:stone" and "mesecons:wire_00000000_off".
|
||||
|
||||
The node name "air" can be used anywhere a normal node name can, and acts as a blank node. This is useful for clearing or removing nodes. For example, `//set air` would remove all the nodes in the current WorldEdit region. Similarly, `//sphere 10 air`, when WorldEdit position 1 underground, would dig a large sphere out of the ground.
|
||||
The node name "air" can be used anywhere a normal node name can and acts as a blank node. This is useful for clearing or removing nodes.
|
||||
For example, `//set air` would remove all the nodes in the current WorldEdit region. Similarly, `//sphere 10 air`, when WorldEdit position 1 underground, would dig a large sphere out of the ground.
|
||||
|
||||
Regions
|
||||
-------
|
||||
@ -93,11 +101,11 @@ Most WorldEdit commands operate on regions. Regions are a set of two positions t
|
||||
|
||||
Each positions together define two opposing corners of the cube. With two opposing corners it is possible to determine both the location and dimensions of the region.
|
||||
|
||||
Regions are not saved between server restarts. They start off as empty regions, and cannot be used with most WorldEdit commands until they are set to valid values.
|
||||
Regions are not saved between server restarts. They start off as empty regions and cannot be used with most WorldEdit commands until they are set to valid values.
|
||||
|
||||
Markers
|
||||
-------
|
||||
Entities are used to mark the location of the WorldEdit regions. They appear as boxes containing the number 1 or 2, and represent position 1 and 2 of the WorldEdit region, respectively.
|
||||
Entities are used to mark the location of the WorldEdit regions. They appear as boxes containing the number 1 or 2 and represent the first and second position of the WorldEdit region, respectively.
|
||||
|
||||
To remove the entities, simply punch them. This does not reset the positions themselves.
|
||||
|
||||
@ -105,9 +113,11 @@ Schematics
|
||||
----------
|
||||
WorldEdit supports two different types of schematics.
|
||||
|
||||
The first is the WorldEdit Schematic format, with the file extension ".we", and in some older versions, ".wem". There have been several previous versions of the WorldEdit Schematic format, but WorldEdit is capable of loading any past versions, and will always support them - there is no need to worry about schematics becoming obselete.
|
||||
The first is the WorldEdit Schematic format, with the file extension ".we", and in some older versions, ".wem".
|
||||
There have been several previous versions of the WorldEdit Schematic format, but WorldEdit is capable of loading any past versions, and will always support them - there is no need to worry about schematics becoming obsolete.
|
||||
|
||||
As of version 5, WorldEdit schematics include a header. The header is seperated from the content by a colon (`:`). It contains fields seperated by commas (`,`). Currently only one field is used, which contains the version in ASCII decimal.
|
||||
As of version 5, WorldEdit schematics include a header. The header is seperated from the content by a colon (`:`). It may contain fields seperated by commas (`,`).
|
||||
Currently only one field is used, which contains the version as an ASCII decimal.
|
||||
|
||||
The current version of the WorldEdit Schematic format is essentially an array of node data tables in Lua 5.1 table syntax preceded by a header.
|
||||
Specifically it looks like this:
|
||||
@ -130,32 +140,53 @@ The ordering of the values and minor aspects of the syntax, such as trailing com
|
||||
|
||||
The WorldEdit Schematic format is accessed via the WorldEdit API, or WorldEdit serialization chat commands such as `//serialize` and `//deserialize`.
|
||||
|
||||
The second is the Minetest Schematic format (MTS). The details of this format may be found in the Minetest documentation and are out of the scope of this document. Access to this format is done via specialized MTS commands such as `//mtschemcreate` and `//mtschemplace`.
|
||||
The second is the Minetest Schematic format (MTS). The details of this format may be found in the Minetest documentation and are out of the scope of this document.
|
||||
Access to this format is done via specialized MTS commands such as `//mtschemcreate` and `//mtschemplace`.
|
||||
|
||||
Authors
|
||||
-------
|
||||
WorldEdit would not be possible without the contributions of many developers and designers. Below, they are listed alphabetically:
|
||||
|
||||
cheapie
|
||||
Alexander Weber
|
||||
ANAND
|
||||
beyondlimits
|
||||
Carter Kolwey
|
||||
cornernote
|
||||
cyisfor
|
||||
danierukun
|
||||
Cy
|
||||
Daniel Sosa
|
||||
electricface
|
||||
est31
|
||||
Eugen Wesseloh
|
||||
h3ndrik
|
||||
HybridDog
|
||||
Isidor Zeuner
|
||||
Jean-Patrick Guerrero
|
||||
Joseph Pickard
|
||||
kaeza
|
||||
khonkhortisan
|
||||
pickardjoe
|
||||
kilbith
|
||||
KodexKy
|
||||
Kyle
|
||||
MT-Modder
|
||||
Niwla23
|
||||
Panquesito7
|
||||
Pedro Gimeno
|
||||
Rui
|
||||
Sebastien Ponce
|
||||
sfan5
|
||||
ShadowNinja
|
||||
shivajiva101
|
||||
spillz
|
||||
Starbeamrainbowlabs
|
||||
TalkLounge
|
||||
tenplus1
|
||||
Uberi/Temperest
|
||||
Wuzzy
|
||||
|
||||
License
|
||||
-------
|
||||
Copyright 2013 sfan5, Anthony Zhang (Uberi/Temperest), and Brett O'Donnell (cornernote).
|
||||
Copyright (c) 2012 sfan5, Anthony Zhang (Uberi/Temperest), and Brett O'Donnell (cornernote).
|
||||
|
||||
This mod is licensed under the [GNU Affero General Public License](http://www.gnu.org/licenses/agpl-3.0.html).
|
||||
This mod is licensed under the [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html).
|
||||
|
||||
Basically, this means everyone is free to use, modify, and distribute the files, as long as these modifications are also licensed the same way.
|
||||
Most importantly, the Affero variant of the GPL requires you to publish your modifications in source form, even if the mod is run only on the server, and not distributed.
|
||||
|
12
Tutorial.md
@ -1,13 +1,11 @@
|
||||
WorldEdit Tutorial
|
||||
==================
|
||||
This is a step-by-step tutorial outlining the basic usage of WorldEdit. For more information, see the [README](README.md).
|
||||
This is a step-by-step tutorial outlining the basic usage of WorldEdit.
|
||||
|
||||
Let's start with a few assumptions:
|
||||
|
||||
* You have a compatible version of Minetest working.
|
||||
* See the [README](README.md) for compatibility information.
|
||||
* You have a compatible version of Minetest working, that is 5.0 or later.
|
||||
* You have WorldEdit installed as a mod.
|
||||
* If using Windows, [MODSTER](https://forum.minetest.net/viewtopic.php?pid=101463) makes installing mods totally painless.
|
||||
* Simply download the file, extract the archive, and move it to the correct mod folder for Minetest.
|
||||
* See the installation instructions in [README](README.md) if you need more details.
|
||||
* You are familiar with the basics of the game.
|
||||
@ -59,7 +57,7 @@ Look at the place between the two markers: it is now filled with MESE blocks!
|
||||
|
||||
The `//set <node>` command fills the region with whatever node you want. It is a region-oriented command, which means it works inside the WorldEdit region only.
|
||||
|
||||
Now, try a few different variations, such as `//set torch`, `//set cobble`, and `//set water`.
|
||||
Now, try a few different variations, such as `//set torch`, `//set cobble`, and `//set water source`.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
@ -75,7 +73,7 @@ Look at the place between the two markers: it is now filled with MESE blocks!
|
||||
|
||||
The "Set Nodes" function fills the region with whatever node you want. It is a region-oriented command, which means it works inside the WorldEdit region only.
|
||||
|
||||
Now, try a few different variations on the node name, such as "torch", "cobble", and "water".
|
||||
Now, try a few different variations on the node name, such as "torch", "cobble", and "water source".
|
||||
|
||||
Step 3: Position commands
|
||||
-------------------------
|
||||
@ -117,4 +115,4 @@ A very useful command to check out is the `//save <schematic>` command, which ca
|
||||
|
||||
This only scratches the surface of what WorldEdit is capable of. Most of the functions in the WorldEdit GUI correspond to chat commands, and so the [Chat Commands Reference](ChatCommands.md) may be useful if you get stuck.
|
||||
|
||||
It is helpful to explore the various buttons in the interface and check out what they do. Learning the chat command interface is also useful if you use WorldEdit intensively - an experienced chat command user can usually work faster than an experienced WorldEdit GUI user.
|
||||
It is helpful to explore the various buttons in the interface and check out what they do. Learning the chat command interface is also useful if you use WorldEdit intensively - an experienced chat command user can usually work faster than an experienced WorldEdit GUI user.
|
||||
|
@ -24,6 +24,7 @@ Contained in manipulations.lua, this module allows several node operations to be
|
||||
### count = worldedit.set(pos1, pos2, node_name)
|
||||
|
||||
Sets a region defined by positions `pos1` and `pos2` to `node_name`. To clear a region, use "air" as the value of `node_name`.
|
||||
If `node_name` is a list of nodes, each set node is randomly picked from it.
|
||||
|
||||
Returns the number of nodes set.
|
||||
|
||||
@ -54,6 +55,7 @@ Returns the number of nodes copied.
|
||||
### count = worldedit.copy2(pos1, pos2, off)
|
||||
|
||||
Copies the region defined by positions `pos1` and `pos2` by the offset vector `off`.
|
||||
Note that the offset needs to be big enough that there is no overlap.
|
||||
|
||||
Returns the number of nodes copied.
|
||||
|
||||
@ -72,6 +74,7 @@ Returns the number of nodes stacked.
|
||||
### count = worldedit.stack2(pos1, pos2, direction, amount)
|
||||
|
||||
Duplicates the region defined by positions `pos1` and `pos2` `amount` times with offset vector `direction`.
|
||||
Note that the offset vector needs to be big enough that there is no overlap.
|
||||
|
||||
Returns the number of nodes stacked.
|
||||
|
||||
@ -193,7 +196,7 @@ Returns the number of nodes restored.
|
||||
|
||||
Serialization
|
||||
-------------
|
||||
Contained in serialization.lua, this module allows regions of nodes to be serialized and deserialized to formats suitable for use outside MineTest.
|
||||
Contained in serialization.lua, this module allows regions of nodes to be serialized and deserialized to formats suitable for use outside Minetest.
|
||||
|
||||
### version, extra_fields, content = worldedit.read_header(value)
|
||||
|
||||
|
3
modpack.conf
Normal file
@ -0,0 +1,3 @@
|
||||
name = Minetest-WorldEdit
|
||||
description = WorldEdit is an in-game world editor. Use it to repair griefing, or just create awesome buildings in seconds.
|
||||
min_minetest_version = 5.0
|
@ -31,7 +31,7 @@ function worldedit.luatransform(pos1, pos2, code)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local pos = vector.new(pos1.x, 0, 0)
|
||||
while pos.x <= pos2.x do
|
||||
pos.y = pos1.y
|
||||
while pos.y <= pos2.y do
|
||||
|
@ -5,8 +5,8 @@
|
||||
-- `pos1` is less than or equal to the corresponding component of `pos2`.
|
||||
-- Returns the new positions.
|
||||
function worldedit.sort_pos(pos1, pos2)
|
||||
pos1 = {x=pos1.x, y=pos1.y, z=pos1.z}
|
||||
pos2 = {x=pos2.x, y=pos2.y, z=pos2.z}
|
||||
pos1 = vector.new(pos1.x, pos1.y, pos1.z)
|
||||
pos2 = vector.new(pos2.x, pos2.y, pos2.z)
|
||||
if pos1.x > pos2.x then
|
||||
pos2.x, pos1.x = pos1.x, pos2.x
|
||||
end
|
||||
@ -46,6 +46,9 @@ end
|
||||
|
||||
|
||||
function worldedit.keep_loaded(pos1, pos2)
|
||||
-- Create a vmanip and read the area from map, this
|
||||
-- causes all MapBlocks to be loaded into memory.
|
||||
-- This doesn't actually *keep* them loaded, unlike the name implies.
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos2)
|
||||
end
|
||||
@ -107,7 +110,9 @@ end
|
||||
|
||||
function mh.finish(manip, data)
|
||||
-- Update map
|
||||
manip:set_data(data)
|
||||
if data ~= nil then
|
||||
manip:set_data(data)
|
||||
end
|
||||
manip:write_to_map()
|
||||
manip:update_map()
|
||||
end
|
||||
|
@ -24,11 +24,14 @@ function worldedit.metasave(pos1, pos2, filename)
|
||||
return count
|
||||
end
|
||||
|
||||
function worldedit.metaload(originpos, filename)
|
||||
function worldedit.metaload(originpos, file_name)
|
||||
deprecated("load")
|
||||
filename = minetest.get_worldpath() .. "/schems/" .. file .. ".wem"
|
||||
local file, err = io.open(filename, "wb")
|
||||
if err then return 0 end
|
||||
local file_path = minetest.get_worldpath() ..
|
||||
"/schems/" .. file_name .. ".wem"
|
||||
local file, err = io.open(file_path, "wb")
|
||||
if err then
|
||||
return 0
|
||||
end
|
||||
local data = file:read("*a")
|
||||
return worldedit.deserialize(originpos, data)
|
||||
end
|
||||
|
@ -2,16 +2,16 @@
|
||||
worldedit.cuboid_volumetric_expand = function(name, amount)
|
||||
local pos1 = worldedit.pos1[name]
|
||||
local pos2 = worldedit.pos2[name]
|
||||
|
||||
|
||||
if pos1 == nil or pos2 == nil then
|
||||
return false, "Undefined cuboid"
|
||||
end
|
||||
|
||||
|
||||
local delta1 = vector.new()
|
||||
local delta2 = vector.new()
|
||||
local delta_dir1
|
||||
local delta_dir2
|
||||
|
||||
|
||||
delta1 = vector.add(delta1, amount)
|
||||
delta2 = vector.add(delta2, amount)
|
||||
delta_dir1, delta_dir2 = worldedit.get_expansion_directions(pos1, pos2)
|
||||
@ -19,7 +19,7 @@ worldedit.cuboid_volumetric_expand = function(name, amount)
|
||||
delta2 = vector.multiply(delta2, delta_dir2)
|
||||
worldedit.pos1[name] = vector.add(pos1, delta1)
|
||||
worldedit.pos2[name] = vector.add(pos2, delta2)
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -28,18 +28,18 @@ end
|
||||
worldedit.cuboid_linear_expand = function(name, axis, direction, amount)
|
||||
local pos1 = worldedit.pos1[name]
|
||||
local pos2 = worldedit.pos2[name]
|
||||
|
||||
|
||||
if pos1 == nil or pos2 == nil then
|
||||
return false, "undefined cuboid"
|
||||
end
|
||||
|
||||
|
||||
if direction ~= 1 and direction ~= -1 then
|
||||
return false, "invalid marker"
|
||||
end
|
||||
|
||||
|
||||
local marker = worldedit.marker_get_closest_to_axis(name, axis, direction)
|
||||
local deltavect = vector.new()
|
||||
|
||||
|
||||
if axis == 'x' then
|
||||
deltavect.x = amount * direction
|
||||
elseif axis == 'y' then
|
||||
@ -49,7 +49,7 @@ worldedit.cuboid_linear_expand = function(name, axis, direction, amount)
|
||||
else
|
||||
return false, "invalid axis"
|
||||
end
|
||||
|
||||
|
||||
worldedit.marker_move(name, marker, deltavect)
|
||||
return true
|
||||
end
|
||||
@ -59,11 +59,11 @@ end
|
||||
worldedit.cuboid_shift = function(name, axis, amount)
|
||||
local pos1 = worldedit.pos1[name]
|
||||
local pos2 = worldedit.pos2[name]
|
||||
|
||||
|
||||
if pos1 == nil or pos2 == nil then
|
||||
return false, "undefined cuboid"
|
||||
end
|
||||
|
||||
|
||||
if axis == 'x' then
|
||||
worldedit.pos1[name].x = pos1.x + amount
|
||||
worldedit.pos2[name].x = pos2.x + amount
|
||||
@ -76,7 +76,7 @@ worldedit.cuboid_shift = function(name, axis, amount)
|
||||
else
|
||||
return false, "invalid axis"
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -86,7 +86,7 @@ worldedit.marker_move = function(name, marker, deltavector)
|
||||
if marker ~= 1 and marker ~= 2 then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if marker == 1 then
|
||||
local pos = worldedit.pos1[name]
|
||||
worldedit.pos1[name] = vector.add(deltavector, pos)
|
||||
@ -94,23 +94,8 @@ worldedit.marker_move = function(name, marker, deltavector)
|
||||
local pos = worldedit.pos2[name]
|
||||
worldedit.pos2[name] = vector.add(deltavector, pos)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- Updates the location ingame of the markers
|
||||
worldedit.marker_update = function(name, marker)
|
||||
if marker == nil then
|
||||
worldedit.mark_pos1(name)
|
||||
worldedit.mark_pos2(name)
|
||||
elseif marker == 1 then
|
||||
worldedit.mark_pos1(name)
|
||||
elseif marker == 2 then
|
||||
worldedit.mark_pos2(name)
|
||||
else
|
||||
minetest.debug(
|
||||
"worldedit: Invalid execution of function update_markers")
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@ -149,10 +134,10 @@ end
|
||||
|
||||
-- Return the marker that is closest to the player
|
||||
worldedit.marker_get_closest_to_player = function(name)
|
||||
local playerpos = minetest.get_player_by_name(name):getpos()
|
||||
local playerpos = minetest.get_player_by_name(name):get_pos()
|
||||
local dist1 = vector.distance(playerpos, worldedit.pos1[name])
|
||||
local dist2 = vector.distance(playerpos, worldedit.pos2[name])
|
||||
|
||||
|
||||
if dist1 < dist2 then
|
||||
return 1
|
||||
else
|
||||
@ -165,7 +150,7 @@ end
|
||||
worldedit.marker_get_closest_to_axis = function(name, axis, direction)
|
||||
local pos1 = vector.new()
|
||||
local pos2 = vector.new()
|
||||
|
||||
|
||||
if direction ~= 1 and direction ~= -1 then
|
||||
return nil
|
||||
end
|
||||
@ -200,20 +185,20 @@ worldedit.marker_get_closest_to_axis = function(name, axis, direction)
|
||||
end
|
||||
|
||||
|
||||
-- Translates up, down, left, right, front, back to their corresponding axes and
|
||||
-- Translates up, down, left, right, front, back to their corresponding axes and
|
||||
-- directions according to faced direction
|
||||
worldedit.translate_direction = function(name, direction)
|
||||
local axis, dir = worldedit.player_axis(name)
|
||||
local resaxis, resdir
|
||||
|
||||
|
||||
if direction == "up" then
|
||||
return 'y', 1
|
||||
end
|
||||
|
||||
|
||||
if direction == "down" then
|
||||
return 'y', -1
|
||||
end
|
||||
|
||||
|
||||
if direction == "front" then
|
||||
if axis == "y" then
|
||||
resaxis = nil
|
||||
@ -223,7 +208,7 @@ worldedit.translate_direction = function(name, direction)
|
||||
resdir = dir
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if direction == "back" then
|
||||
if axis == "y" then
|
||||
resaxis = nil
|
||||
@ -233,7 +218,7 @@ worldedit.translate_direction = function(name, direction)
|
||||
resdir = -dir
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if direction == "left" then
|
||||
if axis == 'x' then
|
||||
resaxis = 'z'
|
||||
@ -243,7 +228,7 @@ worldedit.translate_direction = function(name, direction)
|
||||
resdir = -dir
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if direction == "right" then
|
||||
if axis == 'x' then
|
||||
resaxis = 'z'
|
||||
@ -253,6 +238,6 @@ worldedit.translate_direction = function(name, direction)
|
||||
resdir = dir
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return resaxis, resdir
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- Worldedit.
|
||||
--- WorldEdit mod for the Minetest engine
|
||||
-- @module worldedit
|
||||
-- @release 1.2
|
||||
-- @copyright 2013 sfan5, Anthony Zhang (Uberi/Temperest), and Brett O'Donnell (cornernote).
|
||||
-- @release 1.3
|
||||
-- @copyright 2012 sfan5, Anthony Zhang (Uberi/Temperest), and Brett O'Donnell (cornernote)
|
||||
-- @license GNU Affero General Public License version 3 (AGPLv3)
|
||||
-- @author sfan5
|
||||
-- @author Anthony Zang (Uberi/Temperest)
|
||||
@ -11,18 +11,10 @@
|
||||
|
||||
worldedit = {}
|
||||
|
||||
local ver = {major=1, minor=2}
|
||||
local ver = {major=1, minor=3}
|
||||
worldedit.version = ver
|
||||
worldedit.version_string = string.format("%d.%d", ver.major, ver.minor)
|
||||
|
||||
if not minetest.get_voxel_manip then
|
||||
local err_msg = "This version of WorldEdit requires Minetest 0.4.8 or later! You have an old version."
|
||||
minetest.log("error", string.rep("#", 128))
|
||||
minetest.log("error", err_msg)
|
||||
minetest.log("error", string.rep("#", 128))
|
||||
error(err_msg)
|
||||
end
|
||||
|
||||
local path = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
local function load_module(path)
|
||||
@ -42,7 +34,11 @@ load_module(path .. "/compatibility.lua")
|
||||
load_module(path .. "/cuboid.lua")
|
||||
|
||||
|
||||
if minetest.setting_getbool("log_mods") then
|
||||
if minetest.settings:get_bool("log_mods") then
|
||||
print("[WorldEdit] Loaded!")
|
||||
end
|
||||
|
||||
if minetest.settings:get_bool("worldedit_run_tests") then
|
||||
dofile(path .. "/test.lua")
|
||||
minetest.after(0, worldedit.run_tests)
|
||||
end
|
||||
|
@ -76,9 +76,6 @@ function worldedit.replace(pos1, pos2, search_node, replace_node, inverse)
|
||||
|
||||
local count = 0
|
||||
|
||||
--- TODO: This could be shortened by checking `inverse` in the loop,
|
||||
-- but that would have a speed penalty. Is the penalty big enough
|
||||
-- to matter?
|
||||
if not inverse then
|
||||
for i in area:iterp(pos1, pos2) do
|
||||
if data[i] == search_id then
|
||||
@ -101,27 +98,47 @@ function worldedit.replace(pos1, pos2, search_node, replace_node, inverse)
|
||||
end
|
||||
|
||||
|
||||
local function deferred_execution(next_one, finished)
|
||||
-- Allocate 100% of server step for execution (might lag a little)
|
||||
local allocated_usecs =
|
||||
tonumber(minetest.settings:get("dedicated_server_step"):split(" ")[1]) * 1000000
|
||||
local function f()
|
||||
local deadline = minetest.get_us_time() + allocated_usecs
|
||||
repeat
|
||||
local is_done = next_one()
|
||||
if is_done then
|
||||
if finished then
|
||||
finished()
|
||||
end
|
||||
return
|
||||
end
|
||||
until minetest.get_us_time() >= deadline
|
||||
minetest.after(0, f)
|
||||
end
|
||||
f()
|
||||
end
|
||||
|
||||
--- Duplicates a region `amount` times with offset vector `direction`.
|
||||
-- Stacking is spread across server steps, one copy per step.
|
||||
-- Stacking is spread across server steps.
|
||||
-- @return The number of nodes stacked.
|
||||
function worldedit.stack2(pos1, pos2, direction, amount, finished)
|
||||
-- Protect arguments from external changes during execution
|
||||
pos1 = table.copy(pos1)
|
||||
pos2 = table.copy(pos2)
|
||||
direction = table.copy(direction)
|
||||
|
||||
local i = 0
|
||||
local translated = {x=0, y=0, z=0}
|
||||
local function next_one()
|
||||
if i < amount then
|
||||
i = i + 1
|
||||
translated.x = translated.x + direction.x
|
||||
translated.y = translated.y + direction.y
|
||||
translated.z = translated.z + direction.z
|
||||
worldedit.copy2(pos1, pos2, translated)
|
||||
minetest.after(0, next_one)
|
||||
else
|
||||
if finished then
|
||||
finished()
|
||||
end
|
||||
end
|
||||
local translated = vector.new()
|
||||
local function step()
|
||||
translated.x = translated.x + direction.x
|
||||
translated.y = translated.y + direction.y
|
||||
translated.z = translated.z + direction.z
|
||||
worldedit.copy2(pos1, pos2, translated)
|
||||
i = i + 1
|
||||
return i >= amount
|
||||
end
|
||||
next_one()
|
||||
deferred_execution(step, finished)
|
||||
|
||||
return worldedit.volume(pos1, pos2) * amount
|
||||
end
|
||||
|
||||
@ -135,181 +152,185 @@ end
|
||||
function worldedit.copy(pos1, pos2, axis, amount)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
-- Decide if we need to copy stuff backwards (only applies to metadata)
|
||||
local backwards = amount > 0 and amount < (pos2[axis] - pos1[axis] + 1)
|
||||
|
||||
local get_node, get_meta, set_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.set_node
|
||||
-- Copy things backwards when negative to avoid corruption.
|
||||
-- FIXME: Lots of code duplication here.
|
||||
if amount < 0 then
|
||||
local pos = {}
|
||||
pos.x = pos1.x
|
||||
while pos.x <= pos2.x do
|
||||
pos.y = pos1.y
|
||||
while pos.y <= pos2.y do
|
||||
pos.z = pos1.z
|
||||
while pos.z <= pos2.z do
|
||||
local node = get_node(pos) -- Obtain current node
|
||||
local meta = get_meta(pos):to_table() -- Get meta of current node
|
||||
local value = pos[axis] -- Store current position
|
||||
pos[axis] = value + amount -- Move along axis
|
||||
set_node(pos, node) -- Copy node to new position
|
||||
get_meta(pos):from_table(meta) -- Set metadata of new node
|
||||
pos[axis] = value -- Restore old position
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
else
|
||||
local pos = {}
|
||||
pos.x = pos2.x
|
||||
while pos.x >= pos1.x do
|
||||
pos.y = pos2.y
|
||||
while pos.y >= pos1.y do
|
||||
pos.z = pos2.z
|
||||
while pos.z >= pos1.z do
|
||||
local node = get_node(pos) -- Obtain current node
|
||||
local meta = get_meta(pos):to_table() -- Get meta of current node
|
||||
local value = pos[axis] -- Store current position
|
||||
pos[axis] = value + amount -- Move along axis
|
||||
set_node(pos, node) -- Copy node to new position
|
||||
get_meta(pos):from_table(meta) -- Set metadata of new node
|
||||
pos[axis] = value -- Restore old position
|
||||
pos.z = pos.z - 1
|
||||
end
|
||||
pos.y = pos.y - 1
|
||||
end
|
||||
pos.x = pos.x - 1
|
||||
end
|
||||
end
|
||||
return worldedit.volume(pos1, pos2)
|
||||
local off = vector.new()
|
||||
off[axis] = amount
|
||||
return worldedit.copy2(pos1, pos2, off, backwards)
|
||||
end
|
||||
|
||||
--- Copies a region by offset vector `off`.
|
||||
-- @param pos1
|
||||
-- @param pos2
|
||||
-- @param off
|
||||
-- @param meta_backwards (not officially part of API)
|
||||
-- @return The number of nodes copied.
|
||||
function worldedit.copy2(pos1, pos2, off)
|
||||
function worldedit.copy2(pos1, pos2, off, meta_backwards)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
local src_manip, src_area = mh.init(pos1, pos2)
|
||||
local src_stride = vector.new(1, src_area.ystride, src_area.zstride)
|
||||
local src_offset = vector.subtract(pos1, src_area.MinEdge)
|
||||
|
||||
local get_node, get_meta, set_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.set_node
|
||||
local pos = {}
|
||||
pos.x = pos2.x
|
||||
while pos.x >= pos1.x do
|
||||
pos.y = pos2.y
|
||||
while pos.y >= pos1.y do
|
||||
pos.z = pos2.z
|
||||
while pos.z >= pos1.z do
|
||||
local node = get_node(pos) -- Obtain current node
|
||||
local meta = get_meta(pos):to_table() -- Get meta of current node
|
||||
local newpos = vector.add(pos, off) -- Calculate new position
|
||||
set_node(newpos, node) -- Copy node to new position
|
||||
get_meta(newpos):from_table(meta) -- Set metadata of new node
|
||||
pos.z = pos.z - 1
|
||||
local dpos1 = vector.add(pos1, off)
|
||||
local dpos2 = vector.add(pos2, off)
|
||||
local dim = vector.add(vector.subtract(pos2, pos1), 1)
|
||||
|
||||
local dst_manip, dst_area = mh.init(dpos1, dpos2)
|
||||
local dst_stride = vector.new(1, dst_area.ystride, dst_area.zstride)
|
||||
local dst_offset = vector.subtract(dpos1, dst_area.MinEdge)
|
||||
|
||||
local function do_copy(src_data, dst_data)
|
||||
for z = 0, dim.z-1 do
|
||||
local src_index_z = (src_offset.z + z) * src_stride.z + 1 -- +1 for 1-based indexing
|
||||
local dst_index_z = (dst_offset.z + z) * dst_stride.z + 1
|
||||
for y = 0, dim.y-1 do
|
||||
local src_index_y = src_index_z + (src_offset.y + y) * src_stride.y
|
||||
local dst_index_y = dst_index_z + (dst_offset.y + y) * dst_stride.y
|
||||
-- Copy entire row at once
|
||||
local src_index_x = src_index_y + src_offset.x
|
||||
local dst_index_x = dst_index_y + dst_offset.x
|
||||
for x = 0, dim.x-1 do
|
||||
dst_data[dst_index_x + x] = src_data[src_index_x + x]
|
||||
end
|
||||
end
|
||||
pos.y = pos.y - 1
|
||||
end
|
||||
pos.x = pos.x - 1
|
||||
end
|
||||
|
||||
-- Copy node data
|
||||
local src_data = src_manip:get_data()
|
||||
local dst_data = dst_manip:get_data()
|
||||
do_copy(src_data, dst_data)
|
||||
dst_manip:set_data(dst_data)
|
||||
|
||||
-- Copy param1
|
||||
src_manip:get_light_data(src_data)
|
||||
dst_manip:get_light_data(dst_data)
|
||||
do_copy(src_data, dst_data)
|
||||
dst_manip:set_light_data(dst_data)
|
||||
|
||||
-- Copy param2
|
||||
src_manip:get_param2_data(src_data)
|
||||
dst_manip:get_param2_data(dst_data)
|
||||
do_copy(src_data, dst_data)
|
||||
dst_manip:set_param2_data(dst_data)
|
||||
|
||||
mh.finish(dst_manip)
|
||||
|
||||
-- Copy metadata
|
||||
local get_meta = minetest.get_meta
|
||||
if meta_backwards then
|
||||
for z = dim.z-1, 0, -1 do
|
||||
for y = dim.y-1, 0, -1 do
|
||||
for x = dim.x-1, 0, -1 do
|
||||
local pos = vector.new(pos1.x+x, pos1.y+y, pos1.z+z)
|
||||
local meta = get_meta(pos):to_table()
|
||||
pos = vector.add(pos, off)
|
||||
get_meta(pos):from_table(meta)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for z = 0, dim.z-1 do
|
||||
for y = 0, dim.y-1 do
|
||||
for x = 0, dim.x-1 do
|
||||
local pos = vector.new(pos1.x+x, pos1.y+y, pos1.z+z)
|
||||
local meta = get_meta(pos):to_table()
|
||||
pos = vector.add(pos, off)
|
||||
get_meta(pos):from_table(meta)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return worldedit.volume(pos1, pos2)
|
||||
end
|
||||
|
||||
--- Deletes all node metadata in the region
|
||||
-- @param pos1
|
||||
-- @param pos2
|
||||
-- @return The number of nodes that had their meta deleted.
|
||||
function worldedit.delete_meta(pos1, pos2)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local meta_positions = minetest.find_nodes_with_meta(pos1, pos2)
|
||||
local get_meta = minetest.get_meta
|
||||
for _, pos in ipairs(meta_positions) do
|
||||
get_meta(pos):from_table(nil)
|
||||
end
|
||||
|
||||
return #meta_positions
|
||||
end
|
||||
|
||||
--- Moves a region along `axis` by `amount` nodes.
|
||||
-- @return The number of nodes moved.
|
||||
function worldedit.move(pos1, pos2, axis, amount)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
local dim = vector.add(vector.subtract(pos2, pos1), 1)
|
||||
local overlap = math.abs(amount) < dim[axis]
|
||||
-- Decide if we need to copy metadata backwards
|
||||
local backwards = overlap and amount > 0
|
||||
|
||||
--- TODO: Move slice by slice using schematic method in the move axis
|
||||
-- and transfer metadata in separate loop (and if the amount is
|
||||
-- greater than the length in the axis, copy whole thing at a time and
|
||||
-- erase original after, using schematic method).
|
||||
local get_node, get_meta, set_node, remove_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.set_node, minetest.remove_node
|
||||
-- Copy things backwards when negative to avoid corruption.
|
||||
--- FIXME: Lots of code duplication here.
|
||||
if amount < 0 then
|
||||
local pos = {}
|
||||
pos.x = pos1.x
|
||||
while pos.x <= pos2.x do
|
||||
pos.y = pos1.y
|
||||
while pos.y <= pos2.y do
|
||||
pos.z = pos1.z
|
||||
while pos.z <= pos2.z do
|
||||
local node = get_node(pos) -- Obtain current node
|
||||
local meta = get_meta(pos):to_table() -- Get metadata of current node
|
||||
remove_node(pos) -- Remove current node
|
||||
local value = pos[axis] -- Store current position
|
||||
pos[axis] = value + amount -- Move along axis
|
||||
set_node(pos, node) -- Move node to new position
|
||||
get_meta(pos):from_table(meta) -- Set metadata of new node
|
||||
pos[axis] = value -- Restore old position
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
local function nuke_area(my_off, my_dim)
|
||||
if my_dim.x == 0 or my_dim.y == 0 or my_dim.z == 0 then
|
||||
return
|
||||
end
|
||||
local my_pos1 = vector.add(pos1, my_off)
|
||||
local my_pos2 = vector.subtract(vector.add(my_pos1, my_dim), 1)
|
||||
worldedit.set(my_pos1, my_pos2, "air")
|
||||
worldedit.delete_meta(my_pos1, my_pos2)
|
||||
end
|
||||
|
||||
-- Copy stuff to new location
|
||||
local off = vector.new()
|
||||
off[axis] = amount
|
||||
worldedit.copy2(pos1, pos2, off, backwards)
|
||||
-- Nuke old area
|
||||
if not overlap then
|
||||
nuke_area(vector.new(), dim)
|
||||
else
|
||||
local pos = {}
|
||||
pos.x = pos2.x
|
||||
while pos.x >= pos1.x do
|
||||
pos.y = pos2.y
|
||||
while pos.y >= pos1.y do
|
||||
pos.z = pos2.z
|
||||
while pos.z >= pos1.z do
|
||||
local node = get_node(pos) -- Obtain current node
|
||||
local meta = get_meta(pos):to_table() -- Get metadata of current node
|
||||
remove_node(pos) -- Remove current node
|
||||
local value = pos[axis] -- Store current position
|
||||
pos[axis] = value + amount -- Move along axis
|
||||
set_node(pos, node) -- Move node to new position
|
||||
get_meta(pos):from_table(meta) -- Set metadata of new node
|
||||
pos[axis] = value -- Restore old position
|
||||
pos.z = pos.z - 1
|
||||
end
|
||||
pos.y = pos.y - 1
|
||||
end
|
||||
pos.x = pos.x - 1
|
||||
-- Source and destination region are overlapping, which means we can't
|
||||
-- blindly delete the [pos1, pos2] area
|
||||
local leftover = vector.new(dim) -- size of the leftover slice
|
||||
leftover[axis] = math.abs(amount)
|
||||
if amount > 0 then
|
||||
nuke_area(vector.new(), leftover)
|
||||
else
|
||||
local top = vector.new() -- offset of the leftover slice from pos1
|
||||
top[axis] = dim[axis] - math.abs(amount)
|
||||
nuke_area(top, leftover)
|
||||
end
|
||||
end
|
||||
|
||||
return worldedit.volume(pos1, pos2)
|
||||
end
|
||||
|
||||
|
||||
--- Duplicates a region along `axis` `amount` times.
|
||||
-- Stacking is spread across server steps, one copy per step.
|
||||
-- Stacking is spread across server steps.
|
||||
-- @param pos1
|
||||
-- @param pos2
|
||||
-- @param axis Axis direction, "x", "y", or "z".
|
||||
-- @param count
|
||||
-- @return The number of nodes stacked.
|
||||
function worldedit.stack(pos1, pos2, axis, count)
|
||||
function worldedit.stack(pos1, pos2, axis, count, finished)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
local length = pos2[axis] - pos1[axis] + 1
|
||||
if count < 0 then
|
||||
count = -count
|
||||
length = -length
|
||||
end
|
||||
local amount = 0
|
||||
local copy = worldedit.copy
|
||||
local i = 1
|
||||
function next_one()
|
||||
if i <= count then
|
||||
i = i + 1
|
||||
amount = amount + length
|
||||
copy(pos1, pos2, axis, amount)
|
||||
minetest.after(0, next_one)
|
||||
end
|
||||
|
||||
local i, distance = 0, 0
|
||||
local function step()
|
||||
distance = distance + length
|
||||
worldedit.copy(pos1, pos2, axis, distance)
|
||||
i = i + 1
|
||||
return i >= count
|
||||
end
|
||||
next_one()
|
||||
deferred_execution(step, finished)
|
||||
|
||||
return worldedit.volume(pos1, pos2) * count
|
||||
end
|
||||
|
||||
@ -335,7 +356,7 @@ function worldedit.stretch(pos1, pos2, stretch_x, stretch_y, stretch_z)
|
||||
for i = 1, stretch_x * stretch_y * stretch_z do
|
||||
nodes[i] = placeholder_node
|
||||
end
|
||||
local schematic = {size={x=stretch_x, y=stretch_y, z=stretch_z}, data=nodes}
|
||||
local schematic = {size=vector.new(stretch_x, stretch_y, stretch_z), data=nodes}
|
||||
|
||||
local size_x, size_y, size_z = stretch_x - 1, stretch_y - 1, stretch_z - 1
|
||||
|
||||
@ -346,8 +367,8 @@ function worldedit.stretch(pos1, pos2, stretch_x, stretch_y, stretch_z)
|
||||
}
|
||||
worldedit.keep_loaded(pos1, new_pos2)
|
||||
|
||||
local pos = {x=pos2.x, y=0, z=0}
|
||||
local big_pos = {x=0, y=0, z=0}
|
||||
local pos = vector.new(pos2.x, 0, 0)
|
||||
local big_pos = vector.new()
|
||||
while pos.x >= pos1.x do
|
||||
pos.y = pos2.y
|
||||
while pos.y >= pos1.y do
|
||||
@ -413,16 +434,16 @@ function worldedit.transpose(pos1, pos2, axis1, axis2)
|
||||
end
|
||||
|
||||
-- Calculate the new position 2 after transposition
|
||||
local new_pos2 = {x=pos2.x, y=pos2.y, z=pos2.z}
|
||||
local new_pos2 = vector.new(pos2)
|
||||
new_pos2[axis1] = pos1[axis1] + extent2
|
||||
new_pos2[axis2] = pos1[axis2] + extent1
|
||||
|
||||
local upper_bound = {x=pos2.x, y=pos2.y, z=pos2.z}
|
||||
local upper_bound = vector.new(pos2)
|
||||
if upper_bound[axis1] < new_pos2[axis1] then upper_bound[axis1] = new_pos2[axis1] end
|
||||
if upper_bound[axis2] < new_pos2[axis2] then upper_bound[axis2] = new_pos2[axis2] end
|
||||
worldedit.keep_loaded(pos1, upper_bound)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local pos = vector.new(pos1.x, 0, 0)
|
||||
local get_node, get_meta, set_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.set_node
|
||||
while pos.x <= pos2.x do
|
||||
@ -462,7 +483,7 @@ function worldedit.flip(pos1, pos2, axis)
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
--- TODO: Flip the region slice by slice along the flip axis using schematic method.
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local pos = vector.new(pos1.x, 0, 0)
|
||||
local start = pos1[axis] + pos2[axis]
|
||||
pos2[axis] = pos1[axis] + math.floor((pos2[axis] - pos1[axis]) / 2)
|
||||
local get_node, get_meta, set_node = minetest.get_node,
|
||||
@ -529,20 +550,22 @@ end
|
||||
-- @param pos2
|
||||
-- @param angle Angle in degrees (90 degree increments only).
|
||||
-- @return The number of nodes oriented.
|
||||
-- TODO: Support 6D facedir rotation along arbitrary axis.
|
||||
function worldedit.orient(pos1, pos2, angle)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
local registered_nodes = minetest.registered_nodes
|
||||
|
||||
local wallmounted = {
|
||||
[90] = {[0]=0, 1, 5, 4, 2, 3},
|
||||
[180] = {[0]=0, 1, 3, 2, 5, 4},
|
||||
[270] = {[0]=0, 1, 4, 5, 3, 2}
|
||||
[90] = {0, 1, 5, 4, 2, 3, 0, 0},
|
||||
[180] = {0, 1, 3, 2, 5, 4, 0, 0},
|
||||
[270] = {0, 1, 4, 5, 3, 2, 0, 0}
|
||||
}
|
||||
local facedir = {
|
||||
[90] = {[0]=1, 2, 3, 0},
|
||||
[180] = {[0]=2, 3, 0, 1},
|
||||
[270] = {[0]=3, 0, 1, 2}
|
||||
[90] = { 1, 2, 3, 0, 13, 14, 15, 12, 17, 18, 19, 16,
|
||||
9, 10, 11, 8, 5, 6, 7, 4, 23, 20, 21, 22},
|
||||
[180] = { 2, 3, 0, 1, 10, 11, 8, 9, 6, 7, 4, 5,
|
||||
18, 19, 16, 17, 14, 15, 12, 13, 22, 23, 20, 21},
|
||||
[270] = { 3, 0, 1, 2, 19, 16, 17, 18, 15, 12, 13, 14,
|
||||
7, 4, 5, 6, 11, 8, 9, 10, 21, 22, 23, 20}
|
||||
}
|
||||
|
||||
angle = angle % 360
|
||||
@ -558,9 +581,8 @@ function worldedit.orient(pos1, pos2, angle)
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local count = 0
|
||||
local set_node, get_node, get_meta, swap_node = minetest.set_node,
|
||||
minetest.get_node, minetest.get_meta, minetest.swap_node
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local get_node, swap_node = minetest.get_node, minetest.swap_node
|
||||
local pos = vector.new(pos1.x, 0, 0)
|
||||
while pos.x <= pos2.x do
|
||||
pos.y = pos1.y
|
||||
while pos.y <= pos2.y do
|
||||
@ -569,17 +591,20 @@ function worldedit.orient(pos1, pos2, angle)
|
||||
local node = get_node(pos)
|
||||
local def = registered_nodes[node.name]
|
||||
if def then
|
||||
if def.paramtype2 == "wallmounted" then
|
||||
node.param2 = wallmounted_substitution[node.param2]
|
||||
local meta = get_meta(pos):to_table()
|
||||
set_node(pos, node)
|
||||
get_meta(pos):from_table(meta)
|
||||
local paramtype2 = def.paramtype2
|
||||
if paramtype2 == "wallmounted" or
|
||||
paramtype2 == "colorwallmounted" then
|
||||
local orient = node.param2 % 8
|
||||
node.param2 = node.param2 - orient +
|
||||
wallmounted_substitution[orient + 1]
|
||||
swap_node(pos, node)
|
||||
count = count + 1
|
||||
elseif def.paramtype2 == "facedir" then
|
||||
node.param2 = facedir_substitution[node.param2]
|
||||
local meta = get_meta(pos):to_table()
|
||||
set_node(pos, node)
|
||||
get_meta(pos):from_table(meta)
|
||||
elseif paramtype2 == "facedir" or
|
||||
paramtype2 == "colorfacedir" then
|
||||
local orient = node.param2 % 32
|
||||
node.param2 = node.param2 - orient +
|
||||
facedir_substitution[orient + 1]
|
||||
swap_node(pos, node)
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
@ -613,31 +638,51 @@ function worldedit.clear_objects(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
-- Offset positions to include full nodes (positions are in the center of nodes)
|
||||
local pos1x, pos1y, pos1z = pos1.x - 0.5, pos1.y - 0.5, pos1.z - 0.5
|
||||
local pos2x, pos2y, pos2z = pos2.x + 0.5, pos2.y + 0.5, pos2.z + 0.5
|
||||
local function should_delete(obj)
|
||||
-- Avoid players and WorldEdit entities
|
||||
if obj:is_player() then
|
||||
return false
|
||||
end
|
||||
local entity = obj:get_luaentity()
|
||||
return not entity or not entity.name:find("^worldedit:")
|
||||
end
|
||||
|
||||
-- Offset positions to include full nodes (positions are in the center of nodes)
|
||||
pos1 = vector.add(pos1, -0.5)
|
||||
pos2 = vector.add(pos2, 0.5)
|
||||
|
||||
local count = 0
|
||||
if minetest.get_objects_in_area then
|
||||
local objects = minetest.get_objects_in_area(pos1, pos2)
|
||||
|
||||
for _, obj in pairs(objects) do
|
||||
if should_delete(obj) then
|
||||
obj:remove()
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Fallback implementation via get_objects_inside_radius
|
||||
-- Center of region
|
||||
local center = {
|
||||
x = pos1x + ((pos2x - pos1x) / 2),
|
||||
y = pos1y + ((pos2y - pos1y) / 2),
|
||||
z = pos1z + ((pos2z - pos1z) / 2)
|
||||
x = pos1.x + ((pos2.x - pos1.x) / 2),
|
||||
y = pos1.y + ((pos2.y - pos1.y) / 2),
|
||||
z = pos1.z + ((pos2.z - pos1.z) / 2)
|
||||
}
|
||||
-- Bounding sphere radius
|
||||
local radius = math.sqrt(
|
||||
(center.x - pos1x) ^ 2 +
|
||||
(center.y - pos1y) ^ 2 +
|
||||
(center.z - pos1z) ^ 2)
|
||||
local count = 0
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(center, radius)) do
|
||||
local entity = obj:get_luaentity()
|
||||
-- Avoid players and WorldEdit entities
|
||||
if not obj:is_player() and (not entity or
|
||||
not entity.name:find("^worldedit:")) then
|
||||
local pos = obj:getpos()
|
||||
if pos.x >= pos1x and pos.x <= pos2x and
|
||||
pos.y >= pos1y and pos.y <= pos2y and
|
||||
pos.z >= pos1z and pos.z <= pos2z then
|
||||
(center.x - pos1.x) ^ 2 +
|
||||
(center.y - pos1.y) ^ 2 +
|
||||
(center.z - pos1.z) ^ 2)
|
||||
local objects = minetest.get_objects_inside_radius(center, radius)
|
||||
for _, obj in pairs(objects) do
|
||||
if should_delete(obj) then
|
||||
local pos = obj:get_pos()
|
||||
if pos.x >= pos1.x and pos.x <= pos2.x and
|
||||
pos.y >= pos1.y and pos.y <= pos2.y and
|
||||
pos.z >= pos1.z and pos.z <= pos2.z then
|
||||
-- Inside region
|
||||
obj:remove()
|
||||
count = count + 1
|
||||
|
2
worldedit/mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name = worldedit
|
||||
description = WorldEdit main functionality & API
|
@ -20,7 +20,7 @@ function worldedit.cube(pos, width, height, length, node_name, hollow)
|
||||
|
||||
-- Add cube
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local stride = {x=1, y=area.ystride, z=area.zstride}
|
||||
local stride = vector.new(1, area.ystride, area.zstride)
|
||||
local offset = vector.subtract(basepos, area.MinEdge)
|
||||
local count = 0
|
||||
|
||||
@ -149,7 +149,7 @@ function worldedit.cylinder(pos, axis, length, radius1, radius2, node_name, holl
|
||||
end
|
||||
|
||||
-- Handle negative lengths
|
||||
local current_pos = {x=pos.x, y=pos.y, z=pos.z}
|
||||
local current_pos = vector.new(pos)
|
||||
if length < 0 then
|
||||
length = -length
|
||||
current_pos[axis] = current_pos[axis] - length
|
||||
@ -162,7 +162,7 @@ function worldedit.cylinder(pos, axis, length, radius1, radius2, node_name, holl
|
||||
|
||||
-- Add desired shape (anything inbetween cylinder & cone)
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local stride = {x=1, y=area.ystride, z=area.zstride}
|
||||
local stride = vector.new(1, area.ystride, area.zstride)
|
||||
local offset = {
|
||||
x = current_pos.x - area.MinEdge.x,
|
||||
y = current_pos.y - area.MinEdge.y,
|
||||
@ -208,12 +208,13 @@ function worldedit.pyramid(pos, axis, height, node_name, hollow)
|
||||
local other1, other2 = worldedit.get_axis_others(axis)
|
||||
|
||||
-- Set up voxel manipulator
|
||||
local manip, area = mh.init_axis_radius(pos, axis,
|
||||
height >= 0 and height or -height)
|
||||
-- FIXME: passing negative <radius> causes mis-sorted pos to be passed
|
||||
-- into mh.init() which is technically not allowed but works
|
||||
local manip, area = mh.init_axis_radius(pos, axis, height)
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Handle inverted pyramids
|
||||
local start_axis, end_axis, step
|
||||
local step
|
||||
if height > 0 then
|
||||
height = height - 1
|
||||
step = 1
|
||||
@ -224,7 +225,7 @@ function worldedit.pyramid(pos, axis, height, node_name, hollow)
|
||||
|
||||
-- Add pyramid
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local stride = {x=1, y=area.ystride, z=area.zstride}
|
||||
local stride = vector.new(1, area.ystride, area.zstride)
|
||||
local offset = {
|
||||
x = pos.x - area.MinEdge.x,
|
||||
y = pos.y - area.MinEdge.y,
|
||||
@ -241,8 +242,8 @@ function worldedit.pyramid(pos, axis, height, node_name, hollow)
|
||||
for index3 = -size, size do
|
||||
local i = new_index2 + (index3 + offset[other2]) * stride[other2]
|
||||
if (not hollow or size - math.abs(index2) < 2 or size - math.abs(index3) < 2) then
|
||||
data[i] = node_id
|
||||
count = count + 1
|
||||
data[i] = node_id
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -270,7 +271,7 @@ function worldedit.spiral(pos, length, height, spacer, node_name)
|
||||
|
||||
-- Set up variables
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local stride = {x=1, y=area.ystride, z=area.zstride}
|
||||
local stride = vector.new(1, area.ystride, area.zstride)
|
||||
local offset_x, offset_y, offset_z = pos.x - area.MinEdge.x, pos.y - area.MinEdge.y, pos.z - area.MinEdge.z
|
||||
local i = offset_z * stride.z + offset_y * stride.y + offset_x + 1
|
||||
|
||||
|
@ -24,7 +24,7 @@ Serialization version history:
|
||||
-- @return Extra header fields as a list of strings, or nil if not supported.
|
||||
-- @return Content (data after header).
|
||||
function worldedit.read_header(value)
|
||||
if value:find("^[0-9]+[%-:]") then
|
||||
if value:find("^[0-9]+[,:]") then
|
||||
local header_end = value:find(":", 1, true)
|
||||
local header = value:sub(1, header_end - 1):split(",")
|
||||
local version = tonumber(header[1])
|
||||
@ -56,10 +56,19 @@ function worldedit.serialize(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local get_node, get_meta, hash_node_position =
|
||||
minetest.get_node, minetest.get_meta, minetest.hash_node_position
|
||||
|
||||
-- Find the positions which have metadata
|
||||
local has_meta = {}
|
||||
local meta_positions = minetest.find_nodes_with_meta(pos1, pos2)
|
||||
for i = 1, #meta_positions do
|
||||
has_meta[hash_node_position(meta_positions[i])] = true
|
||||
end
|
||||
|
||||
local pos = vector.new(pos1.x, 0, 0)
|
||||
local count = 0
|
||||
local result = {}
|
||||
local get_node, get_meta = minetest.get_node, minetest.get_meta
|
||||
while pos.x <= pos2.x do
|
||||
pos.y = pos1.y
|
||||
while pos.y <= pos2.y do
|
||||
@ -68,20 +77,19 @@ function worldedit.serialize(pos1, pos2)
|
||||
local node = get_node(pos)
|
||||
if node.name ~= "air" and node.name ~= "ignore" then
|
||||
count = count + 1
|
||||
local meta = get_meta(pos):to_table()
|
||||
|
||||
local meta_empty = true
|
||||
-- Convert metadata item stacks to item strings
|
||||
for name, inventory in pairs(meta.inventory) do
|
||||
for index, stack in ipairs(inventory) do
|
||||
meta_empty = false
|
||||
inventory[index] = stack.to_string and stack:to_string() or stack
|
||||
end
|
||||
end
|
||||
for k in pairs(meta) do
|
||||
if k ~= "inventory" then
|
||||
meta_empty = false
|
||||
break
|
||||
local meta
|
||||
if has_meta[hash_node_position(pos)] then
|
||||
meta = get_meta(pos):to_table()
|
||||
|
||||
-- Convert metadata item stacks to item strings
|
||||
for _, invlist in pairs(meta.inventory) do
|
||||
for index = 1, #invlist do
|
||||
local itemstack = invlist[index]
|
||||
if itemstack.to_string then
|
||||
invlist[index] = itemstack:to_string()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -92,7 +100,7 @@ function worldedit.serialize(pos1, pos2)
|
||||
name = node.name,
|
||||
param1 = node.param1 ~= 0 and node.param1 or nil,
|
||||
param2 = node.param2 ~= 0 and node.param2 or nil,
|
||||
meta = not meta_empty and meta or nil,
|
||||
meta = meta,
|
||||
}
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
@ -106,16 +114,56 @@ function worldedit.serialize(pos1, pos2)
|
||||
return LATEST_SERIALIZATION_HEADER .. result, count
|
||||
end
|
||||
|
||||
local function deserialize_workaround(content)
|
||||
local nodes, err
|
||||
if not minetest.global_exists("jit") then
|
||||
nodes, err = minetest.deserialize(content, true)
|
||||
elseif not content:match("^%s*return%s*{") then
|
||||
-- The data doesn't look like we expect it to so we can't apply the workaround.
|
||||
-- hope for the best
|
||||
minetest.log("warning", "WorldEdit: deserializing data but can't apply LuaJIT workaround")
|
||||
nodes, err = minetest.deserialize(content, true)
|
||||
else
|
||||
-- XXX: This is a filthy hack that works surprisingly well
|
||||
-- in LuaJIT, `minetest.deserialize` will fail due to the register limit
|
||||
nodes = {}
|
||||
content = content:gsub("^%s*return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data
|
||||
-- remove string contents strings while preserving their length
|
||||
local escaped = content:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)
|
||||
local startpos, startpos1 = 1, 1
|
||||
local endpos
|
||||
local entry
|
||||
while true do -- go through each individual node entry (except the last)
|
||||
startpos, endpos = escaped:find("}%s*,%s*{", startpos)
|
||||
if not startpos then
|
||||
break
|
||||
end
|
||||
local current = content:sub(startpos1, startpos)
|
||||
entry, err = minetest.deserialize("return " .. current, true)
|
||||
if not entry then
|
||||
break
|
||||
end
|
||||
table.insert(nodes, entry)
|
||||
startpos, startpos1 = endpos, endpos
|
||||
end
|
||||
if not err then
|
||||
entry = minetest.deserialize("return " .. content:sub(startpos1), true) -- process the last entry
|
||||
table.insert(nodes, entry)
|
||||
end
|
||||
end
|
||||
if err then
|
||||
minetest.log("warning", "WorldEdit: deserialize: " .. err)
|
||||
end
|
||||
return nodes
|
||||
end
|
||||
|
||||
--- Loads the schematic in `value` into a node list in the latest format.
|
||||
-- Contains code based on [table.save/table.load](http://lua-users.org/wiki/SaveTableToFile)
|
||||
-- by ChillCode, available under the MIT license.
|
||||
-- @return A node list in the latest format, or nil on failure.
|
||||
local function load_schematic(value)
|
||||
local version, header, content = worldedit.read_header(value)
|
||||
local version, _, content = worldedit.read_header(value)
|
||||
local nodes = {}
|
||||
if version == 1 or version == 2 then -- Original flat table format
|
||||
local tables = minetest.deserialize(content)
|
||||
local tables = minetest.deserialize(content, true)
|
||||
if not tables then return nil end
|
||||
|
||||
-- Transform the node table into an array of nodes
|
||||
@ -153,28 +201,7 @@ local function load_schematic(value)
|
||||
})
|
||||
end
|
||||
elseif version == 4 or version == 5 then -- Nested table format
|
||||
if not jit then
|
||||
-- This is broken for larger tables in the current version of LuaJIT
|
||||
nodes = minetest.deserialize(content)
|
||||
else
|
||||
-- XXX: This is a filthy hack that works surprisingly well - in LuaJIT, `minetest.deserialize` will fail due to the register limit
|
||||
nodes = {}
|
||||
content = content:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data
|
||||
local escaped = content:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)
|
||||
local startpos, startpos1, endpos = 1, 1
|
||||
while true do -- go through each individual node entry (except the last)
|
||||
startpos, endpos = escaped:find("},%s*{", startpos)
|
||||
if not startpos then
|
||||
break
|
||||
end
|
||||
local current = content:sub(startpos1, startpos)
|
||||
local entry = minetest.deserialize("return " .. current)
|
||||
table.insert(nodes, entry)
|
||||
startpos, startpos1 = endpos, endpos
|
||||
end
|
||||
local entry = minetest.deserialize("return " .. content:sub(startpos1)) -- process the last entry
|
||||
table.insert(nodes, entry)
|
||||
end
|
||||
nodes = deserialize_workaround(content)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
@ -188,7 +215,7 @@ end
|
||||
-- @return The number of nodes.
|
||||
function worldedit.allocate(origin_pos, value)
|
||||
local nodes = load_schematic(value)
|
||||
if not nodes then return nil end
|
||||
if not nodes or #nodes == 0 then return nil end
|
||||
return worldedit.allocate_with_nodes(origin_pos, nodes)
|
||||
end
|
||||
|
||||
@ -208,9 +235,7 @@ function worldedit.allocate_with_nodes(origin_pos, nodes)
|
||||
if y > pos2y then pos2y = y end
|
||||
if z > pos2z then pos2z = z end
|
||||
end
|
||||
local pos1 = {x=pos1x, y=pos1y, z=pos1z}
|
||||
local pos2 = {x=pos2x, y=pos2y, z=pos2z}
|
||||
return pos1, pos2, #nodes
|
||||
return vector.new(pos1x, pos1y, pos1z), vector.new(pos2x, pos2y, pos2z), #nodes
|
||||
end
|
||||
|
||||
|
||||
@ -219,12 +244,12 @@ end
|
||||
function worldedit.deserialize(origin_pos, value)
|
||||
local nodes = load_schematic(value)
|
||||
if not nodes then return nil end
|
||||
if #nodes == 0 then return #nodes end
|
||||
|
||||
local pos1, pos2 = worldedit.allocate_with_nodes(origin_pos, nodes)
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z
|
||||
local count = 0
|
||||
local add_node, get_meta = minetest.add_node, minetest.get_meta
|
||||
for i, entry in ipairs(nodes) do
|
||||
entry.x, entry.y, entry.z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z
|
||||
|
602
worldedit/test.lua
Normal file
@ -0,0 +1,602 @@
|
||||
---------------------
|
||||
-- Helpers
|
||||
---------------------
|
||||
|
||||
local vec = vector.new
|
||||
local vecw = function(axis, n, base)
|
||||
local ret = vec(base)
|
||||
ret[axis] = n
|
||||
return ret
|
||||
end
|
||||
local pos2str = minetest.pos_to_string
|
||||
local get_node = minetest.get_node
|
||||
local set_node = minetest.set_node
|
||||
|
||||
---------------------
|
||||
-- Nodes
|
||||
---------------------
|
||||
local air = "air"
|
||||
local testnode1
|
||||
local testnode2
|
||||
local testnode3
|
||||
-- Loads nodenames to use for tests
|
||||
local function init_nodes()
|
||||
testnode1 = minetest.registered_aliases["mapgen_stone"]
|
||||
testnode2 = minetest.registered_aliases["mapgen_dirt"]
|
||||
testnode3 = minetest.registered_aliases["mapgen_cobble"] or minetest.registered_aliases["mapgen_dirt_with_grass"]
|
||||
assert(testnode1 and testnode2 and testnode3)
|
||||
end
|
||||
-- Writes repeating pattern into given area
|
||||
local function place_pattern(pos1, pos2, pattern)
|
||||
local pos = vec()
|
||||
local node = {name=""}
|
||||
local i = 1
|
||||
for z = pos1.z, pos2.z do
|
||||
pos.z = z
|
||||
for y = pos1.y, pos2.y do
|
||||
pos.y = y
|
||||
for x = pos1.x, pos2.x do
|
||||
pos.x = x
|
||||
node.name = pattern[i]
|
||||
set_node(pos, node)
|
||||
i = i % #pattern + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---------------------
|
||||
-- Area management
|
||||
---------------------
|
||||
assert(minetest.get_mapgen_setting("mg_name") == "singlenode")
|
||||
local area = {}
|
||||
do
|
||||
local areamin, areamax
|
||||
local off
|
||||
local c_air = minetest.get_content_id(air)
|
||||
local vbuffer = {}
|
||||
-- Assign a new area for use, will emerge and then call ready()
|
||||
area.assign = function(min, max, ready)
|
||||
areamin = min
|
||||
areamax = max
|
||||
minetest.emerge_area(min, max, function(bpos, action, remaining)
|
||||
assert(action ~= minetest.EMERGE_ERRORED)
|
||||
if remaining > 0 then return end
|
||||
minetest.after(0, function()
|
||||
area.clear()
|
||||
ready()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
-- Reset area contents and state
|
||||
area.clear = function()
|
||||
local vmanip = minetest.get_voxel_manip(areamin, areamax)
|
||||
local vpos1, vpos2 = vmanip:get_emerged_area()
|
||||
local vcount = (vpos2.x - vpos1.x + 1) * (vpos2.y - vpos1.y + 1) * (vpos2.z - vpos1.z + 1)
|
||||
if #vbuffer ~= vcount then
|
||||
vbuffer = {}
|
||||
for i = 1, vcount do
|
||||
vbuffer[i] = c_air
|
||||
end
|
||||
end
|
||||
vmanip:set_data(vbuffer)
|
||||
vmanip:write_to_map()
|
||||
off = vec(0, 0, 0)
|
||||
end
|
||||
-- Returns an usable area [pos1, pos2] that does not overlap previous ones
|
||||
area.get = function(sizex, sizey, sizez)
|
||||
local size
|
||||
if sizey == nil and sizez == nil then
|
||||
size = vector.new(sizex, sizex, sizex)
|
||||
else
|
||||
size = vector.new(sizex, sizey, sizez)
|
||||
end
|
||||
local pos1 = vector.add(areamin, off)
|
||||
local pos2 = vector.subtract(vector.add(pos1, size), 1)
|
||||
if pos2.x > areamax.x or pos2.y > areamax.y or pos2.z > areamax.z then
|
||||
error("Internal failure: out of space")
|
||||
end
|
||||
off = vector.add(off, size)
|
||||
return pos1, pos2
|
||||
end
|
||||
-- Returns an axis and count (= n) relative to the last-requested area that is unoccupied
|
||||
area.dir = function(n)
|
||||
local pos1 = vector.add(areamin, off)
|
||||
if pos1.x + n <= areamax.x then
|
||||
off.x = off.x + n
|
||||
return "x", n
|
||||
elseif pos1.x + n <= areamax.y then
|
||||
off.y = off.y + n
|
||||
return "y", n
|
||||
elseif pos1.z + n <= areamax.z then
|
||||
off.z = off.z + n
|
||||
return "z", n
|
||||
end
|
||||
error("Internal failure: out of space")
|
||||
end
|
||||
-- Returns [XYZ] margin (list of pos pairs) of n around last-requested area
|
||||
-- (may actually be larger but doesn't matter)
|
||||
area.margin = function(n)
|
||||
local pos1, pos2 = area.get(n)
|
||||
return {
|
||||
{ vec(areamin.x, areamin.y, pos1.z), pos2 }, -- X/Y
|
||||
{ vec(areamin.x, pos1.y, areamin.z), pos2 }, -- X/Z
|
||||
{ vec(pos1.x, areamin.y, areamin.z), pos2 }, -- Y/Z
|
||||
}
|
||||
end
|
||||
end
|
||||
-- Split an existing area into two non-overlapping [pos1, half1], [half2, pos2] parts; returns half1, half2
|
||||
area.split = function(pos1, pos2)
|
||||
local axis
|
||||
if pos2.x - pos1.x >= 1 then
|
||||
axis = "x"
|
||||
elseif pos2.y - pos1.y >= 1 then
|
||||
axis = "y"
|
||||
elseif pos2.z - pos1.z >= 1 then
|
||||
axis = "z"
|
||||
else
|
||||
error("Internal failure: area too small to split")
|
||||
end
|
||||
local hspan = math.floor((pos2[axis] - pos1[axis] + 1) / 2)
|
||||
local half1 = vecw(axis, pos1[axis] + hspan - 1, pos2)
|
||||
local half2 = vecw(axis, pos1[axis] + hspan, pos2)
|
||||
return half1, half2
|
||||
end
|
||||
|
||||
|
||||
---------------------
|
||||
-- Checks
|
||||
---------------------
|
||||
local check = {}
|
||||
-- Check that all nodes in [pos1, pos2] are the node(s) specified
|
||||
check.filled = function(pos1, pos2, nodes)
|
||||
if type(nodes) == "string" then
|
||||
nodes = { nodes }
|
||||
end
|
||||
local _, counts = minetest.find_nodes_in_area(pos1, pos2, nodes)
|
||||
local total = worldedit.volume(pos1, pos2)
|
||||
local sum = 0
|
||||
for _, n in pairs(counts) do
|
||||
sum = sum + n
|
||||
end
|
||||
if sum ~= total then
|
||||
error((total - sum) .. " " .. table.concat(nodes, ",") .. " nodes missing in " ..
|
||||
pos2str(pos1) .. " -> " .. pos2str(pos2))
|
||||
end
|
||||
end
|
||||
-- Check that none of the nodes in [pos1, pos2] are the node(s) specified
|
||||
check.not_filled = function(pos1, pos2, nodes)
|
||||
if type(nodes) == "string" then
|
||||
nodes = { nodes }
|
||||
end
|
||||
local _, counts = minetest.find_nodes_in_area(pos1, pos2, nodes)
|
||||
for nodename, n in pairs(counts) do
|
||||
if n ~= 0 then
|
||||
error(counts[nodename] .. " " .. nodename .. " nodes found in " ..
|
||||
pos2str(pos1) .. " -> " .. pos2str(pos2))
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Check that all of the areas are only made of node(s) specified
|
||||
check.filled2 = function(list, nodes)
|
||||
for _, pos in ipairs(list) do
|
||||
check.filled(pos[1], pos[2], nodes)
|
||||
end
|
||||
end
|
||||
-- Check that none of the areas contain the node(s) specified
|
||||
check.not_filled2 = function(list, nodes)
|
||||
for _, pos in ipairs(list) do
|
||||
check.not_filled(pos[1], pos[2], nodes)
|
||||
end
|
||||
end
|
||||
-- Checks presence of a repeating pattern in [pos1, po2] (cf. place_pattern)
|
||||
check.pattern = function(pos1, pos2, pattern)
|
||||
local pos = vec()
|
||||
local i = 1
|
||||
for z = pos1.z, pos2.z do
|
||||
pos.z = z
|
||||
for y = pos1.y, pos2.y do
|
||||
pos.y = y
|
||||
for x = pos1.x, pos2.x do
|
||||
pos.x = x
|
||||
local node = get_node(pos)
|
||||
if node.name ~= pattern[i] then
|
||||
error(pattern[i] .. " not found at " .. pos2str(pos) .. " (i=" .. i .. ")")
|
||||
end
|
||||
i = i % #pattern + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---------------------
|
||||
-- The actual tests
|
||||
---------------------
|
||||
local tests = {}
|
||||
local function register_test(name, func, opts)
|
||||
assert(type(name) == "string")
|
||||
assert(func == nil or type(func) == "function")
|
||||
if not opts then
|
||||
opts = {}
|
||||
else
|
||||
opts = table.copy(opts)
|
||||
end
|
||||
opts.name = name
|
||||
opts.func = func
|
||||
table.insert(tests, opts)
|
||||
end
|
||||
-- How this works:
|
||||
-- register_test registers a test with a name and function
|
||||
-- The function should return if the test passes or otherwise cause a Lua error
|
||||
-- The basic structure is: get areas + do operations + check results
|
||||
-- Helpers:
|
||||
-- area.get must be used to retrieve areas that can be operated on (these will be cleared before each test)
|
||||
-- check.filled / check.not_filled can be used to check the result
|
||||
-- area.margin + check.filled2 is useful to make sure nodes weren't placed too far
|
||||
-- place_pattern + check.pattern is useful to test ops that operate on existing data
|
||||
|
||||
|
||||
register_test("Internal self-test")
|
||||
register_test("is area loaded?", function()
|
||||
local pos1, _ = area.get(1)
|
||||
assert(get_node(pos1).name == "air")
|
||||
end, {dry=true})
|
||||
|
||||
register_test("area.split", function()
|
||||
for i = 2, 6 do
|
||||
local pos1, pos2 = area.get(1, 1, i)
|
||||
local half1, half2 = area.split(pos1, pos2)
|
||||
assert(pos1.x == half1.x and pos1.y == half1.y)
|
||||
assert(half1.x == half2.x and half1.y == half2.y)
|
||||
assert(half1.z + 1 == half2.z)
|
||||
if i % 2 == 0 then
|
||||
assert((half1.z - pos1.z) == (pos2.z - half2.z)) -- divided equally
|
||||
end
|
||||
end
|
||||
end, {dry=true})
|
||||
|
||||
register_test("check.filled", function()
|
||||
local pos1, pos2 = area.get(1, 2, 1)
|
||||
set_node(pos1, {name=testnode1})
|
||||
set_node(pos2, {name=testnode2})
|
||||
check.filled(pos1, pos1, testnode1)
|
||||
check.filled(pos1, pos2, {testnode1, testnode2})
|
||||
check.not_filled(pos1, pos1, air)
|
||||
check.not_filled(pos1, pos2, {air, testnode3})
|
||||
end)
|
||||
|
||||
register_test("pattern", function()
|
||||
local pos1, pos2 = area.get(3, 2, 1)
|
||||
local pattern = {testnode1, testnode3}
|
||||
place_pattern(pos1, pos2, pattern)
|
||||
assert(get_node(pos1).name == testnode1)
|
||||
check.pattern(pos1, pos2, pattern)
|
||||
end)
|
||||
|
||||
|
||||
register_test("Generic node manipulations")
|
||||
register_test("worldedit.set", function()
|
||||
local pos1, pos2 = area.get(10)
|
||||
local m = area.margin(1)
|
||||
|
||||
worldedit.set(pos1, pos2, testnode1)
|
||||
|
||||
check.filled(pos1, pos2, testnode1)
|
||||
check.filled2(m, air)
|
||||
end)
|
||||
|
||||
register_test("worldedit.set mix", function()
|
||||
local pos1, pos2 = area.get(10)
|
||||
local m = area.margin(1)
|
||||
|
||||
worldedit.set(pos1, pos2, {testnode1, testnode2})
|
||||
|
||||
check.filled(pos1, pos2, {testnode1, testnode2})
|
||||
check.filled2(m, air)
|
||||
end)
|
||||
|
||||
register_test("worldedit.replace", function()
|
||||
local pos1, pos2 = area.get(10)
|
||||
local half1, half2 = area.split(pos1, pos2)
|
||||
|
||||
worldedit.set(pos1, half1, testnode1)
|
||||
worldedit.set(half2, pos2, testnode2)
|
||||
worldedit.replace(pos1, pos2, testnode1, testnode3)
|
||||
|
||||
check.not_filled(pos1, pos2, testnode1)
|
||||
check.filled(pos1, half1, testnode3)
|
||||
check.filled(half2, pos2, testnode2)
|
||||
end)
|
||||
|
||||
register_test("worldedit.replace inverse", function()
|
||||
local pos1, pos2 = area.get(10)
|
||||
local half1, half2 = area.split(pos1, pos2)
|
||||
|
||||
worldedit.set(pos1, half1, testnode1)
|
||||
worldedit.set(half2, pos2, testnode2)
|
||||
worldedit.replace(pos1, pos2, testnode1, testnode3, true)
|
||||
|
||||
check.filled(pos1, half1, testnode1)
|
||||
check.filled(half2, pos2, testnode3)
|
||||
end)
|
||||
|
||||
-- FIXME?: this one looks overcomplicated
|
||||
register_test("worldedit.copy", function()
|
||||
local pos1, pos2 = area.get(4)
|
||||
local axis, n = area.dir(2)
|
||||
local m = area.margin(1)
|
||||
local b = pos1[axis]
|
||||
|
||||
-- create one slice with testnode1, one with testnode2
|
||||
worldedit.set(pos1, vecw(axis, b + 1, pos2), testnode1)
|
||||
worldedit.set(vecw(axis, b + 2, pos1), pos2, testnode2)
|
||||
worldedit.copy(pos1, pos2, axis, n)
|
||||
|
||||
-- should have three slices now
|
||||
check.filled(pos1, vecw(axis, b + 1, pos2), testnode1)
|
||||
check.filled(vecw(axis, b + 2, pos1), pos2, testnode1)
|
||||
check.filled(vecw(axis, b + 4, pos1), vector.add(pos2, vecw(axis, n)), testnode2)
|
||||
check.filled2(m, "air")
|
||||
end)
|
||||
|
||||
register_test("worldedit.copy2", function()
|
||||
local pos1, pos2 = area.get(6)
|
||||
local m1 = area.margin(1)
|
||||
local pos1_, pos2_ = area.get(6)
|
||||
local m2 = area.margin(1)
|
||||
|
||||
local pattern = {testnode1, testnode2, testnode3, testnode1, testnode2}
|
||||
place_pattern(pos1, pos2, pattern)
|
||||
worldedit.copy2(pos1, pos2, vector.subtract(pos1_, pos1))
|
||||
|
||||
check.pattern(pos1, pos2, pattern)
|
||||
check.pattern(pos1_, pos2_, pattern)
|
||||
check.filled2(m1, "air")
|
||||
check.filled2(m2, "air")
|
||||
end)
|
||||
|
||||
register_test("worldedit.move (overlap)", function()
|
||||
local pos1, pos2 = area.get(7)
|
||||
local axis, n = area.dir(2)
|
||||
local m = area.margin(1)
|
||||
|
||||
local pattern = {testnode2, testnode1, testnode2, testnode3, testnode3}
|
||||
place_pattern(pos1, pos2, pattern)
|
||||
worldedit.move(pos1, pos2, axis, n)
|
||||
|
||||
check.filled(pos1, vecw(axis, pos1[axis] + n - 1, pos2), "air")
|
||||
check.pattern(vecw(axis, pos1[axis] + n, pos1), vecw(axis, pos2[axis] + n, pos2), pattern)
|
||||
check.filled2(m, "air")
|
||||
end)
|
||||
|
||||
register_test("worldedit.move", function()
|
||||
local pos1, pos2 = area.get(10)
|
||||
local axis, n = area.dir(10)
|
||||
local m = area.margin(1)
|
||||
|
||||
local pattern = {testnode1, testnode3, testnode3, testnode2}
|
||||
place_pattern(pos1, pos2, pattern)
|
||||
worldedit.move(pos1, pos2, axis, n)
|
||||
|
||||
check.filled(pos1, pos2, "air")
|
||||
check.pattern(vecw(axis, pos1[axis] + n, pos1), vecw(axis, pos2[axis] + n, pos2), pattern)
|
||||
check.filled2(m, "air")
|
||||
end)
|
||||
|
||||
-- TODO: the rest (also testing param2 + metadata)
|
||||
|
||||
register_test("Schematics")
|
||||
register_test("worldedit.read_header", function()
|
||||
local value = '5,foo,BAR,-1,234:the content'
|
||||
local version, header, content = worldedit.read_header(value)
|
||||
assert(version == 5)
|
||||
assert(#header == 4)
|
||||
assert(header[1] == "foo" and header[2] == "BAR")
|
||||
assert(header[3] == "-1" and header[4] == "234")
|
||||
assert(content == "the content")
|
||||
end)
|
||||
|
||||
register_test("worldedit.allocate", function()
|
||||
local value = '3:-1 0 0 dummy 0 0\n0 0 4 dummy 0 0\n0 1 0 dummy 0 0'
|
||||
local pos1, pos2, count = worldedit.allocate(vec(1, 1, 1), value)
|
||||
assert(vector.equals(pos1, vec(0, 1, 1)))
|
||||
assert(vector.equals(pos2, vec(1, 2, 5)))
|
||||
assert(count == 3)
|
||||
end)
|
||||
|
||||
do
|
||||
local function output_weird(numbers, body)
|
||||
local s = {"return {"}
|
||||
for _, parts in ipairs(numbers) do
|
||||
s[#s+1] = "{"
|
||||
for _, n in ipairs(parts) do
|
||||
s[#s+1] = string.format(" {%d},", n)
|
||||
end
|
||||
s[#s+1] = "},"
|
||||
end
|
||||
return table.concat(s, "\n") .. table.concat(body, "\n") .. "}"
|
||||
end
|
||||
local fmt1p = '{\n ["x"]=%d,\n ["y"]=%d,\n ["z"]=%d,\n},'
|
||||
local fmt1n = '{\n ["name"]="%s",\n},'
|
||||
local fmt4 = '{ ["x"] = %d, ["y"] = %d, ["z"] = %d, ["meta"] = { ["fields"] = { }, ["inventory"] = { } }, ["param2"] = 0, ["param1"] = 0, ["name"] = "%s" }'
|
||||
local fmt5 = '{ ["x"] = %d, ["y"] = %d, ["z"] = %d, ["name"] = "%s" }'
|
||||
local fmt51 = '{[r2]=0,x=%d,y=%d,z=%d,name=r%d}'
|
||||
local fmt52 = '{x=%d,y=%d,z=%d,name=_[%d]}'
|
||||
local test_data = {
|
||||
-- used by WorldEdit 0.2 (first public release)
|
||||
{
|
||||
name = "v1", ver = 1,
|
||||
gen = function(pat)
|
||||
local numbers = {
|
||||
{2, 3, 4, 5, 6},
|
||||
{7, 8}, {9, 10}, {11, 12},
|
||||
{13, 14}, {15, 16}
|
||||
}
|
||||
return output_weird(numbers, {
|
||||
fmt1p:format(0, 0, 0),
|
||||
fmt1n:format(pat[1]),
|
||||
fmt1p:format(0, 1, 0),
|
||||
fmt1n:format(pat[3]),
|
||||
fmt1p:format(1, 1, 0),
|
||||
fmt1n:format(pat[1]),
|
||||
fmt1p:format(1, 0, 1),
|
||||
fmt1n:format(pat[3]),
|
||||
fmt1p:format(0, 1, 1),
|
||||
fmt1n:format(pat[1]),
|
||||
})
|
||||
end
|
||||
},
|
||||
|
||||
-- v2: missing because I couldn't find any code in my archives that actually wrote this format
|
||||
|
||||
{
|
||||
name = "v3", ver = 3,
|
||||
gen = function(pat)
|
||||
assert(pat[2] == "air")
|
||||
return table.concat({
|
||||
"0 0 0 " .. pat[1] .. " 0 0",
|
||||
"0 1 0 " .. pat[3] .. " 0 0",
|
||||
"1 1 0 " .. pat[1] .. " 0 0",
|
||||
"1 0 1 " .. pat[3] .. " 0 0",
|
||||
"0 1 1 " .. pat[1] .. " 0 0",
|
||||
}, "\n")
|
||||
end
|
||||
},
|
||||
|
||||
{
|
||||
name = "v4", ver = 4,
|
||||
gen = function(pat)
|
||||
return table.concat({
|
||||
"return { " .. fmt4:format(0, 0, 0, pat[1]),
|
||||
fmt4:format(0, 1, 0, pat[3]),
|
||||
fmt4:format(1, 1, 0, pat[1]),
|
||||
fmt4:format(1, 0, 1, pat[3]),
|
||||
fmt4:format(0, 1, 1, pat[1]) .. " }",
|
||||
}, ", ")
|
||||
end
|
||||
},
|
||||
|
||||
-- like v4 but no meta and param (if empty)
|
||||
{
|
||||
name = "v5 (pre-5.6)", ver = 5,
|
||||
gen = function(pat)
|
||||
return table.concat({
|
||||
"5:return { " .. fmt5:format(0, 0, 0, pat[1]),
|
||||
fmt5:format(0, 1, 0, pat[3]),
|
||||
fmt5:format(1, 1, 0, pat[1]),
|
||||
fmt5:format(1, 0, 1, pat[3]),
|
||||
fmt5:format(0, 1, 1, pat[1]) .. " }",
|
||||
}, ", ")
|
||||
end
|
||||
},
|
||||
|
||||
-- reworked engine serialization in 5.6
|
||||
{
|
||||
name = "v5 (5.6)", ver = 5,
|
||||
gen = function(pat)
|
||||
return table.concat({
|
||||
'5:r1="' .. pat[1] .. '";r2="param1";r3="' .. pat[3] .. '";return {'
|
||||
.. fmt51:format(0, 0, 0, 1),
|
||||
fmt51:format(0, 1, 0, 3),
|
||||
fmt51:format(1, 1, 0, 1),
|
||||
fmt51:format(1, 0, 1, 3),
|
||||
fmt51:format(0, 1, 1, 1) .. "}",
|
||||
}, ",")
|
||||
end
|
||||
},
|
||||
|
||||
-- small changes on engine side again
|
||||
{
|
||||
name = "v5 (post-5.7)", ver = 5,
|
||||
gen = function(pat)
|
||||
return table.concat({
|
||||
'5:local _={};_[1]="' .. pat[1] .. '";_[3]="' .. pat[3] .. '";return {'
|
||||
.. fmt52:format(0, 0, 0, 1),
|
||||
fmt52:format(0, 1, 0, 3),
|
||||
fmt52:format(1, 1, 0, 1),
|
||||
fmt52:format(1, 0, 1, 3),
|
||||
fmt52:format(0, 1, 1, 1) .. "}",
|
||||
}, ",")
|
||||
end
|
||||
},
|
||||
}
|
||||
for _, e in ipairs(test_data) do
|
||||
register_test("worldedit.deserialize " .. e.name, function()
|
||||
local pos1, pos2 = area.get(2)
|
||||
local m = area.margin(1)
|
||||
|
||||
local pat = {testnode3, "air", testnode2}
|
||||
local value = e.gen(pat)
|
||||
assert(type(value) == "string")
|
||||
|
||||
local version = worldedit.read_header(value)
|
||||
assert(version == e.ver, "version: got " .. tostring(version) .. " expected " .. e.ver)
|
||||
local count = worldedit.deserialize(pos1, value)
|
||||
assert(count ~= nil and count > 0)
|
||||
|
||||
check.pattern(pos1, pos2, pat)
|
||||
check.filled2(m, "air")
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------
|
||||
-- Main function
|
||||
---------------------
|
||||
worldedit.run_tests = function()
|
||||
do
|
||||
local v = minetest.get_version()
|
||||
print("Running " .. #tests .. " tests for WorldEdit " ..
|
||||
worldedit.version_string .. " on " .. v.project .. " " .. (v.hash or v.string))
|
||||
end
|
||||
|
||||
init_nodes()
|
||||
|
||||
-- emerge area from (0,0,0) ~ (56,56,56) and keep it loaded
|
||||
-- Note: making this area smaller speeds up tests
|
||||
local wanted = vec(56, 56, 56)
|
||||
for x = 0, math.floor(wanted.x/16) do
|
||||
for y = 0, math.floor(wanted.y/16) do
|
||||
for z = 0, math.floor(wanted.z/16) do
|
||||
assert(minetest.forceload_block(vector.new(x*16, y*16, z*16), true))
|
||||
end
|
||||
end
|
||||
end
|
||||
area.assign(vec(0, 0, 0), wanted, function()
|
||||
|
||||
local failed = 0
|
||||
for _, test in ipairs(tests) do
|
||||
if not test.func then
|
||||
local s = "---- " .. test.name .. " "
|
||||
print(s .. string.rep("-", 60 - #s))
|
||||
else
|
||||
if not test.dry then
|
||||
area.clear()
|
||||
end
|
||||
local ok, err = pcall(test.func)
|
||||
print(string.format("%-60s %s", test.name, ok and "pass" or "FAIL"))
|
||||
if not ok then
|
||||
print(" " .. err)
|
||||
failed = failed + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print("Done, " .. failed .. " tests failed.")
|
||||
if failed == 0 then
|
||||
io.close(io.open(minetest.get_worldpath() .. "/tests_ok", "w"))
|
||||
end
|
||||
minetest.request_shutdown()
|
||||
end)
|
||||
end
|
||||
|
||||
-- for debug purposes
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
minetest.set_player_privs(player:get_player_name(),
|
||||
minetest.string_to_privs("fly,fast,noclip,basic_debug,debug,interact"))
|
||||
end)
|
||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
||||
minetest.chat_send_player(puncher:get_player_name(), pos2str(pos))
|
||||
end)
|
Before Width: | Height: | Size: 442 B |
@ -6,6 +6,7 @@ minetest.register_node("worldedit:placeholder", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
diggable = false,
|
||||
pointable = false,
|
||||
walkable = false,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
@ -18,7 +19,7 @@ function worldedit.hide(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local pos = vector.new(pos1.x, 0, 0)
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
while pos.x <= pos2.x do
|
||||
@ -78,7 +79,7 @@ function worldedit.highlight(pos1, pos2, node_name)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local pos = vector.new(pos1.x, 0, 0)
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
local count = 0
|
||||
|
125
worldedit_brush/init.lua
Normal file
@ -0,0 +1,125 @@
|
||||
if minetest.raycast == nil then
|
||||
error(
|
||||
"worldedit_brush requires at least Minetest 5.0"
|
||||
)
|
||||
end
|
||||
|
||||
local BRUSH_MAX_DIST = 150
|
||||
local brush_on_use = function(itemstack, placer)
|
||||
local meta = itemstack:get_meta()
|
||||
local name = placer:get_player_name()
|
||||
|
||||
local cmd = meta:get_string("command")
|
||||
if cmd == "" then
|
||||
worldedit.player_notify(name,
|
||||
"This brush is not bound, use //brush to bind a command to it.")
|
||||
return false
|
||||
end
|
||||
|
||||
local cmddef = worldedit.registered_commands[cmd]
|
||||
if cmddef == nil then return false end -- shouldn't happen as //brush checks this
|
||||
|
||||
local has_privs, missing_privs = minetest.check_player_privs(name, cmddef.privs)
|
||||
if not has_privs then
|
||||
worldedit.player_notify(name,
|
||||
"Missing privileges: " .. table.concat(missing_privs, ", "))
|
||||
return false
|
||||
end
|
||||
|
||||
local raybegin = vector.add(placer:get_pos(),
|
||||
vector.new(0, placer:get_properties().eye_height, 0))
|
||||
local rayend = vector.add(raybegin, vector.multiply(placer:get_look_dir(), BRUSH_MAX_DIST))
|
||||
local ray = minetest.raycast(raybegin, rayend, false, true)
|
||||
local pointed_thing = ray:next()
|
||||
if pointed_thing == nil then
|
||||
worldedit.player_notify(name, "Too far away.")
|
||||
return false
|
||||
end
|
||||
|
||||
assert(pointed_thing.type == "node")
|
||||
worldedit.pos1[name] = pointed_thing.under
|
||||
worldedit.pos2[name] = nil
|
||||
worldedit.marker_update(name)
|
||||
|
||||
-- this isn't really clean...
|
||||
local player_notify_old = worldedit.player_notify
|
||||
worldedit.player_notify = function(name, msg)
|
||||
if string.match(msg, "^%d") then return end -- discard "1234 nodes added."
|
||||
return player_notify_old(name, msg)
|
||||
end
|
||||
|
||||
assert(cmddef.require_pos < 2)
|
||||
local parsed = {cmddef.parse(meta:get_string("params"))}
|
||||
if not table.remove(parsed, 1) then return false end -- shouldn't happen
|
||||
|
||||
minetest.log("action", string.format("%s uses WorldEdit brush (//%s) at %s",
|
||||
name, cmd, minetest.pos_to_string(pointed_thing.under)))
|
||||
cmddef.func(name, unpack(parsed))
|
||||
|
||||
worldedit.player_notify = player_notify_old
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_tool(":worldedit:brush", {
|
||||
description = "WorldEdit Brush",
|
||||
inventory_image = "worldedit_brush.png",
|
||||
stack_max = 1, -- no need to stack these (metadata prevents this anyway)
|
||||
range = 0,
|
||||
on_use = function(itemstack, placer, pointed_thing)
|
||||
brush_on_use(itemstack, placer)
|
||||
return itemstack -- nothing consumed, nothing changed
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_command("brush", {
|
||||
privs = {worldedit=true},
|
||||
params = "none/<cmd> [parameters]",
|
||||
description = "Assign command to WorldEdit brush item",
|
||||
parse = function(param)
|
||||
local found, _, cmd, params = param:find("^([^%s]+)%s+(.+)$")
|
||||
if not found then
|
||||
params = ""
|
||||
found, _, cmd = param:find("^(.+)$")
|
||||
end
|
||||
if not found then
|
||||
return false
|
||||
end
|
||||
return true, cmd, params
|
||||
end,
|
||||
func = function(name, cmd, params)
|
||||
local itemstack = minetest.get_player_by_name(name):get_wielded_item()
|
||||
if itemstack == nil or itemstack:get_name() ~= "worldedit:brush" then
|
||||
worldedit.player_notify(name, "Not holding brush item.")
|
||||
return
|
||||
end
|
||||
|
||||
cmd = cmd:lower()
|
||||
local meta = itemstack:get_meta()
|
||||
if cmd == "none" then
|
||||
meta:from_table(nil)
|
||||
worldedit.player_notify(name, "Brush assignment cleared.")
|
||||
else
|
||||
local cmddef = worldedit.registered_commands[cmd]
|
||||
if cmddef == nil or cmddef.require_pos ~= 1 then
|
||||
worldedit.player_notify(name, "//" .. cmd .. " cannot be used with brushes")
|
||||
return
|
||||
end
|
||||
|
||||
-- Try parsing command params so we can give the user feedback
|
||||
local ok, err = cmddef.parse(params)
|
||||
if not ok then
|
||||
err = err or "invalid usage"
|
||||
worldedit.player_notify(name, "Error with brush command: " .. err)
|
||||
return
|
||||
end
|
||||
|
||||
meta:set_string("command", cmd)
|
||||
meta:set_string("params", params)
|
||||
local fullcmd = "//" .. cmd .. " " .. params
|
||||
meta:set_string("description",
|
||||
minetest.registered_tools["worldedit:brush"].description .. ": " .. fullcmd)
|
||||
worldedit.player_notify(name, "Brush assigned to command: " .. fullcmd)
|
||||
end
|
||||
minetest.get_player_by_name(name):set_wielded_item(itemstack)
|
||||
end,
|
||||
})
|
3
worldedit_brush/mod.conf
Normal file
@ -0,0 +1,3 @@
|
||||
name = worldedit_brush
|
||||
description = WorldEdit brush
|
||||
depends = worldedit, worldedit_commands
|
BIN
worldedit_brush/textures/worldedit_brush.png
Normal file
After Width: | Height: | Size: 301 B |
@ -1,28 +1,24 @@
|
||||
minetest.register_chatcommand("/outset", {
|
||||
params = "[h|v] <amount>",
|
||||
description = "outset the selection",
|
||||
local S = minetest.get_translator("worldedit_commands")
|
||||
|
||||
worldedit.register_command("outset", {
|
||||
params = "[h/v] <amount>",
|
||||
description = S("Outset the selected region."),
|
||||
privs = {worldedit=true},
|
||||
func = function(name, param)
|
||||
require_pos = 2,
|
||||
parse = function(param)
|
||||
local find, _, dir, amount = param:find("(%a*)%s*([+-]?%d+)")
|
||||
|
||||
if find == nil then
|
||||
return false, "invalid usage: " .. param
|
||||
return false
|
||||
end
|
||||
|
||||
local pos1 = worldedit.pos1[name]
|
||||
local pos2 = worldedit.pos2[name]
|
||||
|
||||
if pos1 == nil or pos2 == nil then
|
||||
return false,
|
||||
"Undefined region. Region must be defined beforehand."
|
||||
end
|
||||
|
||||
|
||||
local hv_test = dir:find("[^hv]+")
|
||||
|
||||
if hv_test ~= nil then
|
||||
return false, "Invalid direction."
|
||||
return false, S("Invalid direction: @1", dir)
|
||||
end
|
||||
|
||||
|
||||
return true, dir, tonumber(amount)
|
||||
end,
|
||||
func = function(name, dir, amount)
|
||||
if dir == "" or dir == "hv" or dir == "vh" then
|
||||
assert(worldedit.cuboid_volumetric_expand(name, amount))
|
||||
elseif dir == "h" then
|
||||
@ -34,41 +30,32 @@ minetest.register_chatcommand("/outset", {
|
||||
assert(worldedit.cuboid_linear_expand(name, 'y', 1, amount))
|
||||
assert(worldedit.cuboid_linear_expand(name, 'y', -1, amount))
|
||||
else
|
||||
return false, "Invalid number of arguments"
|
||||
return false, S("Invalid number of arguments")
|
||||
end
|
||||
|
||||
|
||||
worldedit.marker_update(name)
|
||||
return true, "Region outset by " .. amount .. " blocks"
|
||||
return true, S("Region outset by @1 nodes", amount)
|
||||
end,
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("/inset", {
|
||||
params = "[h|v] <amount>",
|
||||
description = "inset the selection",
|
||||
worldedit.register_command("inset", {
|
||||
params = "[h/v] <amount>",
|
||||
description = S("Inset the selected region."),
|
||||
privs = {worldedit=true},
|
||||
func = function(name, param)
|
||||
require_pos = 2,
|
||||
parse = function(param)
|
||||
local find, _, dir, amount = param:find("(%a*)%s*([+-]?%d+)")
|
||||
|
||||
if find == nil then
|
||||
return false, "invalid usage: " .. param
|
||||
return false
|
||||
end
|
||||
|
||||
local pos1 = worldedit.pos1[name]
|
||||
local pos2 = worldedit.pos2[name]
|
||||
|
||||
if pos1 == nil or pos2 == nil then
|
||||
return false,
|
||||
"Undefined region. Region must be defined beforehand."
|
||||
if dir:find("[^hv]") ~= nil then
|
||||
return false, S("Invalid direction: @1", dir)
|
||||
end
|
||||
|
||||
local hv_test = dir:find("[^hv]+")
|
||||
|
||||
if hv_test ~= nil then
|
||||
return false, "Invalid direction."
|
||||
end
|
||||
|
||||
|
||||
return true, dir, tonumber(amount)
|
||||
end,
|
||||
func = function(name, dir, amount)
|
||||
if dir == "" or dir == "vh" or dir == "hv" then
|
||||
assert(worldedit.cuboid_volumetric_expand(name, -amount))
|
||||
elseif dir == "h" then
|
||||
@ -80,36 +67,29 @@ minetest.register_chatcommand("/inset", {
|
||||
assert(worldedit.cuboid_linear_expand(name, 'y', 1, -amount))
|
||||
assert(worldedit.cuboid_linear_expand(name, 'y', -1, -amount))
|
||||
else
|
||||
return false, "Invalid number of arguments"
|
||||
return false, S("Invalid number of arguments")
|
||||
end
|
||||
|
||||
|
||||
worldedit.marker_update(name)
|
||||
return true, "Region inset by " .. amount .. " blocks"
|
||||
return true, S("Region inset by @1 nodes", amount)
|
||||
end,
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("/shift", {
|
||||
params = "[x|y|z|?|up|down|left|right|front|back] [+|-]<amount>",
|
||||
description = "Moves the selection region. Does not move contents.",
|
||||
worldedit.register_command("shift", {
|
||||
params = "x/y/z/?/up/down/left/right/front/back [+/-]<amount>",
|
||||
description = S("Shifts the selection area without moving its contents"),
|
||||
privs = {worldedit=true},
|
||||
func = function(name, param)
|
||||
local pos1 = worldedit.pos1[name]
|
||||
local pos2 = worldedit.pos2[name]
|
||||
require_pos = 2,
|
||||
parse = function(param)
|
||||
local find, _, direction, amount = param:find("([%?%l]+)%s*([+-]?%d+)")
|
||||
|
||||
if find == nil then
|
||||
worldedit.player_notify(name, "invalid usage: " .. param)
|
||||
return
|
||||
return false
|
||||
end
|
||||
|
||||
if pos1 == nil or pos2 == nil then
|
||||
worldedit.player_notify(name,
|
||||
"Undefined region. Region must be defined beforehand.")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
return true, direction, tonumber(amount)
|
||||
end,
|
||||
func = function(name, direction, amount)
|
||||
local axis, dir
|
||||
if direction == "x" or direction == "y" or direction == "z" then
|
||||
axis, dir = direction, 1
|
||||
@ -118,123 +98,170 @@ minetest.register_chatcommand("/shift", {
|
||||
else
|
||||
axis, dir = worldedit.translate_direction(name, direction)
|
||||
end
|
||||
|
||||
|
||||
if axis == nil or dir == nil then
|
||||
return false, "Invalid if looking straight up or down"
|
||||
return false, S("Invalid if looking straight up or down")
|
||||
end
|
||||
|
||||
|
||||
assert(worldedit.cuboid_shift(name, axis, amount * dir))
|
||||
worldedit.marker_update(name)
|
||||
|
||||
return true, "Region shifted by " .. amount .. " nodes"
|
||||
|
||||
return true, S("Region shifted by @1 nodes", amount)
|
||||
end,
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("/expand", {
|
||||
params = "[+|-]<x|y|z|?|up|down|left|right|front|back> <amount> [reverse-amount]",
|
||||
description = "expand the selection in one or two directions at once",
|
||||
worldedit.register_command("expand", {
|
||||
params = "[+/-]x/y/z/?/up/down/left/right/front/back <amount> [reverse amount]",
|
||||
description = S("Expands the selection in the selected absolute or relative axis"),
|
||||
privs = {worldedit=true},
|
||||
func = function(name, param)
|
||||
local find, _, sign, direction, amount,
|
||||
rev_amount = param:find("([+-]?)([%?%l]+)%s*(%d+)%s*(%d*)")
|
||||
|
||||
if find == nil then
|
||||
worldedit.player_notify(name, "invalid use: " .. param)
|
||||
return
|
||||
end
|
||||
|
||||
if worldedit.pos1[name] == nil or worldedit.pos2[name] == nil then
|
||||
worldedit.player_notify(name,
|
||||
"Undefined region. Region must be defined beforehand.")
|
||||
return
|
||||
end
|
||||
|
||||
local absolute = direction:find("[xyz?]")
|
||||
local dir, axis
|
||||
|
||||
if rev_amount == "" then
|
||||
rev_amount = 0
|
||||
end
|
||||
|
||||
if absolute == nil then
|
||||
axis, dir = worldedit.translate_direction(name, direction)
|
||||
|
||||
if axis == nil or dir == nil then
|
||||
return false, "Invalid if looking straight up or down"
|
||||
require_pos = 2,
|
||||
parse = function(param)
|
||||
local find, _, sign, direction, amount,
|
||||
rev_amount = param:find("([+-]?)([%?%l]+)%s*(%d+)%s*(%d*)")
|
||||
if find == nil then
|
||||
return false
|
||||
end
|
||||
else
|
||||
if direction == "?" then
|
||||
axis, dir = worldedit.player_axis(name)
|
||||
|
||||
if rev_amount == "" then
|
||||
rev_amount = "0"
|
||||
end
|
||||
|
||||
return true, sign, direction, tonumber(amount), tonumber(rev_amount)
|
||||
end,
|
||||
func = function(name, sign, direction, amount, rev_amount)
|
||||
local absolute = direction:find("[xyz?]")
|
||||
local dir, axis
|
||||
|
||||
if absolute == nil then
|
||||
axis, dir = worldedit.translate_direction(name, direction)
|
||||
|
||||
if axis == nil or dir == nil then
|
||||
return false, S("Invalid if looking straight up or down")
|
||||
end
|
||||
else
|
||||
axis = direction
|
||||
dir = 1
|
||||
if direction == "?" then
|
||||
axis, dir = worldedit.player_axis(name)
|
||||
else
|
||||
axis = direction
|
||||
dir = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if sign == "-" then
|
||||
dir = -dir
|
||||
end
|
||||
|
||||
worldedit.cuboid_linear_expand(name, axis, dir, amount)
|
||||
worldedit.cuboid_linear_expand(name, axis, -dir, rev_amount)
|
||||
worldedit.marker_update(name)
|
||||
return true, "Region expanded by " .. (amount + rev_amount) .. " nodes"
|
||||
end,
|
||||
}
|
||||
)
|
||||
|
||||
if sign == "-" then
|
||||
dir = -dir
|
||||
end
|
||||
|
||||
worldedit.cuboid_linear_expand(name, axis, dir, amount)
|
||||
worldedit.cuboid_linear_expand(name, axis, -dir, rev_amount)
|
||||
worldedit.marker_update(name)
|
||||
return true, S("Region expanded by @1 nodes", amount + rev_amount)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("/contract", {
|
||||
params = "[+|-]<x|y|z|?|up|down|left|right|front|back> <amount> [reverse-amount]",
|
||||
description = "contract the selection in one or two directions at once",
|
||||
worldedit.register_command("contract", {
|
||||
params = "[+/-]x/y/z/?/up/down/left/right/front/back <amount> [reverse amount]",
|
||||
description = S("Contracts the selection in the selected absolute or relative axis"),
|
||||
privs = {worldedit=true},
|
||||
func = function(name, param)
|
||||
local find, _, sign, direction, amount,
|
||||
rev_amount = param:find("([+-]?)([%?%l]+)%s*(%d+)%s*(%d*)")
|
||||
|
||||
if find == nil then
|
||||
worldedit.player_notify(name, "invalid use: " .. param)
|
||||
return
|
||||
end
|
||||
|
||||
if worldedit.pos1[name] == nil or worldedit.pos2[name] == nil then
|
||||
worldedit.player_notify(name,
|
||||
"Undefined region. Region must be defined beforehand.")
|
||||
return
|
||||
end
|
||||
|
||||
local absolute = direction:find("[xyz?]")
|
||||
local dir, axis
|
||||
|
||||
if rev_amount == "" then
|
||||
rev_amount = 0
|
||||
end
|
||||
|
||||
if absolute == nil then
|
||||
axis, dir = worldedit.translate_direction(name, direction)
|
||||
|
||||
if axis == nil or dir == nil then
|
||||
return false, "Invalid if looking straight up or down"
|
||||
require_pos = 2,
|
||||
parse = function(param)
|
||||
local find, _, sign, direction, amount,
|
||||
rev_amount = param:find("([+-]?)([%?%l]+)%s*(%d+)%s*(%d*)")
|
||||
if find == nil then
|
||||
return false
|
||||
end
|
||||
else
|
||||
if direction == "?" then
|
||||
axis, dir = worldedit.player_axis(name)
|
||||
|
||||
if rev_amount == "" then
|
||||
rev_amount = "0"
|
||||
end
|
||||
|
||||
return true, sign, direction, tonumber(amount), tonumber(rev_amount)
|
||||
end,
|
||||
func = function(name, sign, direction, amount, rev_amount)
|
||||
local absolute = direction:find("[xyz?]")
|
||||
local dir, axis
|
||||
|
||||
if absolute == nil then
|
||||
axis, dir = worldedit.translate_direction(name, direction)
|
||||
|
||||
if axis == nil or dir == nil then
|
||||
return false, S("Invalid if looking straight up or down")
|
||||
end
|
||||
else
|
||||
axis = direction
|
||||
dir = 1
|
||||
if direction == "?" then
|
||||
axis, dir = worldedit.player_axis(name)
|
||||
else
|
||||
axis = direction
|
||||
dir = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if sign == "-" then
|
||||
dir = -dir
|
||||
end
|
||||
|
||||
worldedit.cuboid_linear_expand(name, axis, dir, -amount)
|
||||
worldedit.cuboid_linear_expand(name, axis, -dir, -rev_amount)
|
||||
worldedit.marker_update(name)
|
||||
return true, "Region contracted by " .. (amount + rev_amount) .. " nodes"
|
||||
end,
|
||||
}
|
||||
)
|
||||
|
||||
if sign == "-" then
|
||||
dir = -dir
|
||||
end
|
||||
|
||||
worldedit.cuboid_linear_expand(name, axis, dir, -amount)
|
||||
worldedit.cuboid_linear_expand(name, axis, -dir, -rev_amount)
|
||||
worldedit.marker_update(name)
|
||||
return true, S("Region contracted by @1 nodes", amount + rev_amount)
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_command("cubeapply", {
|
||||
params = "<size>/(<sizex> <sizey> <sizez>) <command> [parameters]",
|
||||
description = S("Select a cube with side length <size> around position 1 and run <command> on region"),
|
||||
privs = {worldedit=true},
|
||||
require_pos = 1,
|
||||
parse = function(param)
|
||||
local found, _, sidex, sidey, sidez, cmd, args =
|
||||
param:find("^(%d+)%s+(%d+)%s+(%d+)%s+([^%s]+)%s*(.*)$")
|
||||
if found == nil then
|
||||
found, _, sidex, cmd, args = param:find("^(%d+)%s+([^%s]+)%s*(.*)$")
|
||||
if found == nil then
|
||||
return false
|
||||
end
|
||||
sidey = sidex
|
||||
sidez = sidex
|
||||
end
|
||||
sidex = tonumber(sidex)
|
||||
sidey = tonumber(sidey)
|
||||
sidez = tonumber(sidez)
|
||||
if sidex < 1 or sidey < 1 or sidez < 1 then
|
||||
return false
|
||||
end
|
||||
local cmddef = worldedit.registered_commands[cmd]
|
||||
if cmddef == nil or cmddef.require_pos ~= 2 then
|
||||
return false, S("invalid usage: //@1 cannot be used with cubeapply", cmd)
|
||||
end
|
||||
-- run parsing of target command
|
||||
local parsed = {cmddef.parse(args)}
|
||||
if not table.remove(parsed, 1) then
|
||||
return false, parsed[1]
|
||||
end
|
||||
return true, sidex, sidey, sidez, cmd, parsed
|
||||
end,
|
||||
nodes_needed = function(name, sidex, sidey, sidez, cmd, parsed)
|
||||
-- its not possible to defer to the target command at this point
|
||||
return sidex * sidey * sidez
|
||||
end,
|
||||
func = function(name, sidex, sidey, sidez, cmd, parsed)
|
||||
local cmddef = assert(worldedit.registered_commands[cmd])
|
||||
local success, missing_privs = minetest.check_player_privs(name, cmddef.privs)
|
||||
if not success then
|
||||
worldedit.player_notify(name, S("Missing privileges: @1", table.concat(missing_privs, ", ")))
|
||||
return
|
||||
end
|
||||
|
||||
-- update region to be the cuboid the user wanted
|
||||
local half = vector.divide(vector.new(sidex, sidey, sidez), 2)
|
||||
local sizea, sizeb = vector.apply(half, math.floor), vector.apply(half, math.ceil)
|
||||
local center = worldedit.pos1[name]
|
||||
worldedit.pos1[name] = vector.subtract(center, sizea)
|
||||
worldedit.pos2[name] = vector.add(center, vector.subtract(sizeb, 1))
|
||||
worldedit.marker_update(name)
|
||||
|
||||
-- actually run target command
|
||||
return cmddef.func(name, unpack(parsed))
|
||||
end,
|
||||
})
|
||||
|
@ -1 +0,0 @@
|
||||
worldedit
|
145
worldedit_commands/locale/template.txt
Normal file
@ -0,0 +1,145 @@
|
||||
# textdomain: worldedit_commands
|
||||
Outset the selected region.=
|
||||
Invalid direction: @1=
|
||||
Invalid number of arguments=
|
||||
Region outset by @1 nodes=
|
||||
Inset the selected region.=
|
||||
Region inset by @1 nodes=
|
||||
Shifts the selection area without moving its contents=
|
||||
Invalid if looking straight up or down=
|
||||
Region shifted by @1 nodes=
|
||||
Expands the selection in the selected absolute or relative axis=
|
||||
Region expanded by @1 nodes=
|
||||
Contracts the selection in the selected absolute or relative axis=
|
||||
Region contracted by @1 nodes=
|
||||
Select a cube with side length <size> around position 1 and run <command> on region=
|
||||
invalid usage: //@1 cannot be used with cubeapply=
|
||||
Missing privileges: @1=
|
||||
Can use WorldEdit commands=
|
||||
no region selected=
|
||||
no position 1 selected=
|
||||
invalid usage=
|
||||
Could not open file "@1"=
|
||||
Invalid file format!=
|
||||
Schematic was created with a newer version of WorldEdit.=
|
||||
Get information about the WorldEdit mod=
|
||||
WorldEdit @1 is available on this server. Type //help to get a list of commands, or get more information at @2=
|
||||
Get help for WorldEdit commands=
|
||||
You are not allowed to use any WorldEdit commands.=
|
||||
Available commands: @1@nUse '//help <cmd>' to get more information, or '//help all' to list everything.=
|
||||
Available commands:@n=
|
||||
Command not available: =
|
||||
Enable or disable node inspection=
|
||||
inspector: inspection enabled for @1, currently facing the @2 axis=
|
||||
inspector: inspection disabled=
|
||||
inspector: @1 at @2 (param1@=@3, param2@=@4, received light@=@5) punched facing the @6 axis=
|
||||
Reset the region so that it is empty=
|
||||
region reset=
|
||||
Show markers at the region positions=
|
||||
region marked=
|
||||
Hide markers if currently shown=
|
||||
region unmarked=
|
||||
Set WorldEdit region position @1 to the player's location=
|
||||
position @1 set to @2=
|
||||
Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region=
|
||||
unknown subcommand: @1=
|
||||
select positions by punching two nodes=
|
||||
select position @1 by punching a node=
|
||||
position @1: @2=
|
||||
position @1 not set=
|
||||
Set a WorldEdit region position to the position at (<x>, <y>, <z>)=
|
||||
Display the volume of the current WorldEdit region=
|
||||
current region has a volume of @1 nodes (@2*@3*@4)=
|
||||
Remove all MapBlocks (16x16x16) containing the selected area from the map=
|
||||
Area deleted.=
|
||||
There was an error during deletion of the area.=
|
||||
Set the current WorldEdit region to <node>=
|
||||
invalid node name: @1=
|
||||
@1 nodes set=
|
||||
Set param2 of all nodes in the current WorldEdit region to <param2>=
|
||||
Param2 is out of range (must be between 0 and 255 inclusive!)=
|
||||
@1 nodes altered=
|
||||
Fill the current WorldEdit region with a random mix of <node1>, ...=
|
||||
invalid search node name: @1=
|
||||
invalid replace node name: @1=
|
||||
Replace all instances of <search node> with <replace node> in the current WorldEdit region=
|
||||
@1 nodes replaced=
|
||||
Replace all nodes other than <search node> with <replace node> in the current WorldEdit region=
|
||||
Add a hollow cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.=
|
||||
@1 nodes added=
|
||||
Add a cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.=
|
||||
Add hollow sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>=
|
||||
Add sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>=
|
||||
Add hollow dome centered at WorldEdit position 1 with radius <radius>, composed of <node>=
|
||||
Add dome centered at WorldEdit position 1 with radius <radius>, composed of <node>=
|
||||
Add hollow cylinder at WorldEdit position 1 along the given axis with length <length>, base radius <radius1> (and top radius [radius2]), composed of <node>=
|
||||
Add cylinder at WorldEdit position 1 along the given axis with length <length>, base radius <radius1> (and top radius [radius2]), composed of <node>=
|
||||
Add hollow pyramid centered at WorldEdit position 1 along the given axis with height <height>, composed of <node>=
|
||||
Add pyramid centered at WorldEdit position 1 along the given axis with height <height>, composed of <node>=
|
||||
Add spiral centered at WorldEdit position 1 with side length <length>, height <height>, space between walls <space>, composed of <node>=
|
||||
Copy the current WorldEdit region along the given axis by <amount> nodes=
|
||||
@1 nodes copied=
|
||||
Move the current WorldEdit region along the given axis by <amount> nodes=
|
||||
@1 nodes moved=
|
||||
Stack the current WorldEdit region along the given axis <count> times=
|
||||
@1 nodes stacked=
|
||||
Stack the current WorldEdit region <count> times by offset <x>, <y>, <z>=
|
||||
invalid count: @1=
|
||||
invalid increments: @1=
|
||||
Scale the current WorldEdit positions and region by a factor of <stretchx>, <stretchy>, <stretchz> along the X, Y, and Z axes, repectively, with position 1 as the origin=
|
||||
invalid scaling factors: @1=
|
||||
@1 nodes stretched=
|
||||
Transpose the current WorldEdit region along the given axes=
|
||||
invalid usage: axes must be different=
|
||||
@1 nodes transposed=
|
||||
Flip the current WorldEdit region along the given axis=
|
||||
@1 nodes flipped=
|
||||
Rotate the current WorldEdit region around the given axis by angle <angle> (90 degree increment)=
|
||||
invalid usage: angle must be multiple of 90=
|
||||
@1 nodes rotated=
|
||||
Rotate oriented nodes in the current WorldEdit region around the Y axis by angle <angle> (90 degree increment)=
|
||||
@1 nodes oriented=
|
||||
Fix the lighting in the current WorldEdit region=
|
||||
@1 nodes updated=
|
||||
Remove any fluid node within the current WorldEdit region=
|
||||
Remove any plant, tree or foliage-like nodes in the selected region=
|
||||
@1 nodes removed=
|
||||
Hide all nodes in the current WorldEdit region non-destructively=
|
||||
@1 nodes hidden=
|
||||
Suppress all <node> in the current WorldEdit region non-destructively=
|
||||
@1 nodes suppressed=
|
||||
Highlight <node> in the current WorldEdit region by hiding everything else non-destructively=
|
||||
@1 nodes highlighted=
|
||||
Restores nodes hidden with WorldEdit in the current WorldEdit region=
|
||||
@1 nodes restored=
|
||||
Warning: The schematic contains excessive free space and WILL be misaligned when allocated or loaded. To avoid this, shrink your area to cover exactly the nodes to be saved.=
|
||||
Save the current WorldEdit region to "(world folder)/schems/<file>.we"=
|
||||
Disallowed file name: @1=
|
||||
Could not save file to "@1"=
|
||||
@1 nodes saved=
|
||||
Set the region defined by nodes from "(world folder)/schems/<file>.we" as the current WorldEdit region=
|
||||
Schematic empty, nothing allocated=
|
||||
@1 nodes allocated=
|
||||
Load nodes from "(world folder)/schems/<file>[.we[m]]" with position 1 of the current WorldEdit region as the origin=
|
||||
Loading failed!=
|
||||
@1 nodes loaded=
|
||||
Executes <code> as a Lua chunk in the global namespace=
|
||||
Executes <code> as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region=
|
||||
Save the current WorldEdit region using the Minetest Schematic format to "(world folder)/schems/<filename>.mts"=
|
||||
Failed to create Minetest schematic=
|
||||
Saved Minetest schematic to @1=
|
||||
Load nodes from "(world folder)/schems/<file>.mts" with position 1 of the current WorldEdit region as the origin=
|
||||
failed to place Minetest schematic=
|
||||
placed Minetest schematic @1 at @2=
|
||||
Begins node probability entry for Minetest schematics, gets the nodes that have probabilities set, or ends node probability entry=
|
||||
select Minetest schematic probability values by punching nodes=
|
||||
finished Minetest schematic probability selection=
|
||||
currently set node probabilities:=
|
||||
invalid node probability given, not saved=
|
||||
Clears all objects within the WorldEdit region=
|
||||
@1 objects cleared=
|
||||
WARNING: this operation could affect up to @1 nodes; type //y to continue or //n to cancel=
|
||||
Confirm a pending operation=
|
||||
no operation pending=
|
||||
Abort a pending operation=
|
||||
WorldEdit Wand tool@nLeft-click to set 1st position, right-click to set 2nd=
|
156
worldedit_commands/locale/worldedit_commands.de.tr
Normal file
@ -0,0 +1,156 @@
|
||||
# textdomain: worldedit_commands
|
||||
##
|
||||
# Übersetzungshinweise:
|
||||
# node = Block
|
||||
# command = Befehl
|
||||
# region = Gebiet
|
||||
# position 1/2 = Position 1/2
|
||||
# schematic = Schematic
|
||||
# Der Anwender wird gesiezt.
|
||||
# Diese Datei auf Rechtschreibfehler prüfen (unter Linux):
|
||||
# sed -rne 's|^.*[^@]=(.*)$|\1|gp' worldedit_commands/locale/worldedit_commands.de.tr | sed -re 's/\b(WorldEdit|Schematic|Minetest)\b/Beispiel/g' | LANG=de_DE.UTF-8 hunspell -L
|
||||
##
|
||||
Outset the selected region.=Ausgewähltes Gebiet vergrößern.
|
||||
Invalid direction: @1=Ungültige Richtung: @1
|
||||
Invalid number of arguments=Ungültige Anzahl der Argumente
|
||||
Region outset by @1 nodes=Gebiet um @1 Blöcke vergrößert
|
||||
Inset the selected region.=Ausgewähltes Gebiet verkleinern.
|
||||
Region inset by @1 nodes=Gebiet um @1 Blöcke verkleinert
|
||||
Shifts the selection area without moving its contents=Verschiebt das ausgewählte Gebiet ohne dessen Inhalt
|
||||
Invalid if looking straight up or down=Nicht zulässig bei gerade Blickrichtung nach unten oder oben
|
||||
Region shifted by @1 nodes=Gebiet um @1 Blöcke verschoben
|
||||
Expands the selection in the selected absolute or relative axis=Erweitert das Gebiet in Richtung einer absoluten oder relativen Achse
|
||||
Region expanded by @1 nodes=Gebiet um @1 Blöcke erweitert
|
||||
Contracts the selection in the selected absolute or relative axis=Schrumpft das Gebiet in Richtung einer absoluten oder relativen Achse
|
||||
Region contracted by @1 nodes=Gebiet um @1 Blöcke geschrumpft
|
||||
Select a cube with side length <size> around position 1 and run <command> on region=Wähle einen Würfel mit Seitenlänge <size> um Position 1 und führe <command> auf diesem Gebiet aus
|
||||
invalid usage: //@1 cannot be used with cubeapply=Ungültige Verwendung: //@1 kann nicht mit cubeapply verwendet werden
|
||||
Missing privileges: @1=Fehlende Privilegien: @1
|
||||
Can use WorldEdit commands=Kann WorldEdit-Befehle benutzen
|
||||
no region selected=Kein Gebiet ausgewählt
|
||||
no position 1 selected=Keine Position 1 ausgewählt
|
||||
invalid usage=Ungültige Verwendung
|
||||
Could not open file "@1"=Konnte die Datei „@1“ nicht öffnen
|
||||
Invalid file format!=Ungültiges Dateiformat!
|
||||
Schematic was created with a newer version of WorldEdit.=Schematic wurde mit einer neueren Version von WorldEdit erstellt.
|
||||
Get information about the WorldEdit mod=Informationen über den WorldEdit-Mod erhalten.
|
||||
WorldEdit @1 is available on this server. Type //help to get a list of commands, or get more information at @2=WorldEdit @1 ist auf diesem Server verfügbar. Nutzen Sie //help, um eine Liste der Befehle zu erhalten, oder finden Sie weitere Informationen unter @2
|
||||
Get help for WorldEdit commands=Hilfe für WorldEdit-Befehle erhalten
|
||||
You are not allowed to use any WorldEdit commands.=Ihnen ist nicht erlaubt WorldEdit-Befehle zu nutzen.
|
||||
Available commands: @1@nUse '//help <cmd>' to get more information, or '//help all' to list everything.=Verfügbare Befehle: @1@n„//help <Befehl>“ benutzen, um mehr Informationen zu erhalten, oder „//help all“, um alles aufzulisten.
|
||||
Available commands:@n=Verfügbare Befehle:@n
|
||||
Command not available: =Befehl nicht verfügbar:
|
||||
Enable or disable node inspection=Inspizieren von Blöcken ein- oder ausschalten
|
||||
inspector: inspection enabled for @1, currently facing the @2 axis=Inspektur: für @1 aktiviert, aktuell der @2-Achse zugewandt
|
||||
inspector: inspection disabled=Inspektur: deaktiviert
|
||||
inspector: @1 at @2 (param1@=@3, param2@=@4, received light@=@5) punched facing the @6 axis=Inspektur: @1 bei @2 (param1@=@3, param2@=@4, einfallendes Licht@=@5), der @6-Achse zugewandt, gehauen
|
||||
Reset the region so that it is empty=Gebiet zurücksetzen, sodass es leer ist
|
||||
region reset=Gebiet zurückgesetzt
|
||||
Show markers at the region positions=Markierungen bei den Gebietsposition anzeigen
|
||||
region marked=Gebiet markiert
|
||||
Hide markers if currently shown=Markierungen verstecken falls derzeit sichtbar
|
||||
region unmarked=Gebiet nicht mehr markiert
|
||||
Set WorldEdit region position @1 to the player's location=Position @1 des WorldEdit-Gebiets auf die Position des Spieler setzen
|
||||
position @1 set to @2=Position @1 auf @2 gesetzt
|
||||
Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region=
|
||||
unknown subcommand: @1=Unbekannter Unterbefehl: @1
|
||||
select positions by punching two nodes=Wählen Sie die Position durch Hauen zweier Blöcke
|
||||
select position @1 by punching a node=Wählen Sie Position @1 durch Hauen eines Blocks
|
||||
position @1: @2=Position @1: @2
|
||||
position @1 not set=Position @1 ist nicht gesetzt
|
||||
Set a WorldEdit region position to the position at (<x>, <y>, <z>)=Position des WorldEdit-Gebiets auf (<x>, <y>, <z>) setzen
|
||||
Display the volume of the current WorldEdit region=Volumen des aktuellen WorldEdit-Gebiets anzeigen
|
||||
current region has a volume of @1 nodes (@2*@3*@4)=Das aktuelle Gebiet hat ein Volumen von @1 Blöcken (@2*@3*@4)
|
||||
Remove all MapBlocks (16x16x16) containing the selected area from the map=Alle Kartenblöcke (16x16x16) entfernen, die das Gebiet enthalten.
|
||||
Area deleted.=Gebiet gelöscht.
|
||||
There was an error during deletion of the area.=Während des Löschens des Gebiets trat ein Fehler aus.
|
||||
Set the current WorldEdit region to <node>=Das aktuelle WorldEdit-Gebiet mit <node> füllen
|
||||
invalid node name: @1=Ungültiger Blockname: @1
|
||||
@1 nodes set=@1 Blöcke gesetzt
|
||||
Set param2 of all nodes in the current WorldEdit region to <param2>=Den param2 aller Blocke im aktuellen WorldEdit-Gebiet auf <param2> setzen
|
||||
Param2 is out of range (must be between 0 and 255 inclusive!)=Param2 muss zwischen 0 und 255 (inklusiv) sein
|
||||
@1 nodes altered=@1 Blöcke verändert
|
||||
Fill the current WorldEdit region with a random mix of <node1>, ...=Das aktuelle WorldEdit-Gebiet mit einer zufälligen Mischung aus <node1>, ... füllen
|
||||
invalid search node name: @1=Ungültiger Blockname für die Suche: @1
|
||||
invalid replace node name: @1=Ungültiger Blockname für das Ersetzen: @1
|
||||
Replace all instances of <search node> with <replace node> in the current WorldEdit region=Alle Vorkommen von <search node> im aktuellen WorldEdit-Gebiet mit <replace node> ersetzen
|
||||
@1 nodes replaced=@1 Blöcke ersetzt
|
||||
Replace all nodes other than <search node> with <replace node> in the current WorldEdit region=Alle Blöcke außer <search node> im aktuellen WorldEdit-Gebiet mit <replace node> ersetzen.
|
||||
Add a hollow cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.=
|
||||
@1 nodes added=@1 Blöcke hinzugefügt
|
||||
Add a cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.=
|
||||
Add hollow sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>=
|
||||
Add sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>=
|
||||
Add hollow dome centered at WorldEdit position 1 with radius <radius>, composed of <node>=
|
||||
Add dome centered at WorldEdit position 1 with radius <radius>, composed of <node>=
|
||||
Add hollow cylinder at WorldEdit position 1 along the given axis with length <length>, base radius <radius1> (and top radius [radius2]), composed of <node>=
|
||||
Add cylinder at WorldEdit position 1 along the given axis with length <length>, base radius <radius1> (and top radius [radius2]), composed of <node>=
|
||||
Add hollow pyramid centered at WorldEdit position 1 along the given axis with height <height>, composed of <node>=
|
||||
Add pyramid centered at WorldEdit position 1 along the given axis with height <height>, composed of <node>=
|
||||
Add spiral centered at WorldEdit position 1 with side length <length>, height <height>, space between walls <space>, composed of <node>=
|
||||
Copy the current WorldEdit region along the given axis by <amount> nodes=Das aktuelle WorldEdit-Gebiet entlang der gegebenen Achse um <amount> Blöcke kopieren
|
||||
@1 nodes copied=@1 Blöcke kopiert
|
||||
Move the current WorldEdit region along the given axis by <amount> nodes=Das aktuelle WorldEdit-Gebiet entlang der gegebenen Achse um <amount> Blöcke verschieben
|
||||
@1 nodes moved=@1 Blöcke verschoben
|
||||
Stack the current WorldEdit region along the given axis <count> times=Das aktuelle WorldEdit-Gebiet entlang der gegebenen Achse <count>-mal stapeln
|
||||
@1 nodes stacked=@1 Blöcke gestapelt
|
||||
Stack the current WorldEdit region <count> times by offset <x>, <y>, <z>=Das aktuelle WorldEdit-Gebiet <count>-mal um <x>, <y>, <z> versetzt stapeln
|
||||
invalid count: @1=Ungültige Anzahl: @1
|
||||
invalid increments: @1=Ungültige Schrittweite: @1
|
||||
Scale the current WorldEdit positions and region by a factor of <stretchx>, <stretchy>, <stretchz> along the X, Y, and Z axes, repectively, with position 1 as the origin=
|
||||
invalid scaling factors: @1=Ungültige Skalierungsfaktoren: @1
|
||||
@1 nodes stretched=@1 Blöcke gestreckt
|
||||
Transpose the current WorldEdit region along the given axes=
|
||||
invalid usage: axes must be different=Ungültige Verwendung: Achsen müssen verschieden sein
|
||||
@1 nodes transposed=
|
||||
Flip the current WorldEdit region along the given axis=
|
||||
@1 nodes flipped=
|
||||
Rotate the current WorldEdit region around the given axis by angle <angle> (90 degree increment)=
|
||||
invalid usage: angle must be multiple of 90=Ungültige Verwendung: Winkel muss ein Vielfaches von 90 sein
|
||||
@1 nodes rotated=@1 Blöcke gedreht
|
||||
Rotate oriented nodes in the current WorldEdit region around the Y axis by angle <angle> (90 degree increment)=
|
||||
@1 nodes oriented=
|
||||
Fix the lighting in the current WorldEdit region=Belichtung im aktuellen WorldEdit-Gebiet korrigieren
|
||||
@1 nodes updated=@1 Blöcke verändert
|
||||
Remove any fluid node within the current WorldEdit region=Alle flüssigen Blöcke im WorldEdit-Gebiet entfernen
|
||||
Remove any plant, tree or foliage-like nodes in the selected region=Alle Pflanzen, Baum oder Laub-ähnliche Blöcke im WorldEdit-Gebiet entfernen
|
||||
@1 nodes removed=@1 Blöcke entfernt
|
||||
Hide all nodes in the current WorldEdit region non-destructively=Alle Blöcke im WorldEdit-Gebiet zerstörungsfrei verstecken
|
||||
@1 nodes hidden=@1 Blöcke versteckt
|
||||
Suppress all <node> in the current WorldEdit region non-destructively=
|
||||
@1 nodes suppressed=
|
||||
Highlight <node> in the current WorldEdit region by hiding everything else non-destructively=Alle <node> Blöcke im WorldEdit-Gebiet hervorheben, indem alle anderen zerstörungsfrei versteckt werden
|
||||
@1 nodes highlighted=@1 Blöcke hervorgehoben
|
||||
Restores nodes hidden with WorldEdit in the current WorldEdit region=Versteckte Blöcke im WorldEdit-Gebiet wiederherstellen.
|
||||
@1 nodes restored=@1 Blöcke wiederhergestellt
|
||||
Warning: The schematic contains excessive free space and WILL be misaligned when allocated or loaded. To avoid this, shrink your area to cover exactly the nodes to be saved.=Warnung: Das Schematic hat überschüssigen freien Platz und WIRD nach dem Laden falsch ausgerichtet sein. Um dies zu vermeiden, verkleinern Sie das Gebiet sodass es die zu speichernden Blöcke exakt umfasst.
|
||||
Save the current WorldEdit region to "(world folder)/schems/<file>.we"=Das aktuelle WorldEdit-Gebiet in "(Weltordner)/schems/<file>.we" speichern
|
||||
Disallowed file name: @1=Nicht erlaubter Dateiname: @1
|
||||
Could not save file to "@1"=Konnte die Datei nicht unter "@1" speichern
|
||||
@1 nodes saved=@1 Blöcke gespeichert
|
||||
Set the region defined by nodes from "(world folder)/schems/<file>.we" as the current WorldEdit region=Das aktuelle WorldEdit-Gebiet anhand der Blöcke in "(Weltordner)/schems/<file>.we" setzen
|
||||
Schematic empty, nothing allocated=Schematic leer, nichts reserviert
|
||||
@1 nodes allocated=@1 Blöcke reserviert
|
||||
Load nodes from "(world folder)/schems/<file>[.we[m]]" with position 1 of the current WorldEdit region as the origin=Blöcke aus "(Weltordner)/schems/<file>[.we[m]]" mit Position 1 als Ausgangspunkt laden
|
||||
Loading failed!=Laden fehlgeschlagen!
|
||||
@1 nodes loaded=@1 Blöcke geladen
|
||||
Executes <code> as a Lua chunk in the global namespace=
|
||||
Executes <code> as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region=
|
||||
Save the current WorldEdit region using the Minetest Schematic format to "(world folder)/schems/<filename>.mts"=Das aktuelle WorldEdit-Gebiet als Minetest-Schematic in "(Weltordner)/schems/<filename>.mts" speichern
|
||||
Failed to create Minetest schematic=Konnte Minetest-Schematic nicht erstellen
|
||||
Saved Minetest schematic to @1=Minetest-Schematic in @1 gespeichert
|
||||
Load nodes from "(world folder)/schems/<file>.mts" with position 1 of the current WorldEdit region as the origin=Blöcke aus "(Weltordner)/schems/<file>.mts" mit Position 1 als Ausgangspunkt laden
|
||||
failed to place Minetest schematic=Konnte Minetest-Schematic nicht platzieren
|
||||
placed Minetest schematic @1 at @2=Minetest-Schematic @1 bei @2 platziert
|
||||
Begins node probability entry for Minetest schematics, gets the nodes that have probabilities set, or ends node probability entry=
|
||||
select Minetest schematic probability values by punching nodes=
|
||||
finished Minetest schematic probability selection=
|
||||
currently set node probabilities:=
|
||||
invalid node probability given, not saved=
|
||||
Clears all objects within the WorldEdit region=Löscht alle Objekte innerhalb des WorldEdit-Gebiets
|
||||
@1 objects cleared=@1 Objekte gelöscht
|
||||
WARNING: this operation could affect up to @1 nodes; type //y to continue or //n to cancel=WARNUNG: Dieser Vorgang könnte bis zu @1 Blöcke betreffen; //y zum Fortfahren oder //n zum Abbrechen
|
||||
Confirm a pending operation=Einen ausstehenden Vorgang bestätigen
|
||||
no operation pending=Kein Vorgang ausstehend
|
||||
Abort a pending operation=Einen ausstehenden Vorgang abbrechen
|
||||
WorldEdit Wand tool@nLeft-click to set 1st position, right-click to set 2nd=WorldEdit Zauberstab@nSetzen der 1. Position mit Linksklick, der 2. mit Rechtsklick
|
155
worldedit_commands/locale/worldedit_commands.ru.tr
Normal file
@ -0,0 +1,155 @@
|
||||
# textdomain: worldedit_commands
|
||||
|
||||
### init.lua ###
|
||||
Can use WorldEdit commands=Возможность редактировать мир с помощью команд WorldEdit
|
||||
|
||||
no region selected=не выделен регион
|
||||
no position 1 selected=не установлена позиция региона 1
|
||||
invalid usage=не верное использование команды
|
||||
Could not open file "@1"=Не удаётся открыть файл "@1"
|
||||
Invalid file format!=Не верный формат файла!
|
||||
Schematic was created with a newer version of WorldEdit.=Схема была создана с использованием более новой версии WorldEdit.
|
||||
|
||||
Get information about the WorldEdit mod=Вывести информацию о WorldEdit
|
||||
WorldEdit @1 is available on this server. Type //help to get a list of commands, or get more information at @2=WorldEdit @1 доступен на этом сервере. Наберите команду //help чтобы увидеть список команд, больше информации по ссылке @2
|
||||
Get help for WorldEdit commands=Вывести информацию об использовании команд WorldEdit
|
||||
You are not allowed to use any WorldEdit commands.=У вас нет привилегий, чтобы использовать команды WorldEdit.
|
||||
Available commands: @1@nUse '//help <cmd>' to get more information, or '//help all' to list everything.=Доступные команды: @1@nИспользуйте '//help <cmd>' для получения информации по команде или '//help all' для вывода подсказок по всем командам.
|
||||
Available commands:@n=Доступные команды:@n
|
||||
Command not available: =Команда не найдена:
|
||||
Enable or disable node inspection=Включить/отключить инспекцию блоков
|
||||
inspector: inspection enabled for @1, currently facing the @2 axis=inspector: инспекция включена для @1, текущий взор в направлении оси @2
|
||||
inspector: inspection disabled=inspector: инспекция отключена
|
||||
inspector: @1 at @2 (param1@=@3, param2@=@4, received light@=@5) punched facing the @6 axis=inspector: @1 в @2 (param1@=@3, param2@=@4, received light@=@5) ударен по поверхности @6
|
||||
Reset the region so that it is empty=Сбросить выделение области
|
||||
region reset=регион сброшен
|
||||
Show markers at the region positions=Отобразить маркеры выделенной области
|
||||
region marked=маркеры отображены
|
||||
Hide markers if currently shown=Скрыть маркеры выделенной области
|
||||
region unmarked=маркеры скрыты
|
||||
Set WorldEdit region position @1 to the player's location=Установить маркер @1 для WorldEdit-региона в месте нахождения игрока
|
||||
Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region=Выделить WorldEdit-регион или установить маркеры для WorldEdit-региона, либо отобразить уже выбранную область
|
||||
unknown subcommand: @1=неизвестная подкоманда: @1
|
||||
select positions by punching two nodes=выберите позиции, ударив по блокам
|
||||
select position @1 by punching a node=выберите позицию @1, ударив по блоку
|
||||
position @1: @2=позиция @1: @2
|
||||
position @1 not set=позиция @1 не установлена
|
||||
Set a WorldEdit region position to the position at (<x>, <y>, <z>)=Установить маркер для WorldEdit в позиции (<x>, <y>, <z>)
|
||||
position @1 set to @2=позиция @1 установлена в @2
|
||||
Display the volume of the current WorldEdit region=Вывести информацию об объёме текущей выделенной области WorldEdit (кол-во нод, размеры)
|
||||
current region has a volume of @1 nodes (@2*@3*@4)=текущий регион имеет объем @1 нод (@2*@3*@4)
|
||||
Remove all MapBlocks (16x16x16) containing the selected area from the map=Удалить MapBlocks (16x16x16), содержащие выбранную область
|
||||
Area deleted.=Область удалена.
|
||||
There was an error during deletion of the area.=Что-то пошло не так при удалении области.
|
||||
Set the current WorldEdit region to <node>=Заполнить выбранный WorldEdit-регион указанным типом блоков
|
||||
invalid node name: @1=неверное название блока: @1
|
||||
@1 nodes set=@1 блок(а/ов) установленно
|
||||
Set param2 of all nodes in the current WorldEdit region to <param2>=Проставить param2 для всех блоков в текущем WorldEdit-регионе
|
||||
Param2 is out of range (must be between 0 and 255 inclusive!)=Значение param2 должно быть от 0 до 255 (включительно!)
|
||||
@1 nodes altered=изменено @1 блок(а/ов)
|
||||
Fill the current WorldEdit region with a random mix of <node1>, ...=Заполнить выбранный WorldEdit-регион смесью указанных типов блоков
|
||||
invalid search node name: @1=неверное название блока-поиска: @1
|
||||
invalid replace node name: @1=неверное название блока-замены: @1
|
||||
Replace all instances of <search node> with <replace node> in the current WorldEdit region=Заменить все блоки <search node> на <replace node> в выбранной WorldEdit-области
|
||||
@1 nodes replaced=заменено @1 нод(а/ы)
|
||||
Replace all nodes other than <search node> with <replace node> in the current WorldEdit region=Заменить все блоки, кроме <search node>, на <replace node> в выбранной WorldEdit-области
|
||||
Add a hollow cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.=Установить полый куб с центром нижней грани в позиции 1 и указанными размерами, состоящий из блоков <node>.
|
||||
@1 nodes added=добавлен(о) @1 блок(а/ов)
|
||||
Add a cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.=Установить куб с центром нижней грани в позиции 1 и указанными размерами, состоящий из блоков <node>.
|
||||
Add hollow sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>=Установить полую сферу с центром в WorldEdit-позиции 1 радиусом <radius>, состоящую из блоков <node>
|
||||
Add sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>=Установить сферу с центром в WorldEdit-позиции 1 радиусом <radius>, состоящую из блоков <node>
|
||||
Add hollow dome centered at WorldEdit position 1 with radius <radius>, composed of <node>=Установить полый купол с центром в WorldEdit-позиции 1 радиусом <radius>, состоящий из блоков <node>
|
||||
Add dome centered at WorldEdit position 1 with radius <radius>, composed of <node>=Установить купол с центром в WorldEdit-позиции 1 радиусом <radius>, состоящий из блоков <node>
|
||||
Add hollow cylinder at WorldEdit position 1 along the given axis with length <length>, base radius <radius1> (and top radius [radius2]), composed of <node>=Установить полый цилиндр вдоль указанной оси, с центром в позиции 1, высотой/длинной <length>, с радиусом основания <radius> (и радиусом вершины [radius 2]), состоящий из блоков <node>
|
||||
Add cylinder at WorldEdit position 1 along the given axis with length <length>, base radius <radius1> (and top radius [radius2]), composed of <node>=Установить цилиндр вдоль указанной оси, с центром в позиции 1, высотой/длинной <length>, с радиусом основания <radius> (и радиусом вершины [radius 2]), состоящий из блоков <node>
|
||||
Add hollow pyramid centered at WorldEdit position 1 along the given axis with height <height>, composed of <node>=Установить полую пирамиду вдоль указанной оси, с центром в WorldEdit-позиции 1 высотой <height>, состоящую из блоков <node>
|
||||
Add pyramid centered at WorldEdit position 1 along the given axis with height <height>, composed of <node>=Установить пирамиду вдоль указанной оси, с центром в WorldEdit-позиции 1 высотой <height>, состоящую из блоков <node>
|
||||
Add spiral centered at WorldEdit position 1 with side length <length>, height <height>, space between walls <space>, composed of <node>=Установить спираль с центром в WorldEdit-позиции 1 шириной <length>, высотой <height> и с расстоянием между витками <space>, состоящую из блоков <node>
|
||||
Copy the current WorldEdit region along the given axis by <amount> nodes=Копировать текущий WorldEdit-регион со смещением вдоль указанной оси (x/y/z) на <amount> блоков
|
||||
@1 nodes copied=скопировано @1 нод(а/ы)
|
||||
Move the current WorldEdit region along the given axis by <amount> nodes=Переместить текущий WorldEdit-регион вдоль указанной оси (x/y/z) на <amount> блоков
|
||||
@1 nodes moved=перемещено @1 нод(а/ы)
|
||||
Stack the current WorldEdit region along the given axis <count> times=Размножить текущий WorldEdit-регион вдоль указанной оси <count> раз
|
||||
@1 nodes stacked=размножено @1 нод(а/ы)
|
||||
Stack the current WorldEdit region <count> times by offset <x>, <y>, <z>=Размножить текущий WorldEdit-регион <count> раз с шагом <x>, <y>, <z> по соответствующим осям
|
||||
invalid count: @1=неверное количество: @1
|
||||
invalid increments: @1=неверные приращения(шаг)
|
||||
Scale the current WorldEdit positions and region by a factor of <stretchx>, <stretchy>, <stretchz> along the X, Y, and Z axes, repectively, with position 1 as the origin=Масштабировать текущий WorldEdit-регион с коэффициентами <stretchx>, <stretchy>, <stretchz> вдоль осей X, Y и Z, используя WorldEdit-позицию 1 в качестве точки отсчёта
|
||||
invalid scaling factors: @1=неверные коэффициенты масштабирования: @1
|
||||
@1 nodes stretched=масштабировано @1 нод(а/ы)
|
||||
Transpose the current WorldEdit region along the given axes=Транспонировать текущий WorldEdit-регион по заданным осям.
|
||||
invalid usage: axes must be different=недопустимое использование: оси должны быть разными
|
||||
@1 nodes transposed=транспонировано @1 нод(а/ы)
|
||||
Flip the current WorldEdit region along the given axis=Перевернуть/Отразить текущий WorldEdit-регион вдоль указанной оси
|
||||
@1 nodes flipped=отражено @1 нод(а/ы)
|
||||
Rotate the current WorldEdit region around the given axis by angle <angle> (90 degree increment)=Повернуть текущий WorldEdit-регион вокруг оси <axis> на угол <angle> (шаг - 90 градусов)
|
||||
invalid usage: angle must be multiple of 90=недопустимое использование: угол должен быть кратен 90
|
||||
@1 nodes rotated=повёрнуто @1 нод(а/ы)
|
||||
Rotate oriented nodes in the current WorldEdit region around the Y axis by angle <angle> (90 degree increment)=Повернуть блоки в текущем WorldEdit-регионе вокруг оси Y на угол <angle> (шаг - 90 градусов)
|
||||
@1 nodes oriented=повёрнуто @1 нод(а/ы)
|
||||
Fix the lighting in the current WorldEdit region=Исправить освещение в текущем WorldEdit-регионе
|
||||
@1 nodes updated=обновлено @1 нод(а/ы)
|
||||
Remove any fluid node within the current WorldEdit region=Удалить любые жидкости в текущем WorldEdit-регионе
|
||||
Remove any plant, tree or foliage-like nodes in the selected region=Удалить любые растения, деревья или листье-подобные ноды в текущем WorldEdit-регионе
|
||||
@1 nodes removed=удалено @1 нод(а/ы)
|
||||
Hide all nodes in the current WorldEdit region non-destructively=Скрыть узлы текущего WorldEdit-региона, не удаляя их
|
||||
@1 nodes hidden=скрыто @1 нод(а/ы)
|
||||
Suppress all <node> in the current WorldEdit region non-destructively=Скрыть все блоки <node> в текущем WorldEdit-регионе, не удаляя их
|
||||
@1 nodes suppressed=скрыто @1 нод(а/ы)
|
||||
Highlight <node> in the current WorldEdit region by hiding everything else non-destructively=Скрыть все блоки, кроме <node>, в текущем WorldEdit-регионе, не удаляя их
|
||||
@1 nodes highlighted="подсвечено" @1 нод(а/ы)
|
||||
Restores nodes hidden with WorldEdit in the current WorldEdit region=Восстановить скрытые WorldEdit'ом узлы в текущем WorldEdit-регионе
|
||||
@1 nodes restored=восстановлено @1 нод(а/ы)
|
||||
Warning: The schematic contains excessive free space and WILL be misaligned when allocated or loaded. To avoid this, shrink your area to cover exactly the nodes to be saved.=Предупреждение: Схема содержит слишком много свободного места и будет смещена при размещении или загрузке. Чтобы избежать этого, уменьшите область так, чтобы она охватывала именно те узлы, которые необходимо сохранить.
|
||||
Save the current WorldEdit region to "(world folder)/schems/<file>.we"=Сохранить текущий WorldEdit-регион в файл "(world folder)/schems/<file>.we"
|
||||
Disallowed file name: @1=Недопустимое имя файла: @1
|
||||
Could not save file to "@1"=Не удалось сохранить файл в "@1"
|
||||
@1 nodes saved=сохранено @1 нод(а/ы)
|
||||
Set the region defined by nodes from "(world folder)/schems/<file>.we" as the current WorldEdit region=Выделить область, определённую узлами из "(world folder)/schems/<file>.we", как текущий WorldEdit-регион
|
||||
Schematic empty, nothing allocated=Схема пуста, ничего не выделено
|
||||
@1 nodes allocated=выделено @1 нод(а/ы)
|
||||
Load nodes from "(world folder)/schems/<file>[.we[m]]" with position 1 of the current WorldEdit region as the origin=Загрузить регион из "(world folder)/schems/<file>[.we[m]]" с WorldEdit-позицией 1 в качестве точки отсчёта
|
||||
Loading failed!=Не удалось загрузить!
|
||||
@1 nodes loaded=загружено @1 нод(а/ы)
|
||||
Executes <code> as a Lua chunk in the global namespace=Выполнить <code> как Lua-код в глобальном пространстве имён
|
||||
Executes <code> as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region=Выполнить <code> как Lua-код в глобальном пространстве имён, с доступом к переменным позиций для каждого блока в текущем WordEdit-регионе
|
||||
Save the current WorldEdit region using the Minetest Schematic format to "(world folder)/schems/<filename>.mts"=Сохранить текущий WorldEdit-регион с использованием сжатия в формат Minetest Schematic в файл "(world folder)/schems/<filename>.mts"
|
||||
Failed to create Minetest schematic=Не удалось создать Minetest-схему
|
||||
Saved Minetest schematic to @1=Minetest-схема сохранена в @1
|
||||
Load nodes from "(world folder)/schems/<file>.mts" with position 1 of the current WorldEdit region as the origin=Загрузить блоки из "(world folder)/schems/<file>.mts" с WorldEdit-позицией 1 в качестве точки отсчёта
|
||||
failed to place Minetest schematic=не удалось загрузить Minetest-схему
|
||||
placed Minetest schematic @1 at @2=Minetest-схема @1 загружена в @2
|
||||
Begins node probability entry for Minetest schematics, gets the nodes that have probabilities set, or ends node probability entry=Начать запись вероятностей для Minetest Schematic, ударяя по блокам, закончить запись вероятностей или вывести уже записанные вероятности
|
||||
select Minetest schematic probability values by punching nodes=выберите значения вероятностей для Minetest-схемы, ударя по нодам
|
||||
finished Minetest schematic probability selection=выбор вероятностей для Minetest-схемы завершен
|
||||
currently set node probabilities:=заданные вероятности нод на данный момент:
|
||||
invalid node probability given, not saved=недопустимая вероятность ноды, не сохранена
|
||||
Clears all objects within the WorldEdit region=Очистить все объекты в текущем WorldEdit-регионе
|
||||
@1 objects cleared=очищено @1 объектов
|
||||
|
||||
### safe.lua ###
|
||||
WARNING: this operation could affect up to @1 nodes; type //y to continue or //n to cancel=ПРЕДУПРЕЖДЕНИЕ: эта операция может затронуть до @1 нод; введите //y для продолжения или //n для отмены
|
||||
Confirm a pending operation=Подтвердить отложенную операцию
|
||||
no operation pending=нет ожидающей операции
|
||||
Abort a pending operation=Отклонить отложенную операцию
|
||||
|
||||
### cuboid.lua ###
|
||||
Outset the selected region.=Расширить выделение региона.
|
||||
Invalid direction: @1=Недопустимое направление: @1
|
||||
Invalid number of arguments=Недопустимое количество аргументов
|
||||
Region outset by @1 nodes=Регион расширен на @1 нод(у/ы)
|
||||
Inset the selected region.=Сузить выделение региона.
|
||||
Region inset by @1 nodes=Регион сужен на @1 нод(у/ы)
|
||||
Shifts the selection area without moving its contents=Сдвинуть выделение региона без перемещения его содержимого
|
||||
Invalid if looking straight up or down=Недопустимо, если смотреть прямо вверх или вниз
|
||||
Region shifted by @1 nodes=Регион сдвинут на @1 нод(у/ы)
|
||||
Expands the selection in the selected absolute or relative axis=Увеличить выделение региона по выбранной абсолютной или относительной оси
|
||||
Region expanded by @1 nodes=Регион увеличен на @1 нод(у/ы)
|
||||
Contracts the selection in the selected absolute or relative axis=Уменьшить выделение региона по выбранной абсолютной или относительной оси
|
||||
Region contracted by @1 nodes=Регион уменьшен на @1 нод(у/ы)
|
||||
Select a cube with side length <size> around position 1 and run <command> on region=Выделить куб с длиной стороны <size> вокруг позиции 1 и запустите <команду> в области
|
||||
invalid usage: //@1 cannot be used with cubeapply=недопустимое использование: //@1 не может быть применено в cubeapply
|
||||
Missing privileges: @1=Отсутствуют привилегии: @1
|
||||
|
||||
### wand.lua ###
|
||||
WorldEdit Wand tool@nLeft-click to set 1st position, right-click to set 2nd=Инструмент WorldEdit Wand@nЛевая кнопка мыши, чтобы установить 1-ю позицию, правая кнопка мыши, чтобы установить 2-ю
|
@ -2,57 +2,60 @@ worldedit.marker1 = {}
|
||||
worldedit.marker2 = {}
|
||||
worldedit.marker_region = {}
|
||||
|
||||
--marks worldedit region position 1
|
||||
worldedit.mark_pos1 = function(name)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
local init_sentinel = "new" .. tostring(math.random(99999))
|
||||
|
||||
--marks worldedit region position 1
|
||||
worldedit.mark_pos1 = function(name, region_too)
|
||||
local pos1 = worldedit.pos1[name]
|
||||
|
||||
if pos1 ~= nil then
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos1)
|
||||
end
|
||||
if worldedit.marker1[name] ~= nil then --marker already exists
|
||||
worldedit.marker1[name]:remove() --remove marker
|
||||
worldedit.marker1[name] = nil
|
||||
end
|
||||
if pos1 ~= nil then
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos1)
|
||||
|
||||
--add marker
|
||||
worldedit.marker1[name] = minetest.add_entity(pos1, "worldedit:pos1")
|
||||
worldedit.marker1[name] = minetest.add_entity(pos1, "worldedit:pos1", init_sentinel)
|
||||
if worldedit.marker1[name] ~= nil then
|
||||
worldedit.marker1[name]:get_luaentity().player_name = name
|
||||
end
|
||||
end
|
||||
worldedit.mark_region(name)
|
||||
if region_too == nil or region_too then
|
||||
worldedit.mark_region(name)
|
||||
end
|
||||
end
|
||||
|
||||
--marks worldedit region position 2
|
||||
worldedit.mark_pos2 = function(name)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
worldedit.mark_pos2 = function(name, region_too)
|
||||
local pos2 = worldedit.pos2[name]
|
||||
|
||||
if pos2 ~= nil then
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos2, pos2)
|
||||
end
|
||||
if worldedit.marker2[name] ~= nil then --marker already exists
|
||||
worldedit.marker2[name]:remove() --remove marker
|
||||
worldedit.marker2[name] = nil
|
||||
end
|
||||
if pos2 ~= nil then
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos2, pos2)
|
||||
|
||||
--add marker
|
||||
worldedit.marker2[name] = minetest.add_entity(pos2, "worldedit:pos2")
|
||||
worldedit.marker2[name] = minetest.add_entity(pos2, "worldedit:pos2", init_sentinel)
|
||||
if worldedit.marker2[name] ~= nil then
|
||||
worldedit.marker2[name]:get_luaentity().player_name = name
|
||||
end
|
||||
end
|
||||
worldedit.mark_region(name)
|
||||
if region_too == nil or region_too then
|
||||
worldedit.mark_region(name)
|
||||
end
|
||||
end
|
||||
|
||||
worldedit.mark_region = function(name)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
|
||||
if worldedit.marker_region[name] ~= nil then --marker already exists
|
||||
--wip: make the area stay loaded somehow
|
||||
for _, entity in ipairs(worldedit.marker_region[name]) do
|
||||
entity:remove()
|
||||
end
|
||||
@ -64,7 +67,7 @@ worldedit.mark_region = function(name)
|
||||
|
||||
local vec = vector.subtract(pos2, pos1)
|
||||
local maxside = math.max(vec.x, math.max(vec.y, vec.z))
|
||||
local limit = tonumber(minetest.setting_get("active_object_send_range_blocks")) * 16
|
||||
local limit = tonumber(minetest.settings:get("active_object_send_range_blocks")) * 16
|
||||
if maxside > limit * 1.5 then
|
||||
-- The client likely won't be able to see the plane markers as intended anyway,
|
||||
-- thus don't place them and also don't load the area into memory
|
||||
@ -82,7 +85,8 @@ worldedit.mark_region = function(name)
|
||||
|
||||
--XY plane markers
|
||||
for _, z in ipairs({pos1.z - 0.5, pos2.z + 0.5}) do
|
||||
local marker = minetest.add_entity({x=pos1.x + sizex - 0.5, y=pos1.y + sizey - 0.5, z=z}, "worldedit:region_cube")
|
||||
local entpos = {x=pos1.x + sizex - 0.5, y=pos1.y + sizey - 0.5, z=z}
|
||||
local marker = minetest.add_entity(entpos, "worldedit:region_cube", init_sentinel)
|
||||
if marker ~= nil then
|
||||
marker:set_properties({
|
||||
visual_size={x=sizex * 2, y=sizey * 2},
|
||||
@ -95,13 +99,14 @@ worldedit.mark_region = function(name)
|
||||
|
||||
--YZ plane markers
|
||||
for _, x in ipairs({pos1.x - 0.5, pos2.x + 0.5}) do
|
||||
local marker = minetest.add_entity({x=x, y=pos1.y + sizey - 0.5, z=pos1.z + sizez - 0.5}, "worldedit:region_cube")
|
||||
local entpos = {x=x, y=pos1.y + sizey - 0.5, z=pos1.z + sizez - 0.5}
|
||||
local marker = minetest.add_entity(entpos, "worldedit:region_cube", init_sentinel)
|
||||
if marker ~= nil then
|
||||
marker:set_properties({
|
||||
visual_size={x=sizez * 2, y=sizey * 2},
|
||||
collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez},
|
||||
})
|
||||
marker:setyaw(math.pi / 2)
|
||||
marker:set_yaw(math.pi / 2)
|
||||
marker:get_luaentity().player_name = name
|
||||
table.insert(markers, marker)
|
||||
end
|
||||
@ -111,6 +116,13 @@ worldedit.mark_region = function(name)
|
||||
end
|
||||
end
|
||||
|
||||
--convenience function that calls everything
|
||||
worldedit.marker_update = function(name)
|
||||
worldedit.mark_pos1(name, false)
|
||||
worldedit.mark_pos2(name, false)
|
||||
worldedit.mark_region(name)
|
||||
end
|
||||
|
||||
minetest.register_entity(":worldedit:pos1", {
|
||||
initial_properties = {
|
||||
visual = "cube",
|
||||
@ -120,9 +132,11 @@ minetest.register_entity(":worldedit:pos1", {
|
||||
"worldedit_pos1.png", "worldedit_pos1.png"},
|
||||
collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
|
||||
physical = false,
|
||||
static_save = false,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker1[self.player_name] == nil then
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if staticdata ~= init_sentinel then
|
||||
-- we were loaded from before static_save = false was added
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
@ -130,6 +144,9 @@ minetest.register_entity(":worldedit:pos1", {
|
||||
self.object:remove()
|
||||
worldedit.marker1[self.player_name] = nil
|
||||
end,
|
||||
on_blast = function(self, damage)
|
||||
return false, false, {} -- don't damage or knockback
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_entity(":worldedit:pos2", {
|
||||
@ -141,9 +158,11 @@ minetest.register_entity(":worldedit:pos2", {
|
||||
"worldedit_pos2.png", "worldedit_pos2.png"},
|
||||
collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
|
||||
physical = false,
|
||||
static_save = false,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker2[self.player_name] == nil then
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if staticdata ~= init_sentinel then
|
||||
-- we were loaded from before static_save = false was added
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
@ -151,20 +170,23 @@ minetest.register_entity(":worldedit:pos2", {
|
||||
self.object:remove()
|
||||
worldedit.marker2[self.player_name] = nil
|
||||
end,
|
||||
on_blast = function(self, damage)
|
||||
return false, false, {} -- don't damage or knockback
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_entity(":worldedit:region_cube", {
|
||||
initial_properties = {
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x=1.1, y=1.1},
|
||||
textures = {"worldedit_cube.png"},
|
||||
visual_size = {x=10, y=10},
|
||||
physical = false,
|
||||
static_save = false,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker_region[self.player_name] == nil then
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if staticdata ~= init_sentinel then
|
||||
-- we were loaded from before static_save = false was added
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, hitter)
|
||||
@ -177,5 +199,8 @@ minetest.register_entity(":worldedit:region_cube", {
|
||||
end
|
||||
worldedit.marker_region[self.player_name] = nil
|
||||
end,
|
||||
on_blast = function(self, damage)
|
||||
return false, false, {} -- don't damage or knockback
|
||||
end,
|
||||
})
|
||||
|
||||
|
3
worldedit_commands/mod.conf
Normal file
@ -0,0 +1,3 @@
|
||||
name = worldedit_commands
|
||||
description = WorldEdit chat commands
|
||||
depends = worldedit
|
@ -1,65 +1,50 @@
|
||||
local S = minetest.get_translator("worldedit_commands")
|
||||
|
||||
local safe_region_callback = {}
|
||||
local safe_region_param = {}
|
||||
|
||||
local function check_region(name, param)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] --obtain positions
|
||||
if pos1 == nil or pos2 == nil then
|
||||
worldedit.player_notify(name, "no region selected")
|
||||
return nil
|
||||
end
|
||||
return worldedit.volume(pos1, pos2)
|
||||
end
|
||||
|
||||
--`count` is the number of nodes that would possibly be modified
|
||||
--`callback` is a callback to run when the user confirms
|
||||
--`nodes_needed` is a function accepting `param`, `pos1`, and `pos2` to calculate the number of nodes needed
|
||||
local function safe_region(callback, nodes_needed)
|
||||
--default node volume calculation
|
||||
nodes_needed = nodes_needed or check_region
|
||||
|
||||
return function(name, param)
|
||||
--check if the operation applies to a safe number of nodes
|
||||
local count = nodes_needed(name, param)
|
||||
if count == nil then return end --invalid command
|
||||
if count < 10000 then
|
||||
return callback(name, param)
|
||||
end
|
||||
|
||||
--save callback to call later
|
||||
safe_region_callback[name], safe_region_param[name] = callback, param
|
||||
worldedit.player_notify(name, "WARNING: this operation could affect up to " .. count .. " nodes; type //y to continue or //n to cancel")
|
||||
local function safe_region(name, count, callback)
|
||||
if count < 20000 then
|
||||
return callback()
|
||||
end
|
||||
|
||||
--save callback to call later
|
||||
safe_region_callback[name] = callback
|
||||
worldedit.player_notify(name, S("WARNING: this operation could affect up to @1 nodes; type //y to continue or //n to cancel", count))
|
||||
end
|
||||
|
||||
local function reset_pending(name)
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil
|
||||
safe_region_callback[name] = nil
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("/y", {
|
||||
params = "",
|
||||
description = "Confirm a pending operation",
|
||||
description = S("Confirm a pending operation"),
|
||||
func = function(name)
|
||||
local callback, param = safe_region_callback[name], safe_region_param[name]
|
||||
local callback = safe_region_callback[name]
|
||||
if not callback then
|
||||
worldedit.player_notify(name, "no operation pending")
|
||||
worldedit.player_notify(name, S("no operation pending"))
|
||||
return
|
||||
end
|
||||
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil --reset pending operation
|
||||
callback(name, param)
|
||||
reset_pending(name)
|
||||
callback(name)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("/n", {
|
||||
params = "",
|
||||
description = "Confirm a pending operation",
|
||||
description = S("Abort a pending operation"),
|
||||
func = function(name)
|
||||
if not safe_region_callback[name] then
|
||||
worldedit.player_notify(name, "no operation pending")
|
||||
worldedit.player_notify(name, S("no operation pending"))
|
||||
return
|
||||
end
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil
|
||||
|
||||
reset_pending(name)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
return safe_region, check_region, reset_pending
|
||||
return safe_region, reset_pending
|
||||
|
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 79 B |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 157 B After Width: | Height: | Size: 112 B |
BIN
worldedit_commands/textures/worldedit_wand.png
Normal file
After Width: | Height: | Size: 303 B |
@ -1,22 +1,65 @@
|
||||
local S = minetest.get_translator("worldedit_commands")
|
||||
|
||||
local function above_or_under(placer, pointed_thing)
|
||||
if placer:get_player_control().sneak then
|
||||
return pointed_thing.above
|
||||
else
|
||||
return pointed_thing.under
|
||||
end
|
||||
end
|
||||
|
||||
local punched_air_time = {}
|
||||
|
||||
minetest.register_tool(":worldedit:wand", {
|
||||
description = "WorldEdit Wand tool, Left-click to set 1st position, right-click to set 2nd",
|
||||
description = S("WorldEdit Wand tool\nLeft-click to set 1st position, right-click to set 2nd"),
|
||||
inventory_image = "worldedit_wand.png",
|
||||
stack_max = 1, -- there is no need to have more than one
|
||||
liquids_pointable = true, -- ground with only water on can be selected as well
|
||||
|
||||
on_use = function(itemstack, placer, pointed_thing)
|
||||
if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
|
||||
local name = placer:get_player_name()
|
||||
worldedit.pos1[name] = pointed_thing.under
|
||||
if placer == nil or pointed_thing == nil then return end
|
||||
local name = placer:get_player_name()
|
||||
if pointed_thing.type == "node" then
|
||||
-- set and mark pos1
|
||||
worldedit.pos1[name] = above_or_under(placer, pointed_thing)
|
||||
worldedit.mark_pos1(name)
|
||||
elseif pointed_thing.type == "nothing" then
|
||||
local now = minetest.get_us_time()
|
||||
if now - (punched_air_time[name] or 0) < 1000 * 1000 then
|
||||
-- reset markers
|
||||
worldedit.registered_commands["reset"].func(name)
|
||||
end
|
||||
punched_air_time[name] = now
|
||||
elseif pointed_thing.type == "object" then
|
||||
local entity = pointed_thing.ref:get_luaentity()
|
||||
if entity and entity.name == "worldedit:pos2" then
|
||||
-- set pos1 = pos2
|
||||
worldedit.pos1[name] = worldedit.pos2[name]
|
||||
worldedit.mark_pos1(name)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if placer == nil or (pointed_thing or {}).type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
local name = placer:get_player_name()
|
||||
-- set and mark pos2
|
||||
worldedit.pos2[name] = above_or_under(placer, pointed_thing)
|
||||
worldedit.mark_pos2(name)
|
||||
return itemstack -- nothing consumed, nothing changed
|
||||
end,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing) -- Left Click
|
||||
if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
|
||||
local name = placer:get_player_name()
|
||||
worldedit.pos2[name] = pointed_thing.under
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
if user == nil or (pointed_thing or {}).type ~= "object" then
|
||||
return itemstack
|
||||
end
|
||||
local name = user:get_player_name()
|
||||
local entity = pointed_thing.ref:get_luaentity()
|
||||
if entity and entity.name == "worldedit:pos1" then
|
||||
-- set pos2 = pos1
|
||||
worldedit.pos2[name] = worldedit.pos1[name]
|
||||
worldedit.mark_pos2(name)
|
||||
end
|
||||
return itemstack -- nothing consumed, nothing changed
|
||||
|
@ -1,6 +0,0 @@
|
||||
worldedit
|
||||
worldedit_commands
|
||||
unified_inventory?
|
||||
inventory_plus?
|
||||
sfinv?
|
||||
creative?
|
@ -11,6 +11,7 @@ local gui_count2 = {} --mapping of player names to a quantity (arbitrary strings
|
||||
local gui_count3 = {} --mapping of player names to a quantity (arbitrary strings may also appear as values)
|
||||
local gui_angle = {} --mapping of player names to an angle (one of 90, 180, 270, representing the angle in degrees clockwise)
|
||||
local gui_filename = {} --mapping of player names to file names
|
||||
local gui_param2 = {} --mapping of player names to param2 values
|
||||
|
||||
--set default values
|
||||
setmetatable(gui_nodename1, {__index = function() return "Cobblestone" end})
|
||||
@ -25,6 +26,7 @@ setmetatable(gui_count2, {__index = function() return "6" end})
|
||||
setmetatable(gui_count3, {__index = function() return "4" end})
|
||||
setmetatable(gui_angle, {__index = function() return 90 end})
|
||||
setmetatable(gui_filename, {__index = function() return "building" end})
|
||||
setmetatable(gui_param2, {__index = function() return "0" end})
|
||||
|
||||
local axis_indices = {["X axis"]=1, ["Y axis"]=2, ["Z axis"]=3, ["Look direction"]=4}
|
||||
local axis_values = {"x", "y", "z", "?"}
|
||||
@ -52,13 +54,18 @@ end
|
||||
|
||||
-- display node (or unknown_node image otherwise) at specified pos in formspec
|
||||
local formspec_node = function(pos, nodename)
|
||||
return nodename and string.format("item_image[%s;1,1;%s]", pos, nodename)
|
||||
or string.format("image[%s;1,1;worldedit_gui_unknown.png]", pos)
|
||||
local ndef = nodename and minetest.registered_nodes[nodename]
|
||||
if nodename and ndef then
|
||||
return string.format("item_image[%s;1,1;%s]", pos, nodename) ..
|
||||
string.format("tooltip[%s;1,1;%s]", pos, minetest.formspec_escape(ndef.description))
|
||||
else
|
||||
return string.format("image[%s;1,1;worldedit_gui_unknown.png]", pos)
|
||||
end
|
||||
end
|
||||
|
||||
-- two further priv helpers
|
||||
local function we_privs(command)
|
||||
return minetest.chatcommands["/" .. command].privs
|
||||
return worldedit.registered_commands[command].privs
|
||||
end
|
||||
|
||||
local function combine_we_privs(list)
|
||||
@ -69,11 +76,79 @@ local function combine_we_privs(list)
|
||||
return combine_privs(unpack(args))
|
||||
end
|
||||
|
||||
-- functions that handle value changing & page reshowing (without submitting)
|
||||
local function copy_changes(name, fields, def)
|
||||
for field, into in pairs(def) do
|
||||
if into ~= true and fields[field] then
|
||||
local value = tostring(fields[field])
|
||||
if into == gui_axis1 or into == gui_axis2 then
|
||||
into[name] = axis_indices[value]
|
||||
elseif into == gui_angle then
|
||||
into[name] = angle_indices[value]
|
||||
else
|
||||
into[name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function handle_changes(name, identifier, fields, def)
|
||||
local any = false
|
||||
for field, into in pairs(def) do
|
||||
if fields.key_enter_field == field then
|
||||
any = true
|
||||
end
|
||||
-- first condition: buttons (value not saved)
|
||||
-- others: dropdowns which will be sent when their value changes
|
||||
if into == true or into == gui_axis1 or into == gui_axis2 or into == gui_angle then
|
||||
if fields[field] then
|
||||
any = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not any then
|
||||
return false
|
||||
end
|
||||
|
||||
any = false
|
||||
for field, into in pairs(def) do
|
||||
if into ~= true and fields[field] then
|
||||
local value = tostring(fields[field])
|
||||
if into == gui_axis1 or into == gui_axis2 then
|
||||
into[name] = axis_indices[value]
|
||||
elseif into == gui_angle then
|
||||
into[name] = angle_indices[value]
|
||||
else
|
||||
into[name] = value
|
||||
end
|
||||
|
||||
if into == gui_nodename1 or into == gui_nodename2 then
|
||||
any = true
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Only nodename fields change based on the value, so only re-show the page if necessary
|
||||
if any then
|
||||
worldedit.show_page(name, identifier)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- This has the same behaviour as the player invoking the chat command
|
||||
local function execute_worldedit_command(command_name, player_name, params)
|
||||
local chatcmd = minetest.registered_chatcommands["/" .. command_name]
|
||||
assert(chatcmd, "unknown command: " .. command_name)
|
||||
local _, msg = chatcmd.func(player_name, params)
|
||||
if msg then
|
||||
worldedit.player_notify(player_name, msg)
|
||||
end
|
||||
end
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_about", {
|
||||
name = "About",
|
||||
privs = {interact=true},
|
||||
on_select = function(name)
|
||||
minetest.chatcommands["/about"].func(name, "")
|
||||
execute_worldedit_command("about", name, "")
|
||||
end,
|
||||
})
|
||||
|
||||
@ -81,7 +156,8 @@ worldedit.register_gui_function("worldedit_gui_inspect", {
|
||||
name = "Toggle Inspect",
|
||||
privs = we_privs("inspect"),
|
||||
on_select = function(name)
|
||||
minetest.chatcommands["/inspect"].func(name, worldedit.inspect[name] and "disable" or "enable")
|
||||
execute_worldedit_command("inspect", name,
|
||||
worldedit.inspect[name] and "disable" or "enable")
|
||||
end,
|
||||
})
|
||||
|
||||
@ -115,47 +191,47 @@ worldedit.register_gui_function("worldedit_gui_region", {
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_region", function(name, fields)
|
||||
if fields.worldedit_gui_p_get then
|
||||
minetest.chatcommands["/p"].func(name, "get")
|
||||
execute_worldedit_command("p", name, "get")
|
||||
return true
|
||||
elseif fields.worldedit_gui_p_set1 then
|
||||
minetest.chatcommands["/p"].func(name, "set1")
|
||||
execute_worldedit_command("p", name, "set1")
|
||||
return true
|
||||
elseif fields.worldedit_gui_p_set2 then
|
||||
minetest.chatcommands["/p"].func(name, "set2")
|
||||
execute_worldedit_command("p", name, "set2")
|
||||
return true
|
||||
elseif fields.worldedit_gui_pos1 then
|
||||
minetest.chatcommands["/pos1"].func(name, "")
|
||||
execute_worldedit_command("pos1", name, "")
|
||||
worldedit.show_page(name, "worldedit_gui_region")
|
||||
return true
|
||||
elseif fields.worldedit_gui_pos2 then
|
||||
minetest.chatcommands["/pos2"].func(name, "")
|
||||
execute_worldedit_command("pos2", name, "")
|
||||
worldedit.show_page(name, "worldedit_gui_region")
|
||||
return true
|
||||
elseif fields.worldedit_gui_reset then
|
||||
minetest.chatcommands["/reset"].func(name, "")
|
||||
execute_worldedit_command("reset", name, "")
|
||||
worldedit.show_page(name, "worldedit_gui_region")
|
||||
return true
|
||||
elseif fields.worldedit_gui_mark then
|
||||
minetest.chatcommands["/mark"].func(name, "")
|
||||
execute_worldedit_command("mark", name, "")
|
||||
worldedit.show_page(name, "worldedit_gui_region")
|
||||
return true
|
||||
elseif fields.worldedit_gui_unmark then
|
||||
minetest.chatcommands["/unmark"].func(name, "")
|
||||
execute_worldedit_command("unmark", name, "")
|
||||
worldedit.show_page(name, "worldedit_gui_region")
|
||||
return true
|
||||
elseif fields.worldedit_gui_volume then
|
||||
minetest.chatcommands["/volume"].func(name, "")
|
||||
execute_worldedit_command("volume", name, "")
|
||||
worldedit.show_page(name, "worldedit_gui_region")
|
||||
return true
|
||||
elseif fields.worldedit_gui_fixedpos_pos1_submit then
|
||||
minetest.chatcommands["/fixedpos"].func(name, string.format("set1 %s %s %s",
|
||||
execute_worldedit_command("fixedpos", name, ("set1 %s %s %s"):format(
|
||||
tostring(fields.worldedit_gui_fixedpos_pos1x),
|
||||
tostring(fields.worldedit_gui_fixedpos_pos1y),
|
||||
tostring(fields.worldedit_gui_fixedpos_pos1z)))
|
||||
worldedit.show_page(name, "worldedit_gui_region")
|
||||
return true
|
||||
elseif fields.worldedit_gui_fixedpos_pos2_submit then
|
||||
minetest.chatcommands["/fixedpos"].func(name, string.format("set2 %s %s %s",
|
||||
execute_worldedit_command("fixedpos", name, ("set2 %s %s %s"):format(
|
||||
tostring(fields.worldedit_gui_fixedpos_pos2x),
|
||||
tostring(fields.worldedit_gui_fixedpos_pos2y),
|
||||
tostring(fields.worldedit_gui_fixedpos_pos2z)))
|
||||
@ -173,6 +249,7 @@ worldedit.register_gui_function("worldedit_gui_set", {
|
||||
local nodename = worldedit.normalize_nodename(node)
|
||||
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_set") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_set_node;Name;%s]", minetest.formspec_escape(node)) ..
|
||||
"field_close_on_enter[worldedit_gui_set_node;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_set_search;Search]" ..
|
||||
formspec_node("5.5,1.1", nodename) ..
|
||||
"button_exit[0,2.5;3,0.8;worldedit_gui_set_submit;Set Nodes]"
|
||||
@ -180,18 +257,22 @@ worldedit.register_gui_function("worldedit_gui_set", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_set", function(name, fields)
|
||||
if fields.worldedit_gui_set_search or fields.worldedit_gui_set_submit then
|
||||
gui_nodename1[name] = tostring(fields.worldedit_gui_set_node)
|
||||
local cg = {
|
||||
worldedit_gui_set_search = true,
|
||||
worldedit_gui_set_node = gui_nodename1,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_set", fields, cg)
|
||||
if fields.worldedit_gui_set_submit then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_set")
|
||||
if fields.worldedit_gui_set_submit then
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
minetest.chatcommands["/set"].func(name, n)
|
||||
end
|
||||
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
execute_worldedit_command("set", name, n)
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_replace", {
|
||||
@ -202,9 +283,11 @@ worldedit.register_gui_function("worldedit_gui_replace", {
|
||||
local search_nodename, replace_nodename = worldedit.normalize_nodename(search), worldedit.normalize_nodename(replace)
|
||||
return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_replace") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_replace_search;Name;%s]", minetest.formspec_escape(search)) ..
|
||||
"field_close_on_enter[worldedit_gui_replace_search;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_replace_search_search;Search]" ..
|
||||
formspec_node("5.5,1.1", search_nodename) ..
|
||||
string.format("field[0.5,2.5;4,0.8;worldedit_gui_replace_replace;Name;%s]", minetest.formspec_escape(replace)) ..
|
||||
"field_close_on_enter[worldedit_gui_replace_replace;false]" ..
|
||||
"button[4,2.18;1.5,0.8;worldedit_gui_replace_replace_search;Search]" ..
|
||||
formspec_node("5.5,2.1", replace_nodename) ..
|
||||
"button_exit[0,3.5;3,0.8;worldedit_gui_replace_submit;Replace Nodes]" ..
|
||||
@ -213,28 +296,29 @@ worldedit.register_gui_function("worldedit_gui_replace", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_replace", function(name, fields)
|
||||
if fields.worldedit_gui_replace_search_search or fields.worldedit_gui_replace_replace_search
|
||||
or fields.worldedit_gui_replace_submit or fields.worldedit_gui_replace_submit_inverse then
|
||||
gui_nodename1[name] = tostring(fields.worldedit_gui_replace_search)
|
||||
gui_nodename2[name] = tostring(fields.worldedit_gui_replace_replace)
|
||||
local cg = {
|
||||
worldedit_gui_replace_search_search = true,
|
||||
worldedit_gui_replace_replace_search = true,
|
||||
worldedit_gui_replace_search = gui_nodename1,
|
||||
worldedit_gui_replace_replace = gui_nodename2,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_replace", fields, cg)
|
||||
if fields.worldedit_gui_replace_submit or fields.worldedit_gui_replace_submit_inverse then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_replace")
|
||||
|
||||
local submit = nil
|
||||
if fields.worldedit_gui_replace_submit then
|
||||
submit = "replace"
|
||||
elseif fields.worldedit_gui_replace_submit_inverse then
|
||||
local submit = "replace"
|
||||
if fields.worldedit_gui_replace_submit_inverse then
|
||||
submit = "replaceinverse"
|
||||
end
|
||||
if submit then
|
||||
local n1 = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
local n2 = worldedit.normalize_nodename(gui_nodename2[name])
|
||||
if n1 and n2 then
|
||||
minetest.chatcommands["/"..submit].func(name, string.format("%s %s", n1, n2))
|
||||
end
|
||||
local n1 = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
local n2 = worldedit.normalize_nodename(gui_nodename2[name])
|
||||
if n1 and n2 then
|
||||
execute_worldedit_command(submit, name, n1 .. " " .. n2)
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_sphere_dome", {
|
||||
@ -245,9 +329,11 @@ worldedit.register_gui_function("worldedit_gui_sphere_dome", {
|
||||
local nodename = worldedit.normalize_nodename(node)
|
||||
return "size[6.5,5]" .. worldedit.get_formspec_header("worldedit_gui_sphere_dome") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_sphere_dome_node;Name;%s]", minetest.formspec_escape(node)) ..
|
||||
"field_close_on_enter[worldedit_gui_sphere_dome_node;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_sphere_dome_search;Search]" ..
|
||||
formspec_node("5.5,1.1", nodename) ..
|
||||
string.format("field[0.5,2.5;4,0.8;worldedit_gui_sphere_dome_radius;Radius;%s]", minetest.formspec_escape(radius)) ..
|
||||
"field_close_on_enter[worldedit_gui_sphere_dome_radius;false]" ..
|
||||
"button_exit[0,3.5;3,0.8;worldedit_gui_sphere_dome_submit_hollow;Hollow Sphere]" ..
|
||||
"button_exit[3.5,3.5;3,0.8;worldedit_gui_sphere_dome_submit_solid;Solid Sphere]" ..
|
||||
"button_exit[0,4.5;3,0.8;worldedit_gui_sphere_dome_submit_hollow_dome;Hollow Dome]" ..
|
||||
@ -256,32 +342,33 @@ worldedit.register_gui_function("worldedit_gui_sphere_dome", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_sphere_dome", function(name, fields)
|
||||
if fields.worldedit_gui_sphere_dome_search
|
||||
or fields.worldedit_gui_sphere_dome_submit_hollow or fields.worldedit_gui_sphere_dome_submit_solid
|
||||
local cg = {
|
||||
worldedit_gui_sphere_dome_search = true,
|
||||
worldedit_gui_sphere_dome_node = gui_nodename1,
|
||||
worldedit_gui_sphere_dome_radius = gui_distance2,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_sphere_dome", fields, cg)
|
||||
if fields.worldedit_gui_sphere_dome_submit_hollow or fields.worldedit_gui_sphere_dome_submit_solid
|
||||
or fields.worldedit_gui_sphere_dome_submit_hollow_dome or fields.worldedit_gui_sphere_dome_submit_solid_dome then
|
||||
gui_nodename1[name] = tostring(fields.worldedit_gui_sphere_dome_node)
|
||||
gui_distance2[name] = tostring(fields.worldedit_gui_sphere_dome_radius)
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_sphere_dome")
|
||||
|
||||
local submit = nil
|
||||
if fields.worldedit_gui_sphere_dome_submit_hollow then
|
||||
submit = "hollowsphere"
|
||||
elseif fields.worldedit_gui_sphere_dome_submit_solid then
|
||||
local submit = "hollowsphere"
|
||||
if fields.worldedit_gui_sphere_dome_submit_solid then
|
||||
submit = "sphere"
|
||||
elseif fields.worldedit_gui_sphere_dome_submit_hollow_dome then
|
||||
submit = "hollowdome"
|
||||
elseif fields.worldedit_gui_sphere_dome_submit_solid_dome then
|
||||
submit = "dome"
|
||||
end
|
||||
if submit then
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
minetest.chatcommands["/"..submit].func(name, string.format("%s %s", gui_distance2[name], n))
|
||||
end
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
execute_worldedit_command(submit, name,
|
||||
gui_distance2[name] .. " " .. n)
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_cylinder", {
|
||||
@ -293,12 +380,16 @@ worldedit.register_gui_function("worldedit_gui_cylinder", {
|
||||
local nodename = worldedit.normalize_nodename(node)
|
||||
return "size[6.5,6]" .. worldedit.get_formspec_header("worldedit_gui_cylinder") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_cylinder_node;Name;%s]", minetest.formspec_escape(node)) ..
|
||||
"field_close_on_enter[worldedit_gui_cylinder_node;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_cylinder_search;Search]" ..
|
||||
formspec_node("5.5,1.1", nodename) ..
|
||||
string.format("field[0.5,2.5;4,0.8;worldedit_gui_cylinder_length;Length;%s]", minetest.formspec_escape(length)) ..
|
||||
string.format("dropdown[4,2.18;2.5;worldedit_gui_cylinder_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
|
||||
string.format("field[0.5,3.5;2,0.8;worldedit_gui_cylinder_radius1;Base Radius;%s]", minetest.formspec_escape(radius1)) ..
|
||||
string.format("field[2.5,3.5;2,0.8;worldedit_gui_cylinder_radius2;Top Radius;%s]", minetest.formspec_escape(radius2)) ..
|
||||
"field_close_on_enter[worldedit_gui_cylinder_length;false]" ..
|
||||
"field_close_on_enter[worldedit_gui_cylinder_radius1;false]" ..
|
||||
"field_close_on_enter[worldedit_gui_cylinder_radius2;false]" ..
|
||||
"label[0.25,4;Equal base and top radius creates a cylinder,\n"..
|
||||
"zero top radius creates a cone.\nConsult documentation for more information.]"..
|
||||
"button_exit[0,5.5;3,0.8;worldedit_gui_cylinder_submit_hollow;Hollow Cylinder]" ..
|
||||
@ -307,36 +398,31 @@ worldedit.register_gui_function("worldedit_gui_cylinder", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_cylinder", function(name, fields)
|
||||
if fields.worldedit_gui_cylinder_search
|
||||
or fields.worldedit_gui_cylinder_submit_hollow or fields.worldedit_gui_cylinder_submit_solid then
|
||||
gui_nodename1[name] = tostring(fields.worldedit_gui_cylinder_node)
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_cylinder_axis]
|
||||
gui_distance1[name] = tostring(fields.worldedit_gui_cylinder_length)
|
||||
gui_distance2[name] = tostring(fields.worldedit_gui_cylinder_radius1)
|
||||
gui_distance3[name] = tostring(fields.worldedit_gui_cylinder_radius2)
|
||||
local cg = {
|
||||
worldedit_gui_cylinder_search = true,
|
||||
worldedit_gui_cylinder_node = gui_nodename1,
|
||||
worldedit_gui_cylinder_axis = gui_axis1,
|
||||
worldedit_gui_cylinder_length = gui_distance1,
|
||||
worldedit_gui_cylinder_radius1 = gui_distance2,
|
||||
worldedit_gui_cylinder_radius2 = gui_distance3,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_cylinder", fields, cg)
|
||||
if fields.worldedit_gui_cylinder_submit_hollow or fields.worldedit_gui_cylinder_submit_solid then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_cylinder")
|
||||
|
||||
local submit = nil
|
||||
if fields.worldedit_gui_cylinder_submit_hollow then
|
||||
submit = "hollowcylinder"
|
||||
elseif fields.worldedit_gui_cylinder_submit_solid then
|
||||
local submit = "hollowcylinder"
|
||||
if fields.worldedit_gui_cylinder_submit_solid then
|
||||
submit = "cylinder"
|
||||
end
|
||||
if submit then
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
local args = string.format("%s %s %s %s %s", axis_values[gui_axis1[name]], gui_distance1[name], gui_distance2[name], gui_distance3[name], n)
|
||||
minetest.chatcommands["/"..submit].func(name, args)
|
||||
end
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
local args = string.format("%s %s %s %s %s", axis_values[gui_axis1[name]], gui_distance1[name], gui_distance2[name], gui_distance3[name], n)
|
||||
execute_worldedit_command(submit, name, args)
|
||||
end
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_cylinder_axis then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_cylinder_axis]
|
||||
worldedit.show_page(name, "worldedit_gui_cylinder")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_pyramid", {
|
||||
@ -347,42 +433,42 @@ worldedit.register_gui_function("worldedit_gui_pyramid", {
|
||||
local nodename = worldedit.normalize_nodename(node)
|
||||
return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_pyramid") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_pyramid_node;Name;%s]", minetest.formspec_escape(node)) ..
|
||||
"field_close_on_enter[worldedit_gui_pyramid_node;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_pyramid_search;Search]" ..
|
||||
formspec_node("5.5,1.1", nodename) ..
|
||||
string.format("field[0.5,2.5;4,0.8;worldedit_gui_pyramid_length;Length;%s]", minetest.formspec_escape(length)) ..
|
||||
string.format("dropdown[4,2.18;2.5;worldedit_gui_pyramid_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
|
||||
"field_close_on_enter[worldedit_gui_pyramid_length;false]" ..
|
||||
"button_exit[0,3.5;3,0.8;worldedit_gui_pyramid_submit_hollow;Hollow Pyramid]" ..
|
||||
"button_exit[3.5,3.5;3,0.8;worldedit_gui_pyramid_submit_solid;Solid Pyramid]"
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_pyramid", function(name, fields)
|
||||
if fields.worldedit_gui_pyramid_search or fields.worldedit_gui_pyramid_submit_solid or fields.worldedit_gui_pyramid_submit_hollow or fields.worldedit_gui_pyramid_axis then
|
||||
gui_nodename1[name] = tostring(fields.worldedit_gui_pyramid_node)
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_pyramid_axis]
|
||||
gui_distance1[name] = tostring(fields.worldedit_gui_pyramid_length)
|
||||
local cg = {
|
||||
worldedit_gui_pyramid_search = true,
|
||||
worldedit_gui_pyramid_node = gui_nodename1,
|
||||
worldedit_gui_pyramid_axis = gui_axis1,
|
||||
worldedit_gui_pyramid_length = gui_distance1,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_pyramid", fields, cg)
|
||||
if fields.worldedit_gui_pyramid_submit_solid or fields.worldedit_gui_pyramid_submit_hollow then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_pyramid")
|
||||
|
||||
local submit = nil
|
||||
if fields.worldedit_gui_pyramid_submit_solid then
|
||||
submit = "pyramid"
|
||||
elseif fields.worldedit_gui_pyramid_submit_hollow then
|
||||
local submit = "pyramid"
|
||||
if fields.worldedit_gui_pyramid_submit_hollow then
|
||||
submit = "hollowpyramid"
|
||||
end
|
||||
if submit then
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
minetest.chatcommands["/"..submit].func(name, string.format("%s %s %s", axis_values[gui_axis1[name]], gui_distance1[name], n))
|
||||
end
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
execute_worldedit_command(submit, name,
|
||||
string.format("%s %s %s", axis_values[gui_axis1[name]],
|
||||
gui_distance1[name], n))
|
||||
end
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_pyramid_axis then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_pyramid_axis]
|
||||
worldedit.show_page(name, "worldedit_gui_pyramid")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_spiral", {
|
||||
@ -393,31 +479,41 @@ worldedit.register_gui_function("worldedit_gui_spiral", {
|
||||
local nodename = worldedit.normalize_nodename(node)
|
||||
return "size[6.5,6]" .. worldedit.get_formspec_header("worldedit_gui_spiral") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_spiral_node;Name;%s]", minetest.formspec_escape(node)) ..
|
||||
"field_close_on_enter[worldedit_gui_spiral_node;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_spiral_search;Search]" ..
|
||||
formspec_node("5.5,1.1", nodename) ..
|
||||
string.format("field[0.5,2.5;4,0.8;worldedit_gui_spiral_length;Side Length;%s]", minetest.formspec_escape(length)) ..
|
||||
string.format("field[0.5,3.5;4,0.8;worldedit_gui_spiral_height;Height;%s]", minetest.formspec_escape(height)) ..
|
||||
string.format("field[0.5,4.5;4,0.8;worldedit_gui_spiral_space;Wall Spacing;%s]", minetest.formspec_escape(space)) ..
|
||||
"field_close_on_enter[worldedit_gui_spiral_length;false]" ..
|
||||
"field_close_on_enter[worldedit_gui_spiral_height;false]" ..
|
||||
"field_close_on_enter[worldedit_gui_spiral_space;false]" ..
|
||||
"button_exit[0,5.5;3,0.8;worldedit_gui_spiral_submit;Spiral]"
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_spiral", function(name, fields)
|
||||
if fields.worldedit_gui_spiral_search or fields.worldedit_gui_spiral_submit then
|
||||
gui_nodename1[name] = fields.worldedit_gui_spiral_node
|
||||
gui_distance1[name] = tostring(fields.worldedit_gui_spiral_length)
|
||||
gui_distance2[name] = tostring(fields.worldedit_gui_spiral_height)
|
||||
gui_distance3[name] = tostring(fields.worldedit_gui_spiral_space)
|
||||
local cg = {
|
||||
worldedit_gui_spiral_search = true,
|
||||
worldedit_gui_spiral_node = gui_nodename1,
|
||||
worldedit_gui_spiral_length = gui_distance1,
|
||||
worldedit_gui_spiral_height = gui_distance2,
|
||||
worldedit_gui_spiral_space = gui_distance3,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_spiral", fields, cg)
|
||||
if fields.worldedit_gui_spiral_submit then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_spiral")
|
||||
if fields.worldedit_gui_spiral_submit then
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
minetest.chatcommands["/spiral"].func(name, string.format("%s %s %s %s", gui_distance1[name], gui_distance2[name], gui_distance3[name], n))
|
||||
end
|
||||
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
execute_worldedit_command("spiral", name,
|
||||
string.format("%s %s %s %s", gui_distance1[name],
|
||||
gui_distance2[name], gui_distance3[name], n))
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_copy_move", {
|
||||
@ -429,29 +525,31 @@ worldedit.register_gui_function("worldedit_gui_copy_move", {
|
||||
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_copy_move") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_copy_move_amount;Amount;%s]", minetest.formspec_escape(amount)) ..
|
||||
string.format("dropdown[4,1.18;2.5;worldedit_gui_copy_move_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
|
||||
"field_close_on_enter[worldedit_gui_copy_move_amount;false]" ..
|
||||
"button_exit[0,2.5;3,0.8;worldedit_gui_copy_move_copy;Copy Region]" ..
|
||||
"button_exit[3.5,2.5;3,0.8;worldedit_gui_copy_move_move;Move Region]"
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_copy_move", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_copy_move_amount = gui_distance1,
|
||||
worldedit_gui_copy_move_axis = gui_axis1,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_spiral", fields, cg)
|
||||
if fields.worldedit_gui_copy_move_copy or fields.worldedit_gui_copy_move_move then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_copy_move_axis] or 4
|
||||
gui_distance1[name] = tostring(fields.worldedit_gui_copy_move_amount)
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_copy_move")
|
||||
if fields.worldedit_gui_copy_move_copy then
|
||||
minetest.chatcommands["/copy"].func(name, string.format("%s %s", axis_values[gui_axis1[name]], gui_distance1[name]))
|
||||
else --fields.worldedit_gui_copy_move_move
|
||||
minetest.chatcommands["/move"].func(name, string.format("%s %s", axis_values[gui_axis1[name]], gui_distance1[name]))
|
||||
|
||||
local submit = "copy"
|
||||
if fields.worldedit_gui_copy_move_move then
|
||||
submit = "move"
|
||||
end
|
||||
execute_worldedit_command(submit, name,
|
||||
axis_values[gui_axis1[name]] .. " " .. gui_distance1[name])
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_copy_move_axis then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_copy_move_axis] or 4
|
||||
worldedit.show_page(name, "worldedit_gui_copy_move")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_stack", {
|
||||
@ -462,24 +560,26 @@ worldedit.register_gui_function("worldedit_gui_stack", {
|
||||
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_stack") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_stack_count;Count;%s]", minetest.formspec_escape(count)) ..
|
||||
string.format("dropdown[4,1.18;2.5;worldedit_gui_stack_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
|
||||
"field_close_on_enter[worldedit_gui_stack_count;false]" ..
|
||||
"button_exit[0,2.5;3,0.8;worldedit_gui_stack_submit;Stack]"
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_stack", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_stack_axis = gui_axis1,
|
||||
worldedit_gui_stack_count = gui_count1,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_stack", fields, cg)
|
||||
if fields.worldedit_gui_stack_submit then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_stack_axis]
|
||||
gui_count1[name] = tostring(fields.worldedit_gui_stack_count)
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_stack")
|
||||
minetest.chatcommands["/stack"].func(name, string.format("%s %s", axis_values[gui_axis1[name]], gui_count1[name]))
|
||||
|
||||
execute_worldedit_command("stack", name,
|
||||
axis_values[gui_axis1[name]] .. " " .. gui_count1[name])
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_stack_axis then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_stack_axis]
|
||||
worldedit.show_page(name, "worldedit_gui_stack")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_stretch", {
|
||||
@ -491,20 +591,29 @@ worldedit.register_gui_function("worldedit_gui_stretch", {
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_stretch_x;Stretch X;%s]", minetest.formspec_escape(stretchx)) ..
|
||||
string.format("field[0.5,2.5;4,0.8;worldedit_gui_stretch_y;Stretch Y;%s]", minetest.formspec_escape(stretchy)) ..
|
||||
string.format("field[0.5,3.5;4,0.8;worldedit_gui_stretch_z;Stretch Z;%s]", minetest.formspec_escape(stretchz)) ..
|
||||
"field_close_on_enter[worldedit_gui_stretch_x;false]" ..
|
||||
"field_close_on_enter[worldedit_gui_stretch_y;false]" ..
|
||||
"field_close_on_enter[worldedit_gui_stretch_z;false]" ..
|
||||
"button_exit[0,4.5;3,0.8;worldedit_gui_stretch_submit;Stretch]"
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_stretch", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_stretch_x = gui_count1,
|
||||
worldedit_gui_stretch_y = gui_count2,
|
||||
worldedit_gui_stretch_z = gui_count3,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_stretch", fields, cg)
|
||||
if fields.worldedit_gui_stretch_submit then
|
||||
gui_count1[name] = tostring(fields.worldedit_gui_stretch_x)
|
||||
gui_count2[name] = tostring(fields.worldedit_gui_stretch_y)
|
||||
gui_count3[name] = tostring(fields.worldedit_gui_stretch_z)
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_stretch")
|
||||
minetest.chatcommands["/stretch"].func(name, string.format("%s %s %s", gui_count1[name], gui_count2[name], gui_count3[name]))
|
||||
|
||||
execute_worldedit_command("stretch", name, string.format("%s %s %s",
|
||||
gui_count1[name], gui_count2[name], gui_count3[name]))
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_transpose", {
|
||||
@ -520,23 +629,19 @@ worldedit.register_gui_function("worldedit_gui_transpose", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_transpose", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_transpose_axis1 = gui_axis1,
|
||||
worldedit_gui_transpose_axis2 = gui_axis2,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_transpose", fields, cg)
|
||||
if fields.worldedit_gui_transpose_submit then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_transpose_axis1]
|
||||
worldedit.show_page(name, "worldedit_gui_transpose")
|
||||
minetest.chatcommands["/transpose"].func(name, string.format("%s %s", axis_values[gui_axis1[name]], axis_values[gui_axis2[name]]))
|
||||
copy_changes(name, fields, cg)
|
||||
|
||||
execute_worldedit_command("transpose", name,
|
||||
axis_values[gui_axis1[name]] .. " " .. axis_values[gui_axis2[name]])
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_transpose_axis1 then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_transpose_axis1]
|
||||
worldedit.show_page(name, "worldedit_gui_transpose")
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_transpose_axis2 then
|
||||
gui_axis2[name] = axis_indices[fields.worldedit_gui_transpose_axis2]
|
||||
worldedit.show_page(name, "worldedit_gui_transpose")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_flip", {
|
||||
@ -551,18 +656,18 @@ worldedit.register_gui_function("worldedit_gui_flip", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_flip", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_flip_axis = gui_axis1
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_flip", fields, cg)
|
||||
if fields.worldedit_gui_flip_submit then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_flip_axis]
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_flip")
|
||||
minetest.chatcommands["/flip"].func(name, axis_values[gui_axis1[name]])
|
||||
|
||||
execute_worldedit_command("flip", name, axis_values[gui_axis1[name]])
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_flip_axis then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_flip_axis]
|
||||
worldedit.show_page(name, "worldedit_gui_flip")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_rotate", {
|
||||
@ -578,24 +683,20 @@ worldedit.register_gui_function("worldedit_gui_rotate", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_rotate", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_rotate_axis = gui_axis1,
|
||||
worldedit_gui_rotate_angle = gui_angle,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_rotate", fields, cg)
|
||||
if fields.worldedit_gui_rotate_submit then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_rotate_axis]
|
||||
gui_angle[name] = angle_indices[fields.worldedit_gui_rotate_angle]
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_rotate")
|
||||
minetest.chatcommands["/rotate"].func(name, string.format("%s %s", axis_values[gui_axis1[name]], angle_values[gui_angle[name]]))
|
||||
|
||||
execute_worldedit_command("rotate", name,
|
||||
axis_values[gui_axis1[name]] .. " " .. angle_values[gui_angle[name]])
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_rotate_axis then
|
||||
gui_axis1[name] = axis_indices[fields.worldedit_gui_rotate_axis]
|
||||
worldedit.show_page(name, "worldedit_gui_rotate")
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_rotate_angle then
|
||||
gui_angle[name] = angle_indices[fields.worldedit_gui_rotate_angle]
|
||||
worldedit.show_page(name, "worldedit_gui_rotate")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_orient", {
|
||||
@ -610,25 +711,26 @@ worldedit.register_gui_function("worldedit_gui_orient", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_orient", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_orient_angle = gui_angle,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_orient", fields, cg)
|
||||
if fields.worldedit_gui_orient_submit then
|
||||
gui_angle[name] = angle_indices[fields.worldedit_gui_orient_angle]
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_orient")
|
||||
minetest.chatcommands["/orient"].func(name, tostring(angle_values[gui_angle[name]]))
|
||||
|
||||
execute_worldedit_command("orient", name,
|
||||
tostring(angle_values[gui_angle[name]]))
|
||||
return true
|
||||
end
|
||||
if fields.worldedit_gui_orient_angle then
|
||||
gui_angle[name] = angle_indices[fields.worldedit_gui_orient_angle]
|
||||
worldedit.show_page(name, "worldedit_gui_orient")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_fixlight", {
|
||||
name = "Fix Lighting",
|
||||
privs = we_privs("fixlight"),
|
||||
on_select = function(name)
|
||||
minetest.chatcommands["/fixlight"].func(name, "")
|
||||
execute_worldedit_command("fixlight", name, "")
|
||||
end,
|
||||
})
|
||||
|
||||
@ -636,7 +738,7 @@ worldedit.register_gui_function("worldedit_gui_hide", {
|
||||
name = "Hide Region",
|
||||
privs = we_privs("hide"),
|
||||
on_select = function(name)
|
||||
minetest.chatcommands["/hide"].func(name, "")
|
||||
execute_worldedit_command("hide", name, "")
|
||||
end,
|
||||
})
|
||||
|
||||
@ -648,6 +750,7 @@ worldedit.register_gui_function("worldedit_gui_suppress", {
|
||||
local nodename = worldedit.normalize_nodename(node)
|
||||
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_suppress") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_suppress_node;Name;%s]", minetest.formspec_escape(node)) ..
|
||||
"field_close_on_enter[worldedit_gui_suppress_node;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_suppress_search;Search]" ..
|
||||
formspec_node("5.5,1.1", nodename) ..
|
||||
"button_exit[0,2.5;3,0.8;worldedit_gui_suppress_submit;Suppress Nodes]"
|
||||
@ -655,18 +758,22 @@ worldedit.register_gui_function("worldedit_gui_suppress", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_suppress", function(name, fields)
|
||||
if fields.worldedit_gui_suppress_search or fields.worldedit_gui_suppress_submit then
|
||||
gui_nodename1[name] = tostring(fields.worldedit_gui_suppress_node)
|
||||
local cg = {
|
||||
worldedit_gui_suppress_search = true,
|
||||
worldedit_gui_suppress_node = gui_nodename1,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_suppress", fields, cg)
|
||||
if fields.worldedit_gui_suppress_submit then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_suppress")
|
||||
if fields.worldedit_gui_suppress_submit then
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
minetest.chatcommands["/suppress"].func(name, n)
|
||||
end
|
||||
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
execute_worldedit_command("suppress", name, n)
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_highlight", {
|
||||
@ -677,6 +784,7 @@ worldedit.register_gui_function("worldedit_gui_highlight", {
|
||||
local nodename = worldedit.normalize_nodename(node)
|
||||
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_highlight") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_highlight_node;Name;%s]", minetest.formspec_escape(node)) ..
|
||||
"field_close_on_enter[worldedit_gui_highlight_node;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_highlight_search;Search]" ..
|
||||
formspec_node("5.5,1.1", nodename) ..
|
||||
"button_exit[0,2.5;3,0.8;worldedit_gui_highlight_submit;Highlight Nodes]"
|
||||
@ -684,25 +792,29 @@ worldedit.register_gui_function("worldedit_gui_highlight", {
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_highlight", function(name, fields)
|
||||
if fields.worldedit_gui_highlight_search or fields.worldedit_gui_highlight_submit then
|
||||
gui_nodename1[name] = tostring(fields.worldedit_gui_highlight_node)
|
||||
local cg = {
|
||||
worldedit_gui_highlight_search = true,
|
||||
worldedit_gui_highlight_node = gui_nodename1,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_highlight", fields, cg)
|
||||
if fields.worldedit_gui_highlight_submit then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_highlight")
|
||||
if fields.worldedit_gui_highlight_submit then
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
minetest.chatcommands["/highlight"].func(name, n)
|
||||
end
|
||||
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
execute_worldedit_command("highlight", name, n)
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_restore", {
|
||||
name = "Restore Region",
|
||||
privs = we_privs("restore"),
|
||||
on_select = function(name)
|
||||
minetest.chatcommands["/restore"].func(name, "")
|
||||
execute_worldedit_command("restore", name, "")
|
||||
end,
|
||||
})
|
||||
|
||||
@ -713,6 +825,7 @@ worldedit.register_gui_function("worldedit_gui_save_load", {
|
||||
local filename = gui_filename[name]
|
||||
return "size[6,4]" .. worldedit.get_formspec_header("worldedit_gui_save_load") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_save_filename;Filename;%s]", minetest.formspec_escape(filename)) ..
|
||||
"field_close_on_enter[worldedit_gui_save_filename;false]" ..
|
||||
"button_exit[0,2.5;3,0.8;worldedit_gui_save_load_submit_save;Save]" ..
|
||||
"button_exit[3,2.5;3,0.8;worldedit_gui_save_load_submit_allocate;Allocate]" ..
|
||||
"button_exit[0,3.5;3,0.8;worldedit_gui_save_load_submit_load;Load]"
|
||||
@ -723,12 +836,13 @@ worldedit.register_gui_handler("worldedit_gui_save_load", function(name, fields)
|
||||
if fields.worldedit_gui_save_load_submit_save or fields.worldedit_gui_save_load_submit_allocate or fields.worldedit_gui_save_load_submit_load then
|
||||
gui_filename[name] = tostring(fields.worldedit_gui_save_filename)
|
||||
worldedit.show_page(name, "worldedit_gui_save_load")
|
||||
|
||||
if fields.worldedit_gui_save_load_submit_save then
|
||||
minetest.chatcommands["/save"].func(name, gui_filename[name])
|
||||
execute_worldedit_command("save", name, gui_filename[name])
|
||||
elseif fields.worldedit_gui_save_load_submit_allocate then
|
||||
minetest.chatcommands["/allocate"].func(name, gui_filename[name])
|
||||
execute_worldedit_command("allocate", name, gui_filename[name])
|
||||
else --fields.worldedit_gui_save_load_submit_load
|
||||
minetest.chatcommands["/load"].func(name, gui_filename[name])
|
||||
execute_worldedit_command("load", name, gui_filename[name])
|
||||
end
|
||||
return true
|
||||
end
|
||||
@ -736,7 +850,7 @@ worldedit.register_gui_handler("worldedit_gui_save_load", function(name, fields)
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_cube", {
|
||||
name = "Cuboid", -- technically the command is misnamed, I know...
|
||||
name = "Cube",
|
||||
privs = combine_we_privs({"hollowcube", "cube"}),
|
||||
get_formspec = function(name)
|
||||
local width, height, length = gui_distance1[name], gui_distance2[name], gui_distance3[name]
|
||||
@ -744,47 +858,79 @@ worldedit.register_gui_function("worldedit_gui_cube", {
|
||||
local nodename = worldedit.normalize_nodename(node)
|
||||
return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_cube") ..
|
||||
string.format("field[0.5,1.5;4,0.8;worldedit_gui_cube_node;Name;%s]", minetest.formspec_escape(node)) ..
|
||||
"field_close_on_enter[worldedit_gui_cube_node;false]" ..
|
||||
"button[4,1.18;1.5,0.8;worldedit_gui_cube_search;Search]" ..
|
||||
formspec_node("5.5,1.1", nodename) ..
|
||||
string.format("field[0.5,2.5;1,0.8;worldedit_gui_cube_width;Width;%s]", minetest.formspec_escape(width)) ..
|
||||
string.format("field[1.5,2.5;1,0.8;worldedit_gui_cube_height;Height;%s]", minetest.formspec_escape(height)) ..
|
||||
string.format("field[2.5,2.5;1,0.8;worldedit_gui_cube_length;Length;%s]", minetest.formspec_escape(length)) ..
|
||||
"field_close_on_enter[worldedit_gui_cube_width;false]" ..
|
||||
"field_close_on_enter[worldedit_gui_cube_height;false]" ..
|
||||
"field_close_on_enter[worldedit_gui_cube_length;false]" ..
|
||||
"button_exit[0,3.5;3,0.8;worldedit_gui_cube_submit_hollow;Hollow Cuboid]" ..
|
||||
"button_exit[3.5,3.5;3,0.8;worldedit_gui_cube_submit_solid;Solid Cuboid]"
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_cube", function(name, fields)
|
||||
if fields.worldedit_gui_cube_search
|
||||
or fields.worldedit_gui_cube_submit_hollow or fields.worldedit_gui_cube_submit_solid then
|
||||
gui_nodename1[name] = tostring(fields.worldedit_gui_cube_node)
|
||||
gui_distance1[name] = tostring(fields.worldedit_gui_cube_width)
|
||||
gui_distance2[name] = tostring(fields.worldedit_gui_cube_height)
|
||||
gui_distance3[name] = tostring(fields.worldedit_gui_cube_length)
|
||||
local cg = {
|
||||
worldedit_gui_cube_search = true,
|
||||
worldedit_gui_cube_node = gui_nodename1,
|
||||
worldedit_gui_cube_width = gui_distance1,
|
||||
worldedit_gui_cube_height = gui_distance2,
|
||||
worldedit_gui_cube_length = gui_distance3,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_cube", fields, cg)
|
||||
if fields.worldedit_gui_cube_submit_hollow or fields.worldedit_gui_cube_submit_solid then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_cube")
|
||||
|
||||
local submit = nil
|
||||
if fields.worldedit_gui_cube_submit_hollow then
|
||||
submit = "hollowcube"
|
||||
elseif fields.worldedit_gui_cube_submit_solid then
|
||||
local submit = "hollowcube"
|
||||
if fields.worldedit_gui_cube_submit_solid then
|
||||
submit = "cube"
|
||||
end
|
||||
if submit then
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
local args = string.format("%s %s %s %s", gui_distance1[name], gui_distance2[name], gui_distance3[name], n)
|
||||
minetest.chatcommands["/"..submit].func(name, args)
|
||||
end
|
||||
local n = worldedit.normalize_nodename(gui_nodename1[name])
|
||||
if n then
|
||||
local args = string.format("%s %s %s %s", gui_distance1[name], gui_distance2[name], gui_distance3[name], n)
|
||||
execute_worldedit_command(submit, name, args)
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
return ret
|
||||
end)
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_clearobjects", {
|
||||
name = "Clear Objects",
|
||||
privs = we_privs("clearobjects"),
|
||||
on_select = function(name)
|
||||
minetest.chatcommands["/clearobjects"].func(name, "")
|
||||
execute_worldedit_command("clearobjects", name, "")
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_param2", {
|
||||
name = "Set Param2",
|
||||
privs = we_privs("param2"),
|
||||
get_formspec = function(name)
|
||||
local value = gui_param2[name] or "0"
|
||||
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_param2") ..
|
||||
"textarea[0.5,1;5,2;;;Some values may break the node!]"..
|
||||
string.format("field[0.5,2.5;2,0.8;worldedit_gui_param2_value;New Param2;%s]", minetest.formspec_escape(value)) ..
|
||||
"field_close_on_enter[worldedit_gui_param2_value;false]" ..
|
||||
"button_exit[3.5,2.5;3,0.8;worldedit_gui_param2_submit;Set Param2]"
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_param2", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_param2_value = gui_param2,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_param2", fields, cg)
|
||||
if fields.worldedit_gui_param2_submit then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_param2")
|
||||
|
||||
execute_worldedit_command("param2", name, gui_param2[name])
|
||||
return true
|
||||
end
|
||||
return ret
|
||||
end)
|
||||
|
@ -4,10 +4,10 @@ worldedit = worldedit or {}
|
||||
Example:
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_hollow_cylinder", {
|
||||
name = "Make Hollow Cylinder",
|
||||
privs = {worldedit=true},
|
||||
get_formspec = function(name) return "some formspec here" end,
|
||||
on_select = function(name) print(name .. " clicked the button!") end,
|
||||
name = "Make Hollow Cylinder",
|
||||
privs = {worldedit=true},
|
||||
get_formspec = function(name) return "some formspec here" end,
|
||||
on_select = function(name) print(name .. " clicked the button!") end,
|
||||
})
|
||||
|
||||
Use `nil` for the `options` parameter to unregister the function associated with the given identifier.
|
||||
@ -35,14 +35,14 @@ end
|
||||
Example:
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_hollow_cylinder", function(name, fields)
|
||||
print(minetest.serialize(fields))
|
||||
print(minetest.serialize(fields))
|
||||
end)
|
||||
]]
|
||||
|
||||
worldedit.register_gui_handler = function(identifier, handler)
|
||||
local enabled = true
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if not enabled then return false end
|
||||
if not enabled or formname ~= "" or fields.worldedit_gui then return false end
|
||||
enabled = false
|
||||
minetest.after(0.2, function() enabled = true end)
|
||||
local name = player:get_player_name()
|
||||
@ -70,7 +70,7 @@ local get_formspec = function(name, identifier)
|
||||
end
|
||||
|
||||
--implement worldedit.show_page(name, page) in different ways depending on the available APIs
|
||||
if rawget(_G, "unified_inventory") then --unified inventory installed
|
||||
if minetest.global_exists("unified_inventory") then -- unified inventory installed
|
||||
local old_func = worldedit.register_gui_function
|
||||
worldedit.register_gui_function = function(identifier, options)
|
||||
old_func(identifier, options)
|
||||
@ -80,6 +80,9 @@ if rawget(_G, "unified_inventory") then --unified inventory installed
|
||||
unified_inventory.register_button("worldedit_gui", {
|
||||
type = "image",
|
||||
image = "inventory_plus_worldedit_gui.png",
|
||||
condition = function(player)
|
||||
return minetest.check_player_privs(player:get_player_name(), {worldedit=true})
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
@ -103,7 +106,7 @@ if rawget(_G, "unified_inventory") then --unified inventory installed
|
||||
player:set_inventory_formspec(get_formspec(name, page))
|
||||
end
|
||||
end
|
||||
elseif rawget(_G, "inventory_plus") then --inventory++ installed
|
||||
elseif minetest.global_exists("inventory_plus") then -- inventory++ installed
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local can_worldedit = minetest.check_player_privs(player:get_player_name(), {worldedit=true})
|
||||
if can_worldedit then
|
||||
@ -134,7 +137,56 @@ elseif rawget(_G, "inventory_plus") then --inventory++ installed
|
||||
inventory_plus.set_inventory_formspec(player, get_formspec(name, page))
|
||||
end
|
||||
end
|
||||
elseif rawget(_G, "sfinv") then --sfinv installed (part of minetest_game since 0.4.15)
|
||||
elseif minetest.global_exists("smart_inventory") then -- smart_inventory installed
|
||||
-- redefinition: Update the code element on inventory page to show the we-page
|
||||
function worldedit.show_page(name, page)
|
||||
local state = smart_inventory.get_page_state("worldedit_gui", name)
|
||||
if state then
|
||||
state:get("code"):set_we_formspec(page)
|
||||
state.location.rootState:show() -- update inventory page
|
||||
end
|
||||
end
|
||||
|
||||
-- smart_inventory page callback. Contains just a "custom code" element
|
||||
local function smart_worldedit_gui_callback(state)
|
||||
local codebox = state:element("code", { name = "code", code = "" })
|
||||
function codebox:set_we_formspec(we_page)
|
||||
local new_formspec = get_formspec(state.location.rootState.location.player, we_page)
|
||||
new_formspec = new_formspec:gsub('button_exit','button') --no inventory closing
|
||||
self.data.code = "container[1,1]".. new_formspec .. "container_end[]"
|
||||
end
|
||||
codebox:set_we_formspec("worldedit_gui")
|
||||
|
||||
-- process input (the back button)
|
||||
state:onInput(function(state, fields, player)
|
||||
if fields.worldedit_gui then --main page
|
||||
state:get("code"):set_we_formspec("worldedit_gui")
|
||||
elseif fields.worldedit_gui_exit then --return to original page
|
||||
state:get("code"):set_we_formspec("worldedit_gui")
|
||||
state.location.parentState:get("crafting_button"):submit() -- switch to the crafting tab
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- all handler should return false to force inventory UI update
|
||||
local orig_register_gui_handler = worldedit.register_gui_handler
|
||||
worldedit.register_gui_handler = function(identifier, handler)
|
||||
local wrapper = function(...)
|
||||
handler(...)
|
||||
return false
|
||||
end
|
||||
orig_register_gui_handler(identifier, wrapper)
|
||||
end
|
||||
|
||||
-- register the inventory button
|
||||
smart_inventory.register_page({
|
||||
name = "worldedit_gui",
|
||||
tooltip = "Edit your World!",
|
||||
icon = "inventory_plus_worldedit_gui.png",
|
||||
smartfs_callback = smart_worldedit_gui_callback,
|
||||
sequence = 99
|
||||
})
|
||||
elseif minetest.global_exists("sfinv") then -- sfinv installed
|
||||
assert(sfinv.enabled)
|
||||
local orig_get = sfinv.pages["sfinv:crafting"].get
|
||||
sfinv.override_page("sfinv:crafting", {
|
||||
@ -145,21 +197,13 @@ elseif rawget(_G, "sfinv") then --sfinv installed (part of minetest_game since 0
|
||||
end
|
||||
})
|
||||
|
||||
--compatibility with pre-0.4.16 sfinv
|
||||
local set_page = sfinv.set_page or function(player, name)
|
||||
--assumptions: src pg has no leave callback, dst pg has no enter callback
|
||||
local ctx = {page=name}
|
||||
sfinv.contexts[player:get_player_name()] = ctx
|
||||
sfinv.set_player_inventory_formspec(player, ctx)
|
||||
end
|
||||
|
||||
--show the form when the button is pressed and hide it when done
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.worldedit_gui then --main page
|
||||
worldedit.show_page(player:get_player_name(), "worldedit_gui")
|
||||
return true
|
||||
elseif fields.worldedit_gui_exit then --return to original page
|
||||
set_page(player, "sfinv:crafting")
|
||||
sfinv.set_page(player, "sfinv:crafting")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
@ -172,12 +216,12 @@ elseif rawget(_G, "sfinv") then --sfinv installed (part of minetest_game since 0
|
||||
end
|
||||
end
|
||||
else
|
||||
error(
|
||||
"worldedit_gui requires a supported \"gui management\" mod to be installed\n"..
|
||||
"To use the GUI you need to either\n"..
|
||||
"* Use minetest_game (at least 0.4.15) or a subgame with compatible sfinv\n"..
|
||||
"* Install Unified Inventory or Inventory++\n"..
|
||||
"If you do not want to use worldedit_gui, disable it by editing world.mt or from the Main Menu"
|
||||
return minetest.log("error",
|
||||
"worldedit_gui requires a supported gui management mod to be installed.\n"..
|
||||
"To use the it you need to either:\n"..
|
||||
"* use minetest_game or another sfinv-compatible subgame\n"..
|
||||
"* install Unified Inventory, Inventory++ or Smart Inventory\n"..
|
||||
"If you don't want to use worldedit_gui, disable it by editing world.mt or from the main menu."
|
||||
)
|
||||
end
|
||||
|
||||
|
4
worldedit_gui/mod.conf
Normal file
@ -0,0 +1,4 @@
|
||||
name = worldedit_gui
|
||||
description = WorldEdit GUI
|
||||
depends = worldedit, worldedit_commands
|
||||
optional_depends = unified_inventory, inventory_plus, sfinv, creative, smart_inventory
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 597 B After Width: | Height: | Size: 382 B |
@ -1 +0,0 @@
|
||||
worldedit_commands
|
@ -1,52 +1,52 @@
|
||||
--provides shorter names for the commands in `worldedit_commands`
|
||||
|
||||
--returns true if command could not be aliased, false otherwise
|
||||
worldedit.alias_chatcommand = function(alias, original_command)
|
||||
if not minetest.chatcommands[original_command] then
|
||||
minetest.log("error", "worldedit_shortcommands: original command " .. original_command .. " does not exist")
|
||||
return true
|
||||
worldedit.alias_command = function(alias, original)
|
||||
if not worldedit.registered_commands[original] then
|
||||
minetest.log("error", "worldedit_shortcommands: original " .. original .. " does not exist")
|
||||
return
|
||||
end
|
||||
if minetest.chatcommands[alias] then
|
||||
if minetest.chatcommands["/" .. alias] then
|
||||
minetest.log("error", "worldedit_shortcommands: alias " .. alias .. " already exists")
|
||||
return true
|
||||
return
|
||||
end
|
||||
minetest.register_chatcommand(alias, minetest.chatcommands[original_command])
|
||||
return false
|
||||
|
||||
minetest.register_chatcommand("/" .. alias, minetest.chatcommands["/" .. original])
|
||||
worldedit.registered_commands[alias] = worldedit.registered_commands[original]
|
||||
end
|
||||
|
||||
worldedit.alias_chatcommand("/i", "/inspect")
|
||||
worldedit.alias_chatcommand("/rst", "/reset")
|
||||
worldedit.alias_chatcommand("/mk", "/mark")
|
||||
worldedit.alias_chatcommand("/umk", "/unmark")
|
||||
worldedit.alias_chatcommand("/1", "/pos1")
|
||||
worldedit.alias_chatcommand("/2", "/pos2")
|
||||
worldedit.alias_chatcommand("/fp", "/fixedpos")
|
||||
worldedit.alias_chatcommand("/v", "/volume")
|
||||
worldedit.alias_chatcommand("/s", "/set")
|
||||
worldedit.alias_chatcommand("/r", "/replace")
|
||||
worldedit.alias_chatcommand("/ri", "/replaceinverse")
|
||||
worldedit.alias_chatcommand("/hcube", "/hollowcube")
|
||||
worldedit.alias_chatcommand("/hspr", "/hollowsphere")
|
||||
worldedit.alias_chatcommand("/spr", "/sphere")
|
||||
worldedit.alias_chatcommand("/hdo", "/hollowdome")
|
||||
worldedit.alias_chatcommand("/do", "/dome")
|
||||
worldedit.alias_chatcommand("/hcyl", "/hollowcylinder")
|
||||
worldedit.alias_chatcommand("/cyl", "/cylinder")
|
||||
worldedit.alias_chatcommand("/hpyr", "/hollowpyramid")
|
||||
worldedit.alias_chatcommand("/pyr", "/pyramid")
|
||||
worldedit.alias_chatcommand("/spl", "/spiral")
|
||||
worldedit.alias_chatcommand("/m", "/move")
|
||||
worldedit.alias_chatcommand("/c", "/copy")
|
||||
worldedit.alias_chatcommand("/stk", "/stack")
|
||||
worldedit.alias_chatcommand("/sch", "/stretch")
|
||||
worldedit.alias_chatcommand("/tps", "/transpose")
|
||||
worldedit.alias_chatcommand("/fl", "/flip")
|
||||
worldedit.alias_chatcommand("/rot", "/rotate")
|
||||
worldedit.alias_chatcommand("/ort", "/orient")
|
||||
worldedit.alias_chatcommand("/hi", "/hide")
|
||||
worldedit.alias_chatcommand("/sup", "/suppress")
|
||||
worldedit.alias_chatcommand("/hlt", "/highlight")
|
||||
worldedit.alias_chatcommand("/rsr", "/restore")
|
||||
worldedit.alias_chatcommand("/l", "/lua")
|
||||
worldedit.alias_chatcommand("/lt", "/luatransform")
|
||||
worldedit.alias_chatcommand("/clro", "/clearobjects")
|
||||
worldedit.alias_command("i", "inspect")
|
||||
worldedit.alias_command("rst", "reset")
|
||||
worldedit.alias_command("mk", "mark")
|
||||
worldedit.alias_command("umk", "unmark")
|
||||
worldedit.alias_command("1", "pos1")
|
||||
worldedit.alias_command("2", "pos2")
|
||||
worldedit.alias_command("fp", "fixedpos")
|
||||
worldedit.alias_command("v", "volume")
|
||||
worldedit.alias_command("s", "set")
|
||||
worldedit.alias_command("r", "replace")
|
||||
worldedit.alias_command("ri", "replaceinverse")
|
||||
worldedit.alias_command("hcube", "hollowcube")
|
||||
worldedit.alias_command("hspr", "hollowsphere")
|
||||
worldedit.alias_command("spr", "sphere")
|
||||
worldedit.alias_command("hdo", "hollowdome")
|
||||
worldedit.alias_command("do", "dome")
|
||||
worldedit.alias_command("hcyl", "hollowcylinder")
|
||||
worldedit.alias_command("cyl", "cylinder")
|
||||
worldedit.alias_command("hpyr", "hollowpyramid")
|
||||
worldedit.alias_command("pyr", "pyramid")
|
||||
worldedit.alias_command("spl", "spiral")
|
||||
worldedit.alias_command("m", "move")
|
||||
worldedit.alias_command("c", "copy")
|
||||
worldedit.alias_command("stk", "stack")
|
||||
worldedit.alias_command("sch", "stretch")
|
||||
worldedit.alias_command("tps", "transpose")
|
||||
worldedit.alias_command("fl", "flip")
|
||||
worldedit.alias_command("rot", "rotate")
|
||||
worldedit.alias_command("ort", "orient")
|
||||
worldedit.alias_command("hi", "hide")
|
||||
worldedit.alias_command("sup", "suppress")
|
||||
worldedit.alias_command("hlt", "highlight")
|
||||
worldedit.alias_command("rsr", "restore")
|
||||
worldedit.alias_command("l", "lua")
|
||||
worldedit.alias_command("lt", "luatransform")
|
||||
worldedit.alias_command("clro", "clearobjects")
|
||||
|
3
worldedit_shortcommands/mod.conf
Normal file
@ -0,0 +1,3 @@
|
||||
name = worldedit_shortcommands
|
||||
description = WorldEdit command short aliases
|
||||
depends = worldedit_commands
|