Updated WorldEdit

master
Nathan Salapat 2022-09-03 12:13:43 -05:00
parent 07c2a32c17
commit 8cd81a9b10
22 changed files with 817 additions and 335 deletions

View File

@ -6,42 +6,26 @@ Many commands also have shorter names that can be typed faster. For example, if
| Short Name | Original Name |
|:-----------|:-------------------|
| `//i` | `//inspect` |
| `//rst` | `//reset` |
| `//mk` | `//mark` |
| `//umk` | `//unmark` |
| `//1` | `//pos1` |
| `//2` | `//pos2` |
| `//c` | `//copy` |
| `//clro` | `//clearobjects` |
| `//cyl` | `//cylinder` |
| `//do` | `//dome` |
| `//fl` | `//flip` |
| `//fp` | `//fixedpos` |
| `//hcube` | `//hollowcube` |
| `//hcyl` | `//hollowcylinder` |
| `//hdo` | `//hollowdome` |
| `//hi` | `//hide` |
| `//hlt` | `//highlight` |
| `//hpyr` | `//hollowpyramid` |
| `//hspr` | `//hollowsphere` |
| `//i` | `//inspect` |
| `//l` | `//lua` |
| `//lt` | `//luatransform` |
| `//mk` | `//mark` |
| `//m` | `//move` |
| `//ort` | `//orient` |
| `//pyr` | `//pyramid` |
| `//ri` | `//replaceinverse` |
| `//rot` | `//rotate` |
| `//r` | `//replace` |
| `//rsr` | `//restore` |
| `//rst` | `//reset` |
| `//sch` | `//stretch` |
| `//spl` | `//spiral` |
| `//spr` | `//sphere` |
| `//s` | `//set` |
| `//stk` | `//stack` |
| `//sup` | `//suppress` |
| `//tps` | `//transpose` |
| `//umk` | `//unmark` |
| `//v` | `//volume` |
| `//s` | `//set` |
| `//r` | `//replace` |
| `//ri` | `//replaceinverse` |
| `//hcube` | `//hollowcube` |
| `//hspr` | `//hollowsphere` |
| `//spr` | `//sphere` |
| `//hdo` | `//hollowdome` |
| `//do` | `//dome` |
| `//hcyl` | `//hollowcylinder` |
| `//cyl` | `//cylinder` |
| `//hpyr` | `//hollowpyramid` |
| `//pyr` | `//pyramid` |
### `//about`

View File

@ -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,37 +11,40 @@ 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).
@ -49,9 +52,11 @@ Compatibility
-------------
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), [Unified Inventory](https://forum.minetest.net/viewtopic.php?t=12767) or [Inventory++](https://forum.minetest.net/viewtopic.php?id=6204) or [Smart Inventory](https://forum.minetest.net/viewtopic.php?t=16597).
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,7 +64,7 @@ WorldEdit API
-------------
WorldEdit exposes all significant functionality in a simple Lua interface.
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.
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 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.
@ -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,13 +140,15 @@ 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:
Alexander Weber
ANAND
beyondlimits
Carter Kolwey
cornernote
@ -145,6 +157,7 @@ WorldEdit would not be possible without the contributions of many developers and
electricface
est31
Eugen Wesseloh
h3ndrik
HybridDog
Isidor Zeuner
Jean-Patrick Guerrero
@ -171,9 +184,9 @@ WorldEdit would not be possible without the contributions of many developers and
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.

View File

@ -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.

View File

@ -38,3 +38,7 @@ 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

View File

@ -1,40 +0,0 @@
--- Worldedit.
-- @module worldedit
-- @release 1.2
-- @copyright 2013 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)
-- @author Bret O'Donnel (cornernote)
-- @author ShadowNinja
worldedit = {}
local ver = {major=1, minor=2}
worldedit.version = ver
worldedit.version_string = string.format("%d.%d", ver.major, ver.minor)
local path = minetest.get_modpath(minetest.get_current_modname())
local function load_module(path)
local file = io.open(path, "r")
if not file then return end
file:close()
return dofile(path)
end
dofile(path .. "/common.lua")
load_module(path .. "/manipulations.lua")
load_module(path .. "/primitives.lua")
load_module(path .. "/visualization.lua")
load_module(path .. "/serialization.lua")
load_module(path .. "/code.lua")
load_module(path .. "/compatibility.lua")
load_module(path .. "/cuboid.lua")
if minetest.settings:get_bool("log_mods") then
print("[WorldEdit] Loaded!")
end

View File

@ -3,6 +3,7 @@
local mh = worldedit.manip_helpers
--- Sets a region to `node_names`.
-- @param pos1
-- @param pos2
@ -61,33 +62,6 @@ function worldedit.set_param2(pos1, pos2, param2)
return worldedit.volume(pos1, pos2)
end
--- Changes param2 by a constant value for each node in a region.
-- @param pos1
-- @param pos2
-- @param delta Param2 value to add to each node
-- @return The number of nodes set.
function worldedit.add_param2(pos1, pos2, delta)
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
local manip, area = mh.init(pos1, pos2)
local param2_data = manip:get_param2_data()
local new_p2 = 0
-- Add delta to every node
for i in area:iterp(pos1, pos2) do
new_p2 = (param2_data[i] + delta) % 256
if new_p2 < 0 then new_p2 = new_p2 + 256 end
param2_data[i] = new_p2
end
-- Update map
manip:set_param2_data(param2_data)
manip:write_to_map()
manip:update_map()
return worldedit.volume(pos1, pos2)
end
--- Replaces all instances of `search_node` with `replace_node` in a region.
-- When `inverse` is `true`, replaces all instances that are NOT `search_node`.
-- @return The number of nodes replaced.
@ -666,10 +640,34 @@ function worldedit.clear_objects(pos1, pos2)
worldedit.keep_loaded(pos1, pos2)
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)
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 count = 0
if minetest.get_objects_in_area then
local objects = minetest.get_objects_in_area({x=pos1x, y=pos1y, z=pos1z},
{x=pos2x, y=pos2y, z=pos2z})
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),
@ -681,12 +679,8 @@ function worldedit.clear_objects(pos1, pos2)
(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
if should_delete(obj) then
local pos = obj:get_pos()
if pos.x >= pos1x and pos.x <= pos2x and
pos.y >= pos1y and pos.y <= pos2y and

View File

@ -114,11 +114,14 @@ function worldedit.serialize(pos1, pos2)
return LATEST_SERIALIZATION_HEADER .. result, count
end
-- Contains code based on [table.save/table.load](http://lua-users.org/wiki/SaveTableToFile)
-- by ChillCode, available under the MIT license.
local function deserialize_workaround(content)
local nodes
if not jit then
if not minetest.global_exists("jit") then
nodes = 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 = minetest.deserialize(content, true)
else
-- XXX: This is a filthy hack that works surprisingly well
@ -130,7 +133,7 @@ local function deserialize_workaround(content)
local startpos, startpos1 = 1, 1
local endpos
while true do -- go through each individual node entry (except the last)
startpos, endpos = escaped:find("},%s*{", startpos)
startpos, endpos = escaped:find("}%s*,%s*{", startpos)
if not startpos then
break
end

View File

@ -0,0 +1,448 @@
---------------------
-- 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 or sizez == nil then
size = {x=sizex, y=sizex, z=sizex}
else
size = {x=sizex, y=sizey, z=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)
---------------------
-- 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({x=x*16, y=y*16, z=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)

View File

@ -1,7 +1,7 @@
worldedit.register_command("outset", {
params = "[h/v] <amount>",
description = "Outset the selected region.",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local find, _, dir, amount = param:find("(%a*)%s*([+-]?%d+)")
@ -40,7 +40,7 @@ worldedit.register_command("outset", {
worldedit.register_command("inset", {
params = "[h/v] <amount>",
description = "Inset the selected region.",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local find, _, dir, amount = param:find("(%a*)%s*([+-]?%d+)")
@ -77,7 +77,7 @@ worldedit.register_command("inset", {
worldedit.register_command("shift", {
params = "x/y/z/?/up/down/left/right/front/back [+/-]<amount>",
description = "Shifts the selection area without moving its contents",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local find, _, direction, amount = param:find("([%?%l]+)%s*([+-]?%d+)")
@ -112,7 +112,7 @@ worldedit.register_command("shift", {
worldedit.register_command("expand", {
params = "[+/-]x/y/z/?/up/down/left/right/front/back <amount> [reverse amount]",
description = "Expands the selection in the selected absolute or relative axis",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local find, _, sign, direction, amount,
@ -161,7 +161,7 @@ worldedit.register_command("expand", {
worldedit.register_command("contract", {
params = "[+/-]x/y/z/?/up/down/left/right/front/back <amount> [reverse amount]",
description = "Contracts the selection in the selected absolute or relative axis",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local find, _, sign, direction, amount,
@ -209,7 +209,7 @@ worldedit.register_command("contract", {
worldedit.register_command("cubeapply", {
params = "<size>/(<sizex> <sizey> <sizez>) <command> [parameters]",
description = "Select a cube with side length <size> around position 1 and run <command> on region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = function(param)
local found, _, sidex, sidey, sidez, cmd, args =

View File

@ -1,5 +1,4 @@
minetest.register_privilege("worldedit", "Old")
minetest.register_privilege("worldeditor", "Can use WorldEdit commands")
minetest.register_privilege("worldedit", "Can use WorldEdit commands")
worldedit.pos1 = {}
worldedit.pos2 = {}
@ -65,7 +64,7 @@ end
-- def = {
-- privs = {}, -- Privileges needed
-- params = "", -- Human readable parameter list (optional)
-- -- setting params = "" will automatically provide a parse() if not given
-- -- setting params = "" will automatically provide a parse() if not given
-- description = "", -- Description
-- require_pos = 0, -- Number of positions required to be set (optional)
-- parse = function(param)
@ -298,7 +297,7 @@ worldedit.register_command("help", {
worldedit.register_command("inspect", {
params = "[on/off/1/0/true/false/yes/no/enable/disable]",
description = "Enable or disable node inspection",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
parse = function(param)
if param == "on" or param == "1" or param == "true" or param == "yes" or param == "enable" or param == "" then
return true, true
@ -349,7 +348,7 @@ end)
worldedit.register_command("reset", {
params = "",
description = "Reset the region so that it is empty",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
func = function(name)
worldedit.pos1[name] = nil
worldedit.pos2[name] = nil
@ -364,7 +363,7 @@ worldedit.register_command("reset", {
worldedit.register_command("mark", {
params = "",
description = "Show markers at the region positions",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
func = function(name)
worldedit.marker_update(name)
worldedit.player_notify(name, "region marked")
@ -374,7 +373,7 @@ worldedit.register_command("mark", {
worldedit.register_command("unmark", {
params = "",
description = "Hide markers if currently shown",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
func = function(name)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
worldedit.pos1[name] = nil
@ -389,41 +388,33 @@ worldedit.register_command("unmark", {
worldedit.register_command("pos1", {
params = "",
description = "Set WorldEdit region position 1 to the player's location",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
func = function(name)
local pos = minetest.get_player_by_name(name):get_pos()
pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5)
if not minetest.is_protected(pos, name) or not minetest.check_player_privs(name, {server = true}) then
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
else
minetest.chat_send_player(name, 'Try again')
end
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
end,
})
worldedit.register_command("pos2", {
params = "",
description = "Set WorldEdit region position 2 to the player's location",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
func = function(name)
local pos = minetest.get_player_by_name(name):get_pos()
pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5)
if not minetest.is_protected(pos, name) or not minetest.check_player_privs(name, {server = true}) then
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
else
minetest.chat_send_player(name, 'Try again')
end
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
end,
})
worldedit.register_command("p", {
params = "set/set1/set2/get",
description = "Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
parse = function(param)
if param == "set" or param == "set1" or param == "set2" or param == "get" then
return true, param
@ -458,7 +449,7 @@ worldedit.register_command("p", {
worldedit.register_command("fixedpos", {
params = "set1/set2 <x> <y> <z>",
description = "Set a WorldEdit region position to the position at (<x>, <y>, <z>)",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
parse = function(param)
local found, _, flag, x, y, z = param:find("^(set[12])%s+([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)$")
if found == nil then
@ -468,17 +459,13 @@ worldedit.register_command("fixedpos", {
end,
func = function(name, flag, pos)
if flag == "set1" then
if not minetest.is_protected(pos, name) then
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
end
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
else --flag == "set2"
if not minetest.is_protected(pos, name) then
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
end
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
end
end,
})
@ -487,26 +474,20 @@ minetest.register_on_punchnode(function(pos, node, puncher)
local name = puncher:get_player_name()
if name ~= "" and worldedit.set_pos[name] ~= nil then --currently setting position
if worldedit.set_pos[name] == "pos1" then --setting position 1
if not minetest.is_protected(pos, puncher:get_player_name()) then
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.set_pos[name] = "pos2" --set position 2 on the next invocation
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
end
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.set_pos[name] = "pos2" --set position 2 on the next invocation
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
elseif worldedit.set_pos[name] == "pos1only" then --setting position 1 only
if not minetest.is_protected(pos, puncher:get_player_name()) then
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.set_pos[name] = nil --finished setting positions
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
end
worldedit.pos1[name] = pos
worldedit.mark_pos1(name)
worldedit.set_pos[name] = nil --finished setting positions
worldedit.player_notify(name, "position 1 set to " .. minetest.pos_to_string(pos))
elseif worldedit.set_pos[name] == "pos2" then --setting position 2
if not minetest.is_protected(pos, puncher:get_player_name()) then
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.set_pos[name] = nil --finished setting positions
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
end
worldedit.pos2[name] = pos
worldedit.mark_pos2(name)
worldedit.set_pos[name] = nil --finished setting positions
worldedit.player_notify(name, "position 2 set to " .. minetest.pos_to_string(pos))
elseif worldedit.set_pos[name] == "prob" then --setting Minetest schematic node probabilities
worldedit.prob_pos[name] = pos
minetest.show_formspec(puncher:get_player_name(), "prob_val_enter", "field[text;;]")
@ -514,11 +495,10 @@ minetest.register_on_punchnode(function(pos, node, puncher)
end
end)
worldedit.register_command("volume", {
params = "",
description = "Display the volume of the current WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
func = function(name)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
@ -535,7 +515,7 @@ worldedit.register_command("volume", {
worldedit.register_command("deleteblocks", {
params = "",
description = "remove all MapBlocks (16x16x16) containing the selected area from the map",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
nodes_needed = check_region,
func = function(name)
@ -552,7 +532,7 @@ worldedit.register_command("deleteblocks", {
worldedit.register_command("set", {
params = "<node>",
description = "Set the current WorldEdit region to <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local node = worldedit.normalize_nodename(param)
@ -571,7 +551,7 @@ worldedit.register_command("set", {
worldedit.register_command("param2", {
params = "<param2>",
description = "Set param2 of all nodes in the current WorldEdit region to <param2>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local param2 = tonumber(param)
@ -589,44 +569,10 @@ worldedit.register_command("param2", {
end,
})
--[[
//pbrush: special command for the "Traitor" game.
Simulates using Traitor's "PaintBrush" tool on a WorldEdit region.
]]--
worldedit.register_command("pbrush", {
params = "+ / - / [+/-]<steps>",
description = minetest.formspec_escape(
"Increase/decrease the color tone of all suitable nodes in the current WorldEdit region.\n"
.. "Suitable nodes are those that can be colored using the PaintBrush tool "
.. "(e.g. the blocks in the 'color' namespace).\n"
.. "Using + or - changes the color once; use <steps> for multiple steps.\n"
.. "Note that <steps> should be at most 7, higher values are ignored."),
privs = {worldeditor=true, creative=true},
require_pos = 2,
parse = function(param)
local found, _, sign, steps = param:find("([+-]?)(%d?)")
local delta = 32
if found == nil then return false end
if steps ~= nil and steps ~= "" then
local count = tonumber(steps) % 8
delta = 32 * count
end
if sign == "-" then delta = -delta end
return true, delta
end,
nodes_needed = check_region,
func = function(name, delta)
local count = worldedit.add_param2(worldedit.pos1[name], worldedit.pos2[name], delta)
worldedit.player_notify(name, count .. " nodes altered")
end,
})
worldedit.register_command("mix", {
params = "<node1> [count1] <node2> [count2] ...",
description = "Fill the current WorldEdit region with a random mix of <node1>, ...",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local nodes = {}
@ -676,7 +622,7 @@ end
worldedit.register_command("replace", {
params = "<search node> <replace node>",
description = "Replace all instances of <search node> with <replace node> in the current WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = check_replace,
nodes_needed = check_region,
@ -690,7 +636,7 @@ worldedit.register_command("replace", {
worldedit.register_command("replaceinverse", {
params = "<search node> <replace node>",
description = "Replace all nodes other than <search node> with <replace node> in the current WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = check_replace,
nodes_needed = check_region,
@ -716,7 +662,7 @@ end
worldedit.register_command("hollowcube", {
params = "<width> <height> <length> <node>",
description = "Add a hollow cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_cube,
nodes_needed = function(name, w, h, l, node)
@ -731,7 +677,7 @@ worldedit.register_command("hollowcube", {
worldedit.register_command("cube", {
params = "<width> <height> <length> <node>",
description = "Add a cube with its ground level centered at WorldEdit position 1 with dimensions <width> x <height> x <length>, composed of <node>.",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_cube,
nodes_needed = function(name, w, h, l, node)
@ -758,7 +704,7 @@ end
worldedit.register_command("hollowsphere", {
params = "<radius> <node>",
description = "Add hollow sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_sphere,
nodes_needed = function(name, radius, node)
@ -773,7 +719,7 @@ worldedit.register_command("hollowsphere", {
worldedit.register_command("sphere", {
params = "<radius> <node>",
description = "Add sphere centered at WorldEdit position 1 with radius <radius>, composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_sphere,
nodes_needed = function(name, radius, node)
@ -800,7 +746,7 @@ end
worldedit.register_command("hollowdome", {
params = "<radius> <node>",
description = "Add hollow dome centered at WorldEdit position 1 with radius <radius>, composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_dome,
nodes_needed = function(name, radius, node)
@ -815,7 +761,7 @@ worldedit.register_command("hollowdome", {
worldedit.register_command("dome", {
params = "<radius> <node>",
description = "Add dome centered at WorldEdit position 1 with radius <radius>, composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_dome,
nodes_needed = function(name, radius, node)
@ -848,7 +794,7 @@ end
worldedit.register_command("hollowcylinder", {
params = "x/y/z/? <length> <radius1> [radius2] <node>",
description = "Add hollow cylinder at WorldEdit position 1 along the given axis with length <length>, base radius <radius1> (and top radius [radius2]), composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_cylinder,
nodes_needed = function(name, axis, length, radius1, radius2, node)
@ -869,7 +815,7 @@ worldedit.register_command("hollowcylinder", {
worldedit.register_command("cylinder", {
params = "x/y/z/? <length> <radius1> [radius2] <node>",
description = "Add cylinder at WorldEdit position 1 along the given axis with length <length>, base radius <radius1> (and top radius [radius2]), composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_cylinder,
nodes_needed = function(name, axis, length, radius1, radius2, node)
@ -898,11 +844,11 @@ local check_pyramid = function(param)
end
return true, axis, tonumber(height), node
end
worldedit.register_command("hollowpyramid", {
params = "x/y/z/? <height> <node>",
description = "Add hollow pyramid centered at WorldEdit position 1 along the given axis with height <height>, composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_pyramid,
nodes_needed = function(name, axis, height, node)
@ -922,7 +868,7 @@ worldedit.register_command("hollowpyramid", {
worldedit.register_command("pyramid", {
params = "x/y/z/? <height> <node>",
description = "Add pyramid centered at WorldEdit position 1 along the given axis with height <height>, composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = check_pyramid,
nodes_needed = function(name, axis, height, node)
@ -942,7 +888,7 @@ worldedit.register_command("pyramid", {
worldedit.register_command("spiral", {
params = "<length> <height> <space> <node>",
description = "Add spiral centered at WorldEdit position 1 with side length <length>, height <height>, space between walls <space>, composed of <node>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = function(param)
local found, _, length, height, space, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")
@ -967,7 +913,7 @@ worldedit.register_command("spiral", {
worldedit.register_command("copy", {
params = "x/y/z/? <amount>",
description = "Copy the current WorldEdit region along the given axis by <amount> nodes",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local found, _, axis, amount = param:find("^([xyz%?])%s+([+-]?%d+)$")
@ -994,7 +940,7 @@ worldedit.register_command("copy", {
worldedit.register_command("move", {
params = "x/y/z/? <amount>",
description = "Move the current WorldEdit region along the given axis by <amount> nodes",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local found, _, axis, amount = param:find("^([xyz%?])%s+([+-]?%d+)$")
@ -1026,7 +972,7 @@ worldedit.register_command("move", {
worldedit.register_command("stack", {
params = "x/y/z/? <count>",
description = "Stack the current WorldEdit region along the given axis <count> times",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local found, _, axis, repetitions = param:find("^([xyz%?])%s+([+-]?%d+)$")
@ -1056,7 +1002,7 @@ worldedit.register_command("stack", {
worldedit.register_command("stack2", {
params = "<count> <x> <y> <z>",
description = "Stack the current WorldEdit region <count> times by offset <x>, <y>, <z>",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local repetitions, incs = param:match("(%d+)%s*(.+)")
@ -1086,7 +1032,7 @@ worldedit.register_command("stack2", {
worldedit.register_command("stretch", {
params = "<stretchx> <stretchy> <stretchz>",
description = "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",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local found, _, stretchx, stretchy, stretchz = param:find("^(%d+)%s+(%d+)%s+(%d+)$")
@ -1118,7 +1064,7 @@ worldedit.register_command("stretch", {
worldedit.register_command("transpose", {
params = "x/y/z/? x/y/z/?",
description = "Transpose the current WorldEdit region along the given axes",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local found, _, axis1, axis2 = param:find("^([xyz%?])%s+([xyz%?])$")
@ -1148,7 +1094,7 @@ worldedit.register_command("transpose", {
worldedit.register_command("flip", {
params = "x/y/z/?",
description = "Flip the current WorldEdit region along the given axis",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
if param ~= "x" and param ~= "y" and param ~= "z" and param ~= "?" then
@ -1167,7 +1113,7 @@ worldedit.register_command("flip", {
worldedit.register_command("rotate", {
params = "x/y/z/? <angle>",
description = "Rotate the current WorldEdit region around the given axis by angle <angle> (90 degree increment)",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local found, _, axis, angle = param:find("^([xyz%?])%s+([+-]?%d+)$")
@ -1198,7 +1144,7 @@ worldedit.register_command("rotate", {
worldedit.register_command("orient", {
params = "<angle>",
description = "Rotate oriented nodes in the current WorldEdit region around the Y axis by angle <angle> (90 degree increment)",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local found, _, angle = param:find("^([+-]?%d+)$")
@ -1221,7 +1167,7 @@ worldedit.register_command("orient", {
worldedit.register_command("fixlight", {
params = "",
description = "Fix the lighting in the current WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
nodes_needed = check_region,
func = function(name)
@ -1233,7 +1179,7 @@ worldedit.register_command("fixlight", {
worldedit.register_command("drain", {
params = "",
description = "Remove any fluid node within the current WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
nodes_needed = check_region,
func = function(name)
@ -1325,7 +1271,7 @@ end
worldedit.register_command("clearcut", {
params = "",
description = "Remove any plant, tree or foilage-like nodes in the selected region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
nodes_needed = check_region,
func = function(name)
@ -1338,7 +1284,7 @@ worldedit.register_command("clearcut", {
worldedit.register_command("hide", {
params = "",
description = "Hide all nodes in the current WorldEdit region non-destructively",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
nodes_needed = check_region,
func = function(name)
@ -1350,7 +1296,7 @@ worldedit.register_command("hide", {
worldedit.register_command("suppress", {
params = "<node>",
description = "Suppress all <node> in the current WorldEdit region non-destructively",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local node = worldedit.normalize_nodename(param)
@ -1369,7 +1315,7 @@ worldedit.register_command("suppress", {
worldedit.register_command("highlight", {
params = "<node>",
description = "Highlight <node> in the current WorldEdit region by hiding everything else non-destructively",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
local node = worldedit.normalize_nodename(param)
@ -1388,7 +1334,7 @@ worldedit.register_command("highlight", {
worldedit.register_command("restore", {
params = "",
description = "Restores nodes hidden with WorldEdit in the current WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
nodes_needed = check_region,
func = function(name)
@ -1417,7 +1363,7 @@ end
worldedit.register_command("save", {
params = "<file>",
description = "Save the current WorldEdit region to \"(world folder)/schems/<file>.we\"",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
if param == "" then
@ -1455,7 +1401,7 @@ worldedit.register_command("save", {
worldedit.register_command("allocate", {
params = "<file>",
description = "Set the region defined by nodes from \"(world folder)/schems/<file>.we\" as the current WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = function(param)
if param == "" then
@ -1504,7 +1450,7 @@ worldedit.register_command("allocate", {
worldedit.register_command("load", {
params = "<file>",
description = "Load nodes from \"(world folder)/schems/<file>[.we[m]]\" with position 1 of the current WorldEdit region as the origin",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = function(param)
if param == "" then
@ -1565,7 +1511,7 @@ worldedit.register_command("load", {
worldedit.register_command("lua", {
params = "<code>",
description = "Executes <code> as a Lua chunk in the global namespace",
privs = {worldeditor=true, server=true},
privs = {worldedit=true, server=true},
parse = function(param)
return true, param
end,
@ -1584,7 +1530,7 @@ worldedit.register_command("lua", {
worldedit.register_command("luatransform", {
params = "<code>",
description = "Executes <code> as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region",
privs = {worldeditor=true, server=true},
privs = {worldedit=true, server=true},
require_pos = 2,
parse = function(param)
return true, param
@ -1606,7 +1552,7 @@ worldedit.register_command("mtschemcreate", {
params = "<file>",
description = "Save the current WorldEdit region using the Minetest "..
"Schematic format to \"(world folder)/schems/<filename>.mts\"",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
parse = function(param)
if param == "" then
@ -1639,7 +1585,7 @@ worldedit.register_command("mtschemcreate", {
worldedit.register_command("mtschemplace", {
params = "<file>",
description = "Load nodes from \"(world folder)/schems/<file>.mts\" with position 1 of the current WorldEdit region as the origin",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 1,
parse = function(param)
if param == "" then
@ -1666,7 +1612,7 @@ worldedit.register_command("mtschemplace", {
worldedit.register_command("mtschemprob", {
params = "start/finish/get",
description = "Begins node probability entry for Minetest schematics, gets the nodes that have probabilities set, or ends node probability entry",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
parse = function(param)
if param ~= "start" and param ~= "finish" and param ~= "get" then
return false, "unknown subcommand: " .. param
@ -1709,7 +1655,7 @@ end)
worldedit.register_command("clearobjects", {
params = "",
description = "Clears all objects within the WorldEdit region",
privs = {worldeditor=true, creative=true},
privs = {worldedit=true},
require_pos = 2,
nodes_needed = check_region,
func = function(name)

View File

@ -123,48 +123,6 @@ worldedit.marker_update = function(name)
worldedit.mark_region(name)
end
--[[
Determines if the thing currently being pointed at is one of the following:
- one of the Worldedit position boxes to delimit a Worldedit region
- one of the special cubes that Worldedit puts at certain nodes to
visualize the bounds of a selection region
The function uses knowledge about the internal structure of the Worldedit
regions. Also, it uses the API function "ObjectRef:get_entity_name" to
determine the registered names of the object pointed at. However, the
documentation states that this function will be removed in the future[1].
--------------------------------------------------------------------------
[1] https://minetest.gitlab.io/minetest/class-reference/#objectref
--]]
worldedit.is_marker_region = function(pointed_thing)
if pointed_thing ~= nil and pointed_thing.type ~= nil then
if pointed_thing.type == 'object' and pointed_thing.ref ~= nil then
local ref = pointed_thing.ref
if ref.get_entity_name ~= nil then
local objname = ref:get_entity_name()
if objname == 'worldedit:region_cube' or
objname == 'worldedit:pos1' or
objname == 'worldedit:pos2' then
return true
end
end
end
end
return false
end
--[[
Returns true if `user` is the owner of the Worldedit marker region
currently being pointed at.
--]]
worldedit.is_region_owner = function(pointed_thing, user)
local region_ref = pointed_thing.ref
local region_entity = region_ref:get_luaentity()
return (user == region_entity.player_name)
end
minetest.register_entity(":worldedit:pos1", {
initial_properties = {
visual = "cube",

View File

@ -11,7 +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 = {}
local gui_param2 = {} --mapping of player names to param2 values
--set default values
setmetatable(gui_nodename1, {__index = function() return "Cobblestone" end})
@ -913,10 +913,10 @@ worldedit.register_gui_function("worldedit_gui_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 make break the node!]'..
"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_copy_move_amount;false]" ..
"button_exit[3.5,2.5;3,0.8;worldedit_gui_param2;Set Param2]"
"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,
})
@ -925,10 +925,11 @@ worldedit.register_gui_handler("worldedit_gui_param2", function(name, fields)
worldedit_gui_param2_value = gui_param2,
}
local ret = handle_changes(name, "worldedit_gui_param2", fields, cg)
if fields.worldedit_gui_param2_value then
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])
execute_worldedit_command("param2", name, gui_param2[name])
return true
end
return ret

View File

@ -5,7 +5,7 @@ Example:
worldedit.register_gui_function("worldedit_gui_hollow_cylinder", {
name = "Make Hollow Cylinder",
privs = {worldeditor=true},
privs = {worldedit=true},
get_formspec = function(name) return "some formspec here" end,
on_select = function(name) print(name .. " clicked the button!") end,
})

View File

@ -1,4 +0,0 @@
#!/bin/sh
## This generates the contents for the aliases table in ../ChatCommands.md
grep "alias_command(" init.lua | sort | sed 's,[^"]*",,;s/"[^"]*"/ /;s/".*//' | awk '{printf("| %-10s | %-18s |\n", "`//" $1 "`", "`//" $2 "`")}'

116
mods/tasks/beehive.lua Normal file
View File

@ -0,0 +1,116 @@
local box = {
type = 'fixed',
fixed = {
{-.5, -.5, -.5, .5, .375, .5}}}
local formspec_good =
'formspec_version[3]'..
'size[12,6]'..
'image[0,0;12,6;tasks_beehive_ui_bg.png]'
local function math_clamp(val, lower, upper)
return math.max(lower, math.min(upper, val))
end
beehive = {}
local function beehive_formspec(name, wx, wy, b1x, b1y, b2x, b2y)
wx = math_clamp((wx + math.random(-4,4)/10), 0, 11)
wy = math_clamp((wy + math.random(-4,4)/10), 0, 5)
b1x = math_clamp((b1x + math.random(-4,4)/10), 0, 11)
b1y = math_clamp((b1y + math.random(-4,4)/10), 0, 5)
b2x = math_clamp((b2x + math.random(-4,4)/10), 0, 11)
b2y = math_clamp((b2y + math.random(-4,4)/10), 0, 5)
local formspec =
'formspec_version[3]'..
'size[12,6]'..
'image[0,0;12,6;tasks_beehive_ui_bg.png]'..
'image_button['..wx..','..wy..';1,1;tasks_beehive_ui_wasp.png;thief;;true;false]'..
'image_button['..b1x..','..b1y..';1,1;tasks_beehive_ui_bee.png;bee;;true;false]'..
'image_button['..b2x..','..b2y..';1,1;tasks_beehive_ui_bee.png;bee;;true;false]'
minetest.show_formspec(name, 'tasks:beehive_bad', formspec)
minetest.after(.25, function()
if beehive[name] == 'true' then
beehive_formspec(name, wx, wy, b1x, b1y, b2x, b2y)
end
end)
end
minetest.register_node('tasks:beehive',{
description = 'Beehive',
drawtype = 'mesh',
mesh = 'tasks_beehive.obj',
tiles = {'tasks_beehive.png'},
paramtype = 'light',
paramtype2 = 'facedir',
selection_box = box,
collision_box = box,
groups = {breakable = 1, tasks=1},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string('infotext', 'Beehive')
meta:set_string('info_working', 'Beehive')
meta:set_string('info_repair', 'Distressed Beehive')
meta:set_string('status', 'good')
meta:set_int('time_min', 30)
meta:set_int('time_max', 90)
meta:set_int('xp', 5)
meta:set_int('level', 0)
end,
on_rightclick = function(pos, node, clicker)
local name = clicker:get_player_name()
local timer = minetest.get_node_timer(pos)
local meta = minetest.get_meta(pos)
local min = meta:get_int('time_min') or 30
local max = meta:get_int('time_max') or 60
local status = meta:get_string('status')
local random_number = math.random(min,max)
timer:start(random_number)
local map_id = lobby.game[name]
local sabotage_level = lobby.sabotage_level[map_id] or 5
local level = meta:get_int('level') or 0
if level < sabotage_level then
if status == 'good' then
minetest.show_formspec(name, 'tasks:beehive_good', formspec_good)
else
tasks.player_config[name] = pos
beehive[name] = 'true'
beehive_formspec(name, 6, 3, 2, 4, 9, 1)
end
else
minetest.chat_send_player(name, 'level is currently sabotaged, and you can\'t do this now.')
end
end,
on_timer = function(pos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local infotext = meta:get_string('info_repair')
meta:set_string('infotext', infotext)
meta:set_string('status', 'bad')
end,
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if formname == 'tasks:beehive_bad'then
if fields.thief then
beehive[name] = 'false'
local pos = tasks.player_config[name]
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local infotext = meta:get_string('info_working')
local xp = meta:get_int('xp')
meta:set_string('status', 'good')
meta:set_string('infotext', infotext)
tasks.only_add_xp(xp, name)
minetest.close_formspec(name, 'tasks:beehive_bad')
minetest.chat_send_player(name, 'Nice going, the queen thanks you!')
elseif fields.bee then
beehive[name] = 'false'
minetest.close_formspec(name, 'tasks:beehive_bad')
minetest.chat_send_player(name, 'Careful, you just killed a honeybee.')
elseif fields.quit then
beehive[name] = 'false'
end
end
end)

View File

@ -16,6 +16,7 @@ dofile(minetest.get_modpath('tasks')..'/items.lua')
dofile(minetest.get_modpath('tasks')..'/storage_locker.lua')
--Actual tasks
dofile(minetest.get_modpath('tasks')..'/beehive.lua')
dofile(minetest.get_modpath('tasks')..'/campfire.lua')
dofile(minetest.get_modpath('tasks')..'/code.lua')
dofile(minetest.get_modpath('tasks')..'/engine_0.lua')

View File

@ -0,0 +1,60 @@
# Blender v3.2.2 OBJ File: 'tasks.blend'
# www.blender.org
o BeeHive_Cube.017
v -0.437500 -0.500000 0.437500
v -0.437500 0.187500 0.437500
v -0.437500 -0.500000 -0.437500
v -0.437500 0.187500 -0.437500
v 0.437500 -0.500000 0.437500
v 0.437500 0.187500 0.437500
v 0.437500 -0.500000 -0.437500
v 0.437500 0.187500 -0.437500
v -0.500000 0.187500 0.500000
v -0.500000 0.375000 0.500000
v -0.500000 0.187500 -0.500000
v -0.500000 0.375000 -0.500000
v 0.500000 0.187500 0.500000
v 0.500000 0.375000 0.500000
v 0.500000 0.187500 -0.500000
v 0.500000 0.375000 -0.500000
vt 0.656250 0.000000
vt 0.656250 0.171875
vt 0.437500 0.171875
vt 0.437500 0.000000
vt 0.218750 0.171875
vt 0.218750 0.000000
vt 0.000000 0.171875
vt 0.000000 0.000000
vt 0.875000 0.000000
vt 0.875000 0.171875
vt 0.046875 1.000000
vt 0.046875 0.953125
vt 0.296875 0.953125
vt 0.296875 1.000000
vt 0.000000 0.703125
vt 0.046875 0.703125
vt 0.000000 0.953125
vt 0.343750 0.953125
vt 0.296875 0.703125
vt 0.343750 0.703125
vt 0.296875 0.656250
vt 0.046875 0.656250
vt 0.046875 0.406250
vt 0.296875 0.406250
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 3/4/2 4/3/2 8/5/2 7/6/2
f 7/6/3 8/5/3 6/7/3 5/8/3
f 5/9/4 6/10/4 2/2/4 1/1/4
f 11/11/2 12/12/2 16/13/2 15/14/2
f 9/15/1 10/16/1 12/12/1 11/17/1
f 15/18/3 16/13/3 14/19/3 13/20/3
f 13/21/4 14/19/4 10/16/4 9/22/4
f 11/23/5 15/24/5 13/21/5 9/22/5
f 16/13/6 12/12/6 10/16/6 14/19/6

View File

@ -19,8 +19,8 @@ end
local box = {
type = 'fixed',
fixed = {
{-.2, .4, -.2, .2, .5, .2},},}
fixed = {
{-.2, .4, -.2, .2, .5, .2}}}
minetest.register_node('tasks:smoke_detector_on',{
description = 'Smoke Detector',

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB