Re-organize the repository, Begin the minetest.conf file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.patch
|
22
LICENSE
@ -1,22 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 MinetestForFun
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
0
minetestforfun-bros/menu/header.png → menu/header.png
Executable file → Normal file
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
0
minetestforfun-bros/menu/icon.png → menu/icon.png
Executable file → Normal file
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
78
minetest.conf
Normal file
@ -0,0 +1,78 @@
|
||||
### GENERAL SETTINGS SERVER ###
|
||||
###############################
|
||||
name = Darcidride
|
||||
# 0 = none, 1 = errors and debug, 2 = action, 3 = info, 4 = verbose
|
||||
debug_log_level = 2
|
||||
# Désactivation de l'anti-cheat qui fait ce téléporter en arrière si l'on va trop vite
|
||||
disable_anticheat = true
|
||||
# Options pour le type du serveur
|
||||
creative_mode = false
|
||||
enable_damage = true
|
||||
disallow_empty_password = true
|
||||
server_dedicated = true
|
||||
# If true, actions are recorded for rollback
|
||||
enable_rollback_recording = true
|
||||
# Desactivate fire
|
||||
disable_fire = true
|
||||
mg_flags = nocaves, nodungeons
|
||||
# no mapgen, and no lua mod for mapgen
|
||||
mg_name = singlenode
|
||||
# Activated the minimap usage if true
|
||||
enable_minimap = true
|
||||
|
||||
### SERVER PERFORMANCE SETTINGS ###
|
||||
###################################
|
||||
max_block_send_distance = 8
|
||||
max_simultaneous_block_sends_per_client = 10000
|
||||
max_simultaneous_block_sends_server_total = 10000
|
||||
active_block_range = 1
|
||||
server_map_save_interval = 300
|
||||
|
||||
### Game balance ###
|
||||
####################
|
||||
movement_speed_walk = 5
|
||||
movement_speed_crouch = 2
|
||||
time_speed = 0
|
||||
|
||||
### SERVER ANNOUNCEMENT ###
|
||||
###########################
|
||||
server_announce = 1
|
||||
server_url = http://minetestforfun.com/
|
||||
server_name = MinetestForFun BROS
|
||||
server_description = Bros server hosted by MinetestForFun Team.
|
||||
motd = Welcome to MinetestForFun Team Bros server.
|
||||
max_users = 20
|
||||
serverlist_url = servers.minetest.net
|
||||
server_address = 212.83.148.178
|
||||
#port = 300??
|
||||
strict_protocol_version_checking = false
|
||||
#Sert à quoi ?
|
||||
#remote_media = http://hugo.pro/minetest-data/
|
||||
|
||||
### Mods ###
|
||||
############
|
||||
# Mobs
|
||||
#spawn_hostile_mobs = false
|
||||
# HudBars
|
||||
#hudbars_sorting = health=0,breath=1,hunger=2,thirst=3
|
||||
# Random_Messages
|
||||
#random_messages_interval = 900
|
||||
# Bottom layout of death blocks
|
||||
bottom_layout = -100
|
||||
|
||||
### IRC CHAT ###
|
||||
################
|
||||
#irc.server = digitalaudioconcepts.com
|
||||
#irc.channel = #minetestforfun-hg
|
||||
#irc.interval = 2.0
|
||||
#irc.nick = MFFSB-Bot
|
||||
# irc.password = # Empty because no channel password
|
||||
#secure.trusted_mods = irc # Mod security
|
||||
#irc.debug = false
|
||||
#irc.disable_auto_connect = false
|
||||
#irc.disable_auto_join = false
|
||||
#irc.send_join_part = true
|
||||
|
||||
### TIME TO REMOVE DROPPED ITEMS ###
|
||||
####################################
|
||||
#item_entity_ttl = 30
|
@ -1 +0,0 @@
|
||||
name = minetestforfun-bros
|
@ -1,9 +0,0 @@
|
||||
# Game configuration file
|
||||
mg_name = singlenode
|
||||
time_speed = 0
|
||||
|
||||
# Bottom layout of death blocks
|
||||
bottom_layout = -100
|
||||
|
||||
# Desactivate fire
|
||||
disable_fire = true
|
0
minetestforfun-bros/mods/WorldEdit/.gitignore → mods/WorldEdit/.gitignore
vendored
Executable file → Normal file
764
minetestforfun-bros/mods/WorldEdit/ChatCommands.md → mods/WorldEdit/ChatCommands.md
Executable file → Normal file
@ -1,382 +1,382 @@
|
||||
Chat Commands
|
||||
-------------
|
||||
For more information, see the [README](README.md).
|
||||
|
||||
Many commands also have shorter names that can be typed faster. For example, if we wanted to use `//move ? 5`, we could instead type `//m ? 5`. All shortened names are listed below:
|
||||
|
||||
| Short Name | Original Name |
|
||||
|:-----------|:-------------------|
|
||||
| `//i` | `//inspect` |
|
||||
| `//rst` | `//reset` |
|
||||
| `//mk` | `//mark` |
|
||||
| `//umk` | `//unmark` |
|
||||
| `//1` | `//pos1` |
|
||||
| `//2` | `//pos2` |
|
||||
| `//fp` | `//fixedpos` |
|
||||
| `//v` | `//volume` |
|
||||
| `//s` | `//set` |
|
||||
| `//r` | `//replace` |
|
||||
| `//ri` | `//replaceinverse` |
|
||||
| `//hspr` | `//hollowsphere` |
|
||||
| `//spr` | `//sphere` |
|
||||
| `//hdo` | `//hollowdome` |
|
||||
| `//do` | `//dome` |
|
||||
| `//hcyl` | `//hollowcylinder` |
|
||||
|
||||
### `//about`
|
||||
|
||||
Get information about the mod.
|
||||
|
||||
//about
|
||||
|
||||
### `//inspect on/off/1/0/true/false/yes/no/enable/disable/<blank>`
|
||||
|
||||
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`
|
||||
|
||||
Reset the region so that it is empty.
|
||||
|
||||
//reset
|
||||
|
||||
### `//mark`
|
||||
|
||||
Show markers at the region positions.
|
||||
|
||||
//mark
|
||||
|
||||
### `//unmark`
|
||||
|
||||
Hide markers if currently shown.
|
||||
|
||||
//unmark
|
||||
|
||||
### `//pos1`
|
||||
|
||||
Set WorldEdit region position 1 to the player's location.
|
||||
|
||||
//pos1
|
||||
|
||||
### `//pos2`
|
||||
|
||||
Set WorldEdit region position 2 to the player's location.
|
||||
|
||||
//pos2
|
||||
|
||||
### `//p set/set1/set2/get`
|
||||
|
||||
Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region.
|
||||
|
||||
//p set
|
||||
//p set1
|
||||
//p set2
|
||||
//p get
|
||||
|
||||
### `//fixedpos set1 x y z`
|
||||
|
||||
Set a WorldEdit region position to the position at (`<x>`, `<y>`, `<z>`).
|
||||
|
||||
//fixedpos set1 0 0 0
|
||||
//fixedpos set1 -30 5 28
|
||||
//fixedpos set2 1004 -200 432
|
||||
|
||||
### `//volume`
|
||||
|
||||
Display the volume of the current WorldEdit region.
|
||||
|
||||
//volume
|
||||
|
||||
### `//deleteblocks`
|
||||
|
||||
Delete the MapBlocks (16x16x16 units) that contain the selected region. This means that mapgen will be invoked for that area. As only whole MapBlocks get removed, the deleted area is usually larger than the selected one. Also, mapgen can trigger mechanisms like mud reflow or cavegen, which affects nodes (up to 112 nodes away) outside the MapBlock, so dont use this near buildings.
|
||||
|
||||
//deleteblocks
|
||||
|
||||
### `//set <node>`
|
||||
|
||||
Set the current WorldEdit region to `<node>`.
|
||||
|
||||
//set air
|
||||
//set cactus
|
||||
//set Blue Lightstone
|
||||
//set dirt with grass
|
||||
|
||||
### `//mix <node1> ...`
|
||||
|
||||
Fill the current WorldEdit region with a random mix of `<node1>`, `...`.
|
||||
|
||||
//mix air
|
||||
//mix cactus stone glass sandstone
|
||||
//mix Bronze
|
||||
//mix default:cobble air
|
||||
|
||||
### `//replace <search node> <replace node>`
|
||||
|
||||
Replace all instances of `<search node>` with `<replace node>` in the current WorldEdit region.
|
||||
|
||||
//replace Cobblestone air
|
||||
//replace lightstone_blue glass
|
||||
//replace dirt Bronze Block
|
||||
//replace mesecons:wire_00000000_off flowers:flower_tulip
|
||||
|
||||
### `//replaceinverse <search node> <replace node>`
|
||||
|
||||
Replace all nodes other than `<search node>` with `<replace node>` in the current WorldEdit region.
|
||||
|
||||
//replaceinverse Cobblestone air
|
||||
//replaceinverse flowers:flower_waterlily glass
|
||||
//replaceinverse dirt Bronze Block
|
||||
//replaceinverse mesecons:wire_00000000_off flowers:flower_tulip
|
||||
|
||||
### `//hollowsphere <radius> <node>`
|
||||
|
||||
Add hollow sphere centered at WorldEdit position 1 with radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//hollowsphere 5 Diamond Block
|
||||
//hollowsphere 12 glass
|
||||
//hollowsphere 17 mesecons:wire_00000000_off
|
||||
|
||||
### `//sphere <radius> <node>`
|
||||
|
||||
Add sphere centered at WorldEdit position 1 with radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//sphere 5 Diamond Block
|
||||
//sphere 12 glass
|
||||
//sphere 17 mesecons:wire_00000000_off
|
||||
|
||||
### `//hollowdome <radius> <node>`
|
||||
|
||||
Add hollow dome centered at WorldEdit position 1 with radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//hollowdome 5 Diamond Block
|
||||
//hollowdome -12 glass
|
||||
//hollowdome 17 mesecons:wire_00000000_off
|
||||
|
||||
### `//dome <radius> <node>`
|
||||
|
||||
Add dome centered at WorldEdit position 1 with radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//dome 5 Diamond Block
|
||||
//dome -12 glass
|
||||
//dome 17 mesecons:wire_00000000_off
|
||||
|
||||
### `//hollowcylinder x/y/z/? <length> <radius> <node>`
|
||||
|
||||
Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length `<length>` and radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//hollowcylinder x +5 8 Bronze Block
|
||||
//hollowcylinder y 28 10 glass
|
||||
//hollowcylinder z -12 3 mesecons:wire_00000000_off
|
||||
//hollowcylinder ? 2 4 default:stone
|
||||
|
||||
### `//cylinder x/y/z/? <length> <radius> <node>`
|
||||
|
||||
Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length `<length>` and radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//cylinder x +5 8 Bronze Block
|
||||
//cylinder y 28 10 glass
|
||||
//cylinder z -12 3 mesecons:wire_00000000_off
|
||||
//cylinder ? 2 4 default:stone
|
||||
|
||||
### `//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>`.
|
||||
|
||||
//pyramid x 8 Diamond Block
|
||||
//pyramid y -5 glass
|
||||
//pyramid z 2 mesecons:wire_00000000_off
|
||||
//pyramid ? 12 mesecons:wire_00000000_off
|
||||
|
||||
### `//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>`.
|
||||
|
||||
//spiral 20 5 3 Diamond Block
|
||||
//spiral 5 2 1 glass
|
||||
//spiral 7 1 5 mesecons:wire_00000000_off
|
||||
|
||||
### `//copy x/y/z/? <amount>`
|
||||
|
||||
Copy the current WorldEdit region along the x/y/z/? axis by `<amount>` nodes.
|
||||
|
||||
//copy x 15
|
||||
//copy y -7
|
||||
//copy z +4
|
||||
//copy ? 8
|
||||
|
||||
### `//move x/y/z/? <amount>`
|
||||
|
||||
Move the current WorldEdit positions and region along the x/y/z/? axis by `<amount>` nodes.
|
||||
|
||||
//move x 15
|
||||
//move y -7
|
||||
//move z +4
|
||||
//move ? -1
|
||||
|
||||
### `//stack x/y/z/? <count>`
|
||||
|
||||
Stack the current WorldEdit region along the x/y/z/? axis `<count>` times.
|
||||
|
||||
//stack x 3
|
||||
//stack y -1
|
||||
//stack z +5
|
||||
//stack ? 12
|
||||
|
||||
### `//stack2 <count> <x> <y> <z>`
|
||||
|
||||
Stack the current WorldEdit region `<count>` times by offset `<x>`, `<y>`, `<z>`.
|
||||
|
||||
//stack2 5 3 8 2
|
||||
//stack2 1 -1 -1 -1
|
||||
|
||||
### `//scale <factor>`
|
||||
|
||||
Scale the current WorldEdit positions and region by a factor of positive integer `<factor>` with position 1 as the origin.
|
||||
|
||||
//scale 2
|
||||
//scale 1
|
||||
//scale 10
|
||||
|
||||
### `//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 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 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 x 90
|
||||
//rotate y 180
|
||||
//rotate z 270
|
||||
//rotate ? -90
|
||||
|
||||
### `//orient <angle>`
|
||||
|
||||
Rotate oriented nodes in the current WorldEdit region around the Y axis by angle `<angle>` (90 degree increment)
|
||||
|
||||
//orient 90
|
||||
//orient 180
|
||||
//orient 270
|
||||
//orient -90
|
||||
|
||||
### `//fixlight`
|
||||
|
||||
Fixes the lighting in the current WorldEdit region.
|
||||
|
||||
//fixlight
|
||||
|
||||
### `//hide`
|
||||
|
||||
Hide all nodes in the current WorldEdit region non-destructively.
|
||||
|
||||
//hide
|
||||
|
||||
### `//suppress <node>`
|
||||
|
||||
Suppress all <node> in the current WorldEdit region non-destructively.
|
||||
|
||||
//suppress Diamond Block
|
||||
//suppress glass
|
||||
//suppress mesecons:wire_00000000_off
|
||||
|
||||
### `//highlight <node>`
|
||||
|
||||
Highlight <node> in the current WorldEdit region by hiding everything else non-destructively.
|
||||
|
||||
//highlight Diamond Block
|
||||
//highlight glass
|
||||
//highlight mesecons:wire_00000000_off
|
||||
|
||||
### `//restore`
|
||||
|
||||
Restores nodes hidden with WorldEdit in the current WorldEdit region.
|
||||
|
||||
//restore
|
||||
|
||||
### `//save <file>`
|
||||
|
||||
Save the current WorldEdit region to "(world folder)/schems/`<file>`.we".
|
||||
|
||||
//save some random filename
|
||||
//save huge_base
|
||||
|
||||
### `//allocate <file>`
|
||||
|
||||
Set the region defined by nodes from "(world folder)/schems/`<file>`.we" as the current WorldEdit region.
|
||||
|
||||
//allocate some random filename
|
||||
//allocate huge_base
|
||||
|
||||
### `//load <file>`
|
||||
|
||||
Load nodes from "(world folder)/schems/`<file>`.we" with position 1 of the current WorldEdit region as the origin.
|
||||
|
||||
//load some random filename
|
||||
//load huge_base
|
||||
|
||||
### `//lua <code>`
|
||||
|
||||
Executes `<code>` as a Lua chunk in the global namespace.
|
||||
|
||||
//lua worldedit.pos1["singleplayer"] = {x=0, y=0, z=0}
|
||||
//lua worldedit.rotate(worldedit.pos1["singleplayer"], worldedit.pos2["singleplayer"], "y", 90)
|
||||
|
||||
### `//luatransform <code>`
|
||||
|
||||
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"})
|
||||
|
||||
### `//mtschemcreate <file>`
|
||||
|
||||
Save the current WorldEdit region using the Minetest Schematic format to "(world folder)/schems/`<file>`.mts".
|
||||
|
||||
//mtschemcreate some random filename
|
||||
//mtschemcreate huge_base
|
||||
|
||||
### `//mtschemplace <file>`
|
||||
|
||||
Load nodes from "(world folder)/schems/`<file>`.mts" with position 1 of the current WorldEdit region as the origin.
|
||||
|
||||
//mtschemplace some random filename
|
||||
//mtschemplace huge_base
|
||||
|
||||
### `//mtschemprob start/finish/get`
|
||||
|
||||
After using `//mtschemprob start` all nodes punched will bring up a text field where a probablity can be entered.
|
||||
This mode can be left with `//mtschemprob finish`. `//mtschemprob get` will display the probabilities saved for the nodes.
|
||||
|
||||
//mtschemprob get
|
||||
|
||||
### `//clearobjects`
|
||||
|
||||
Clears all objects within the WorldEdit region.
|
||||
|
||||
//clearobjects
|
||||
Chat Commands
|
||||
-------------
|
||||
For more information, see the [README](README.md).
|
||||
|
||||
Many commands also have shorter names that can be typed faster. For example, if we wanted to use `//move ? 5`, we could instead type `//m ? 5`. All shortened names are listed below:
|
||||
|
||||
| Short Name | Original Name |
|
||||
|:-----------|:-------------------|
|
||||
| `//i` | `//inspect` |
|
||||
| `//rst` | `//reset` |
|
||||
| `//mk` | `//mark` |
|
||||
| `//umk` | `//unmark` |
|
||||
| `//1` | `//pos1` |
|
||||
| `//2` | `//pos2` |
|
||||
| `//fp` | `//fixedpos` |
|
||||
| `//v` | `//volume` |
|
||||
| `//s` | `//set` |
|
||||
| `//r` | `//replace` |
|
||||
| `//ri` | `//replaceinverse` |
|
||||
| `//hspr` | `//hollowsphere` |
|
||||
| `//spr` | `//sphere` |
|
||||
| `//hdo` | `//hollowdome` |
|
||||
| `//do` | `//dome` |
|
||||
| `//hcyl` | `//hollowcylinder` |
|
||||
|
||||
### `//about`
|
||||
|
||||
Get information about the mod.
|
||||
|
||||
//about
|
||||
|
||||
### `//inspect on/off/1/0/true/false/yes/no/enable/disable/<blank>`
|
||||
|
||||
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`
|
||||
|
||||
Reset the region so that it is empty.
|
||||
|
||||
//reset
|
||||
|
||||
### `//mark`
|
||||
|
||||
Show markers at the region positions.
|
||||
|
||||
//mark
|
||||
|
||||
### `//unmark`
|
||||
|
||||
Hide markers if currently shown.
|
||||
|
||||
//unmark
|
||||
|
||||
### `//pos1`
|
||||
|
||||
Set WorldEdit region position 1 to the player's location.
|
||||
|
||||
//pos1
|
||||
|
||||
### `//pos2`
|
||||
|
||||
Set WorldEdit region position 2 to the player's location.
|
||||
|
||||
//pos2
|
||||
|
||||
### `//p set/set1/set2/get`
|
||||
|
||||
Set WorldEdit region, WorldEdit position 1, or WorldEdit position 2 by punching nodes, or display the current WorldEdit region.
|
||||
|
||||
//p set
|
||||
//p set1
|
||||
//p set2
|
||||
//p get
|
||||
|
||||
### `//fixedpos set1 x y z`
|
||||
|
||||
Set a WorldEdit region position to the position at (`<x>`, `<y>`, `<z>`).
|
||||
|
||||
//fixedpos set1 0 0 0
|
||||
//fixedpos set1 -30 5 28
|
||||
//fixedpos set2 1004 -200 432
|
||||
|
||||
### `//volume`
|
||||
|
||||
Display the volume of the current WorldEdit region.
|
||||
|
||||
//volume
|
||||
|
||||
### `//deleteblocks`
|
||||
|
||||
Delete the MapBlocks (16x16x16 units) that contain the selected region. This means that mapgen will be invoked for that area. As only whole MapBlocks get removed, the deleted area is usually larger than the selected one. Also, mapgen can trigger mechanisms like mud reflow or cavegen, which affects nodes (up to 112 nodes away) outside the MapBlock, so dont use this near buildings.
|
||||
|
||||
//deleteblocks
|
||||
|
||||
### `//set <node>`
|
||||
|
||||
Set the current WorldEdit region to `<node>`.
|
||||
|
||||
//set air
|
||||
//set cactus
|
||||
//set Blue Lightstone
|
||||
//set dirt with grass
|
||||
|
||||
### `//mix <node1> ...`
|
||||
|
||||
Fill the current WorldEdit region with a random mix of `<node1>`, `...`.
|
||||
|
||||
//mix air
|
||||
//mix cactus stone glass sandstone
|
||||
//mix Bronze
|
||||
//mix default:cobble air
|
||||
|
||||
### `//replace <search node> <replace node>`
|
||||
|
||||
Replace all instances of `<search node>` with `<replace node>` in the current WorldEdit region.
|
||||
|
||||
//replace Cobblestone air
|
||||
//replace lightstone_blue glass
|
||||
//replace dirt Bronze Block
|
||||
//replace mesecons:wire_00000000_off flowers:flower_tulip
|
||||
|
||||
### `//replaceinverse <search node> <replace node>`
|
||||
|
||||
Replace all nodes other than `<search node>` with `<replace node>` in the current WorldEdit region.
|
||||
|
||||
//replaceinverse Cobblestone air
|
||||
//replaceinverse flowers:flower_waterlily glass
|
||||
//replaceinverse dirt Bronze Block
|
||||
//replaceinverse mesecons:wire_00000000_off flowers:flower_tulip
|
||||
|
||||
### `//hollowsphere <radius> <node>`
|
||||
|
||||
Add hollow sphere centered at WorldEdit position 1 with radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//hollowsphere 5 Diamond Block
|
||||
//hollowsphere 12 glass
|
||||
//hollowsphere 17 mesecons:wire_00000000_off
|
||||
|
||||
### `//sphere <radius> <node>`
|
||||
|
||||
Add sphere centered at WorldEdit position 1 with radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//sphere 5 Diamond Block
|
||||
//sphere 12 glass
|
||||
//sphere 17 mesecons:wire_00000000_off
|
||||
|
||||
### `//hollowdome <radius> <node>`
|
||||
|
||||
Add hollow dome centered at WorldEdit position 1 with radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//hollowdome 5 Diamond Block
|
||||
//hollowdome -12 glass
|
||||
//hollowdome 17 mesecons:wire_00000000_off
|
||||
|
||||
### `//dome <radius> <node>`
|
||||
|
||||
Add dome centered at WorldEdit position 1 with radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//dome 5 Diamond Block
|
||||
//dome -12 glass
|
||||
//dome 17 mesecons:wire_00000000_off
|
||||
|
||||
### `//hollowcylinder x/y/z/? <length> <radius> <node>`
|
||||
|
||||
Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length `<length>` and radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//hollowcylinder x +5 8 Bronze Block
|
||||
//hollowcylinder y 28 10 glass
|
||||
//hollowcylinder z -12 3 mesecons:wire_00000000_off
|
||||
//hollowcylinder ? 2 4 default:stone
|
||||
|
||||
### `//cylinder x/y/z/? <length> <radius> <node>`
|
||||
|
||||
Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length `<length>` and radius `<radius>`, composed of `<node>`.
|
||||
|
||||
//cylinder x +5 8 Bronze Block
|
||||
//cylinder y 28 10 glass
|
||||
//cylinder z -12 3 mesecons:wire_00000000_off
|
||||
//cylinder ? 2 4 default:stone
|
||||
|
||||
### `//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>`.
|
||||
|
||||
//pyramid x 8 Diamond Block
|
||||
//pyramid y -5 glass
|
||||
//pyramid z 2 mesecons:wire_00000000_off
|
||||
//pyramid ? 12 mesecons:wire_00000000_off
|
||||
|
||||
### `//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>`.
|
||||
|
||||
//spiral 20 5 3 Diamond Block
|
||||
//spiral 5 2 1 glass
|
||||
//spiral 7 1 5 mesecons:wire_00000000_off
|
||||
|
||||
### `//copy x/y/z/? <amount>`
|
||||
|
||||
Copy the current WorldEdit region along the x/y/z/? axis by `<amount>` nodes.
|
||||
|
||||
//copy x 15
|
||||
//copy y -7
|
||||
//copy z +4
|
||||
//copy ? 8
|
||||
|
||||
### `//move x/y/z/? <amount>`
|
||||
|
||||
Move the current WorldEdit positions and region along the x/y/z/? axis by `<amount>` nodes.
|
||||
|
||||
//move x 15
|
||||
//move y -7
|
||||
//move z +4
|
||||
//move ? -1
|
||||
|
||||
### `//stack x/y/z/? <count>`
|
||||
|
||||
Stack the current WorldEdit region along the x/y/z/? axis `<count>` times.
|
||||
|
||||
//stack x 3
|
||||
//stack y -1
|
||||
//stack z +5
|
||||
//stack ? 12
|
||||
|
||||
### `//stack2 <count> <x> <y> <z>`
|
||||
|
||||
Stack the current WorldEdit region `<count>` times by offset `<x>`, `<y>`, `<z>`.
|
||||
|
||||
//stack2 5 3 8 2
|
||||
//stack2 1 -1 -1 -1
|
||||
|
||||
### `//scale <factor>`
|
||||
|
||||
Scale the current WorldEdit positions and region by a factor of positive integer `<factor>` with position 1 as the origin.
|
||||
|
||||
//scale 2
|
||||
//scale 1
|
||||
//scale 10
|
||||
|
||||
### `//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 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 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 x 90
|
||||
//rotate y 180
|
||||
//rotate z 270
|
||||
//rotate ? -90
|
||||
|
||||
### `//orient <angle>`
|
||||
|
||||
Rotate oriented nodes in the current WorldEdit region around the Y axis by angle `<angle>` (90 degree increment)
|
||||
|
||||
//orient 90
|
||||
//orient 180
|
||||
//orient 270
|
||||
//orient -90
|
||||
|
||||
### `//fixlight`
|
||||
|
||||
Fixes the lighting in the current WorldEdit region.
|
||||
|
||||
//fixlight
|
||||
|
||||
### `//hide`
|
||||
|
||||
Hide all nodes in the current WorldEdit region non-destructively.
|
||||
|
||||
//hide
|
||||
|
||||
### `//suppress <node>`
|
||||
|
||||
Suppress all <node> in the current WorldEdit region non-destructively.
|
||||
|
||||
//suppress Diamond Block
|
||||
//suppress glass
|
||||
//suppress mesecons:wire_00000000_off
|
||||
|
||||
### `//highlight <node>`
|
||||
|
||||
Highlight <node> in the current WorldEdit region by hiding everything else non-destructively.
|
||||
|
||||
//highlight Diamond Block
|
||||
//highlight glass
|
||||
//highlight mesecons:wire_00000000_off
|
||||
|
||||
### `//restore`
|
||||
|
||||
Restores nodes hidden with WorldEdit in the current WorldEdit region.
|
||||
|
||||
//restore
|
||||
|
||||
### `//save <file>`
|
||||
|
||||
Save the current WorldEdit region to "(world folder)/schems/`<file>`.we".
|
||||
|
||||
//save some random filename
|
||||
//save huge_base
|
||||
|
||||
### `//allocate <file>`
|
||||
|
||||
Set the region defined by nodes from "(world folder)/schems/`<file>`.we" as the current WorldEdit region.
|
||||
|
||||
//allocate some random filename
|
||||
//allocate huge_base
|
||||
|
||||
### `//load <file>`
|
||||
|
||||
Load nodes from "(world folder)/schems/`<file>`.we" with position 1 of the current WorldEdit region as the origin.
|
||||
|
||||
//load some random filename
|
||||
//load huge_base
|
||||
|
||||
### `//lua <code>`
|
||||
|
||||
Executes `<code>` as a Lua chunk in the global namespace.
|
||||
|
||||
//lua worldedit.pos1["singleplayer"] = {x=0, y=0, z=0}
|
||||
//lua worldedit.rotate(worldedit.pos1["singleplayer"], worldedit.pos2["singleplayer"], "y", 90)
|
||||
|
||||
### `//luatransform <code>`
|
||||
|
||||
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"})
|
||||
|
||||
### `//mtschemcreate <file>`
|
||||
|
||||
Save the current WorldEdit region using the Minetest Schematic format to "(world folder)/schems/`<file>`.mts".
|
||||
|
||||
//mtschemcreate some random filename
|
||||
//mtschemcreate huge_base
|
||||
|
||||
### `//mtschemplace <file>`
|
||||
|
||||
Load nodes from "(world folder)/schems/`<file>`.mts" with position 1 of the current WorldEdit region as the origin.
|
||||
|
||||
//mtschemplace some random filename
|
||||
//mtschemplace huge_base
|
||||
|
||||
### `//mtschemprob start/finish/get`
|
||||
|
||||
After using `//mtschemprob start` all nodes punched will bring up a text field where a probablity can be entered.
|
||||
This mode can be left with `//mtschemprob finish`. `//mtschemprob get` will display the probabilities saved for the nodes.
|
||||
|
||||
//mtschemprob get
|
||||
|
||||
### `//clearobjects`
|
||||
|
||||
Clears all objects within the WorldEdit region.
|
||||
|
||||
//clearobjects
|
0
minetestforfun-bros/mods/WorldEdit/LICENSE.txt → mods/WorldEdit/LICENSE.txt
Executable file → Normal file
0
minetestforfun-bros/mods/WorldEdit/README.md → mods/WorldEdit/README.md
Executable file → Normal file
238
minetestforfun-bros/mods/WorldEdit/Tutorial.md → mods/WorldEdit/Tutorial.md
Executable file → Normal file
@ -1,120 +1,120 @@
|
||||
WorldEdit Tutorial
|
||||
==================
|
||||
This is a step-by-step tutorial outlining the basic usage of WorldEdit. For more information, see the [README](README.md).
|
||||
|
||||
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 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.
|
||||
* How to walk, jump, and climb.
|
||||
* How to dig, place, and punch blocks.
|
||||
* One of the following:
|
||||
* How to type into the chat and read text from it.
|
||||
* How to open the inventory screen and press buttons on it.
|
||||
|
||||
Overview
|
||||
--------
|
||||
WorldEdit has a "region", which is simply a cuboid area defined by two markers, both of which the player can move around. Every player can have their own region with their own two markers.
|
||||
|
||||
WorldEdit GUI buttons and chat commands generally work inside the region selected, or around the first marker.
|
||||
|
||||
If you are using the chat commands, follow the steps under **Chat Commands**. If you are using the WorldEdit GUI, follow the steps under **WorldEdit GUI**.
|
||||
|
||||
Step 1: Selecting a region
|
||||
--------------------------
|
||||
### Chat Commands
|
||||
|
||||
In the chat prompt, enter `//p set`. In the chat, you are prompted to punch two nodes to set the positions of the two markers.
|
||||
|
||||
Punch a nearby node. Be careful of breakable ones such as torches. A black cube reading "1" will appear around the node. This is the marker for WorldEdit position 1.
|
||||
|
||||
Walk away from the node you just punched. Now, punch another node. A black cube reading "2" will appear around the node. This is the marker for WorldEdit position 2.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
Open the main WorldEdit GUI from your inventory screen. The icon looks like a globe with a red dot in the center.
|
||||
|
||||
Press the "Get/Set Positions" button. On the new screen, press the "Set Position 1" button. The inventory screen should close.
|
||||
|
||||
Punch a nearby node. Be careful of breakable ones such as torches. A black cube reading "1" will appear around the node. This is the marker for WorldEdit position 1.
|
||||
|
||||
Walk away from the node you just punched. Open your inventory again. It should be on the same page as it was before.
|
||||
|
||||
Press the "Set Position 2" button. The inventory screen should close.
|
||||
|
||||
Now, punch another node. A black cube reading "2" will appear around the node. This is the marker for WorldEdit position 2.
|
||||
|
||||
Step 2: Region commands
|
||||
-----------------------
|
||||
### Chat Commands
|
||||
|
||||
In the chat prompt, enter `//set mese`. In the chat, you will see a message showing the number of nodes set after a small delay.
|
||||
|
||||
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`.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
Open the main WorldEdit GUI from your inventory screen.
|
||||
|
||||
Press the "Set Nodes" button. You should see a new screen with various options for setting nodes.
|
||||
|
||||
Enter "mese" in the "Name" field. Press Search if you would like to see what the node you just entered looks like.
|
||||
|
||||
Press the "Set Nodes" button on this screen. In the chat, you will see a message showing the number of nodes set after a small delay.
|
||||
|
||||
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".
|
||||
|
||||
Step 3: Position commands
|
||||
-------------------------
|
||||
### Chat Commands
|
||||
|
||||
In the chat prompt, enter `//hollowdome 30 glass`. In the chat, you will see a message showing the number of nodes set after a small delay.
|
||||
|
||||
Look around marker 1: it is now surrounded by a hollow glass dome!
|
||||
|
||||
The `//hollowdome <radius> <node>` command creates a hollow dome centered around marker 1, made of any node you want. It is a position-oriented command, which means it works around marker 1 and can go outside the WorldEdit region.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
Open the main WorldEdit GUI from your inventory screen.
|
||||
|
||||
Press the "Sphere/Dome" button. You should see a new screen with various options for making spheres or domes.
|
||||
|
||||
Enter "glass" in the "Name" field. Press Search if you would like to see what the node you just entered looks like.
|
||||
|
||||
Enter "30" in the "Radius" field.
|
||||
|
||||
Press the "Hollow Dome" button on this screen. In the chat, you will see a message showing the number of nodes added after a small delay.
|
||||
|
||||
Look around marker 1: it is now surrounded by a hollow glass dome!
|
||||
|
||||
The "Hollow Dome" function creates a hollow dome centered around marker 1, made of any node you want. It is a position-oriented command, which means it works around marker 1 and can go outside the WorldEdit region.
|
||||
|
||||
Step 4: Other commands
|
||||
----------------------
|
||||
### Chat Commands
|
||||
|
||||
There are many more commands than what is shown here. See the [Chat Commands Reference](ChatCommands.md) for a detailed list of them, along with descriptions and examples for every single one.
|
||||
|
||||
If you're in-game and forgot how a command works, just use the `/help <command name>` command, without the first forward slash. For example, to see some information about the `//set <node>` command mentioned earlier, simply use `/help /set`.
|
||||
|
||||
A very useful command to check out is the `//save <schematic>` command, which can save everything inside the WorldEdit region to a file, stored on the computer hosting the server (the player's computer, in single player mode). You can then later use `//load <schematic>` to load the data in a file into a world, even another world on another computer.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
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.
|
||||
|
||||
WorldEdit Tutorial
|
||||
==================
|
||||
This is a step-by-step tutorial outlining the basic usage of WorldEdit. For more information, see the [README](README.md).
|
||||
|
||||
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 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.
|
||||
* How to walk, jump, and climb.
|
||||
* How to dig, place, and punch blocks.
|
||||
* One of the following:
|
||||
* How to type into the chat and read text from it.
|
||||
* How to open the inventory screen and press buttons on it.
|
||||
|
||||
Overview
|
||||
--------
|
||||
WorldEdit has a "region", which is simply a cuboid area defined by two markers, both of which the player can move around. Every player can have their own region with their own two markers.
|
||||
|
||||
WorldEdit GUI buttons and chat commands generally work inside the region selected, or around the first marker.
|
||||
|
||||
If you are using the chat commands, follow the steps under **Chat Commands**. If you are using the WorldEdit GUI, follow the steps under **WorldEdit GUI**.
|
||||
|
||||
Step 1: Selecting a region
|
||||
--------------------------
|
||||
### Chat Commands
|
||||
|
||||
In the chat prompt, enter `//p set`. In the chat, you are prompted to punch two nodes to set the positions of the two markers.
|
||||
|
||||
Punch a nearby node. Be careful of breakable ones such as torches. A black cube reading "1" will appear around the node. This is the marker for WorldEdit position 1.
|
||||
|
||||
Walk away from the node you just punched. Now, punch another node. A black cube reading "2" will appear around the node. This is the marker for WorldEdit position 2.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
Open the main WorldEdit GUI from your inventory screen. The icon looks like a globe with a red dot in the center.
|
||||
|
||||
Press the "Get/Set Positions" button. On the new screen, press the "Set Position 1" button. The inventory screen should close.
|
||||
|
||||
Punch a nearby node. Be careful of breakable ones such as torches. A black cube reading "1" will appear around the node. This is the marker for WorldEdit position 1.
|
||||
|
||||
Walk away from the node you just punched. Open your inventory again. It should be on the same page as it was before.
|
||||
|
||||
Press the "Set Position 2" button. The inventory screen should close.
|
||||
|
||||
Now, punch another node. A black cube reading "2" will appear around the node. This is the marker for WorldEdit position 2.
|
||||
|
||||
Step 2: Region commands
|
||||
-----------------------
|
||||
### Chat Commands
|
||||
|
||||
In the chat prompt, enter `//set mese`. In the chat, you will see a message showing the number of nodes set after a small delay.
|
||||
|
||||
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`.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
Open the main WorldEdit GUI from your inventory screen.
|
||||
|
||||
Press the "Set Nodes" button. You should see a new screen with various options for setting nodes.
|
||||
|
||||
Enter "mese" in the "Name" field. Press Search if you would like to see what the node you just entered looks like.
|
||||
|
||||
Press the "Set Nodes" button on this screen. In the chat, you will see a message showing the number of nodes set after a small delay.
|
||||
|
||||
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".
|
||||
|
||||
Step 3: Position commands
|
||||
-------------------------
|
||||
### Chat Commands
|
||||
|
||||
In the chat prompt, enter `//hollowdome 30 glass`. In the chat, you will see a message showing the number of nodes set after a small delay.
|
||||
|
||||
Look around marker 1: it is now surrounded by a hollow glass dome!
|
||||
|
||||
The `//hollowdome <radius> <node>` command creates a hollow dome centered around marker 1, made of any node you want. It is a position-oriented command, which means it works around marker 1 and can go outside the WorldEdit region.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
Open the main WorldEdit GUI from your inventory screen.
|
||||
|
||||
Press the "Sphere/Dome" button. You should see a new screen with various options for making spheres or domes.
|
||||
|
||||
Enter "glass" in the "Name" field. Press Search if you would like to see what the node you just entered looks like.
|
||||
|
||||
Enter "30" in the "Radius" field.
|
||||
|
||||
Press the "Hollow Dome" button on this screen. In the chat, you will see a message showing the number of nodes added after a small delay.
|
||||
|
||||
Look around marker 1: it is now surrounded by a hollow glass dome!
|
||||
|
||||
The "Hollow Dome" function creates a hollow dome centered around marker 1, made of any node you want. It is a position-oriented command, which means it works around marker 1 and can go outside the WorldEdit region.
|
||||
|
||||
Step 4: Other commands
|
||||
----------------------
|
||||
### Chat Commands
|
||||
|
||||
There are many more commands than what is shown here. See the [Chat Commands Reference](ChatCommands.md) for a detailed list of them, along with descriptions and examples for every single one.
|
||||
|
||||
If you're in-game and forgot how a command works, just use the `/help <command name>` command, without the first forward slash. For example, to see some information about the `//set <node>` command mentioned earlier, simply use `/help /set`.
|
||||
|
||||
A very useful command to check out is the `//save <schematic>` command, which can save everything inside the WorldEdit region to a file, stored on the computer hosting the server (the player's computer, in single player mode). You can then later use `//load <schematic>` to load the data in a file into a world, even another world on another computer.
|
||||
|
||||
### WorldEdit GUI
|
||||
|
||||
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.
|
438
minetestforfun-bros/mods/WorldEdit/WorldEdit API.md → mods/WorldEdit/WorldEdit API.md
Executable file → Normal file
@ -1,219 +1,219 @@
|
||||
WorldEdit API
|
||||
=============
|
||||
The WorldEdit API is composed of multiple modules, each of which is independent and can be used without the other. Each module is contained within a single file.
|
||||
|
||||
If needed, individual modules such as visualization.lua can be removed without affecting the rest of the program. The only file that cannot be removed is init.lua, which is necessary for the mod to run.
|
||||
|
||||
For more information, see the [README](README.md).
|
||||
|
||||
General
|
||||
-------
|
||||
|
||||
### value = worldedit.version
|
||||
|
||||
Contains the current version of WorldEdit in a table of the form `{major=MAJOR_INTEGER, minor=MINOR_INTEGER}`, where `MAJOR_INTEGER` is the major version (the number before the period) as an integer, and `MINOR_INTEGER` is the minor version (the number after the period) as an integer. This is intended for version checking purposes.
|
||||
|
||||
### value = worldedit.version_string
|
||||
|
||||
Contains the current version of WorldEdit in the form of a string `"MAJOR_INTEGER.MINOR_INTEGER"`, where `MAJOR_INTEGER` is the major version (the number before the period) as an integer, and `MINOR_INTEGER` is the minor version (the number after the period) as an integer. This is intended for display purposes.
|
||||
|
||||
Manipulations
|
||||
-------------
|
||||
Contained in manipulations.lua, this module allows several node operations to be applied over a region.
|
||||
|
||||
### 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`.
|
||||
|
||||
Returns the number of nodes set.
|
||||
|
||||
### count = worldedit.replace(pos1, pos2, searchnode, replacenode)
|
||||
|
||||
Replaces all instances of `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns the number of nodes replaced.
|
||||
|
||||
### count = worldedit.replaceinverse(pos1, pos2, searchnode, replacenode)
|
||||
|
||||
Replaces all nodes other than `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns the number of nodes replaced.
|
||||
|
||||
### count = worldedit.copy(pos1, pos2, axis, amount)
|
||||
|
||||
Copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.
|
||||
|
||||
Returns the number of nodes copied.
|
||||
|
||||
### count = worldedit.move(pos1, pos2, axis, amount)
|
||||
|
||||
Moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.
|
||||
|
||||
Returns the number of nodes moved.
|
||||
|
||||
### count = worldedit.stack(pos1, pos2, axis, count)
|
||||
|
||||
Duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times.
|
||||
|
||||
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`.
|
||||
|
||||
Returns the number of nodes stacked.
|
||||
|
||||
### count, newpos1, newpos2 = worldedit.stretch(pos1, pos2, stretchx, stretchy, stretchz)
|
||||
|
||||
Stretches the region defined by positions `pos1` and `pos2` by an factor of positive integers `stretchx`, `stretchy`. and `stretchz` along the X, Y, and Z axes, respectively, with `pos1` as the origin.
|
||||
|
||||
Returns the number of nodes stretched, the new scaled position 1, and the new scaled position 2.
|
||||
|
||||
### count, newpos1, newpos2 = worldedit.transpose(pos1, pos2, axis1, axis2)
|
||||
|
||||
Transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes ("x" or "y" or "z").
|
||||
|
||||
Returns the number of nodes transposed, the new transposed position 1, and the new transposed position 2.
|
||||
|
||||
### count = worldedit.flip(pos1, pos2, axis)
|
||||
|
||||
Flips a region defined by the positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z").
|
||||
|
||||
Returns the number of nodes flipped.
|
||||
|
||||
### count, newpos2, newpos2 = worldedit.rotate(pos1, pos2, angle)
|
||||
|
||||
Rotates a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise around the y axis (supporting 90 degree increments only).
|
||||
|
||||
Returns the number of nodes rotated, the new position 1, and the new position 2.
|
||||
|
||||
### count = worldedit.orient(pos1, pos2, angle)
|
||||
|
||||
Rotates all oriented nodes in a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise (90 degree increment) around the Y axis.
|
||||
|
||||
Returns the number of nodes oriented.
|
||||
|
||||
### count = worldedit.fixlight(pos1, pos2)
|
||||
|
||||
Fixes the lighting in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns the number of nodes updated.
|
||||
|
||||
### count = worldedit.clearobjects(pos1, pos2)
|
||||
|
||||
Clears all objects in a region defined by the positions `pos1` and `pos2`.
|
||||
|
||||
Returns the number of objects cleared.
|
||||
|
||||
Primitives
|
||||
----------
|
||||
Contained in primitives.lua, this module allows the creation of several geometric primitives.
|
||||
|
||||
### count = worldedit.sphere(pos, radius, node_name, hollow)
|
||||
|
||||
Adds a sphere centered at `pos` with radius `radius`, composed of `node_name`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
### count = worldedit.dome(pos, radius, node_name, hollow)
|
||||
|
||||
Adds a dome centered at `pos` with radius `radius`, composed of `node_name`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
### count = worldedit.cylinder(pos, axis, length, radius, node_name, hollow)
|
||||
|
||||
Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `node_name`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
### count = worldedit.pyramid(pos, axis, height, node_name)
|
||||
|
||||
Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with height `height`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
### count = worldedit.spiral(pos, length, height, spacer, node_name)
|
||||
|
||||
Adds a spiral centered at `pos` with side length `length`, height `height`, space between walls `spacer`, composed of `node_name`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
Visualization
|
||||
-------------
|
||||
Contained in visualization.lua, this module allows nodes to be visualized in different ways.
|
||||
|
||||
### volume = worldedit.volume(pos1, pos2)
|
||||
|
||||
Determines the volume of the region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns the volume.
|
||||
|
||||
### count = worldedit.hide(pos1, pos2)
|
||||
|
||||
Hides all nodes in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.
|
||||
|
||||
Returns the number of nodes hidden.
|
||||
|
||||
### count = worldedit.suppress(pos1, pos2, node_name)
|
||||
|
||||
Suppresses all instances of `node_name` in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.
|
||||
|
||||
Returns the number of nodes suppressed.
|
||||
|
||||
### count = worldedit.highlight(pos1, pos2, node_name)
|
||||
|
||||
Highlights all instances of `node_name` in a region defined by positions `pos1` and `pos2` by non-destructively hiding all other nodes.
|
||||
|
||||
Returns the number of nodes found.
|
||||
|
||||
### count = worldedit.restore(pos1, pos2)
|
||||
|
||||
Restores all nodes hidden with WorldEdit functions in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
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.
|
||||
|
||||
### version, extra_fields, content = worldedit.read_header(value)
|
||||
|
||||
Reads the header from serialized data `value`.
|
||||
|
||||
Returns the version as a positive integer (nil for unknown versions),
|
||||
extra header fields (nil if not supported), and the content after the header.
|
||||
|
||||
### data, count = worldedit.serialize(pos1, pos2)
|
||||
|
||||
Converts the region defined by positions `pos1` and `pos2` into a single string.
|
||||
|
||||
Returns the serialized data and the number of nodes serialized, or nil.
|
||||
|
||||
### pos1, pos2, count = worldedit.allocate(origin_pos, value)
|
||||
|
||||
Determines the volume the nodes represented by string `value` would occupy if deserialized at `origin_pos`.
|
||||
|
||||
Returns the two corner positions and the number of nodes, or nil.
|
||||
|
||||
### count = worldedit.deserialize(origin_pos, value)
|
||||
|
||||
Loads the nodes represented by string `value` at position `origin_pos`.
|
||||
|
||||
Returns the number of nodes deserialized or nil.
|
||||
|
||||
Code
|
||||
----
|
||||
Contained in code.lua, this module allows arbitrary Lua code to be used with WorldEdit.
|
||||
|
||||
### error = worldedit.lua(code)
|
||||
|
||||
Executes `code` as a Lua chunk in the global namespace.
|
||||
|
||||
Returns an error if the code fails or nil otherwise.
|
||||
|
||||
### error = worldedit.luatransform(pos1, pos2, code)
|
||||
|
||||
Executes `code` as a Lua chunk in the global namespace with the variable `pos` available, for each node in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns an error if the code fails or nil otherwise.
|
||||
WorldEdit API
|
||||
=============
|
||||
The WorldEdit API is composed of multiple modules, each of which is independent and can be used without the other. Each module is contained within a single file.
|
||||
|
||||
If needed, individual modules such as visualization.lua can be removed without affecting the rest of the program. The only file that cannot be removed is init.lua, which is necessary for the mod to run.
|
||||
|
||||
For more information, see the [README](README.md).
|
||||
|
||||
General
|
||||
-------
|
||||
|
||||
### value = worldedit.version
|
||||
|
||||
Contains the current version of WorldEdit in a table of the form `{major=MAJOR_INTEGER, minor=MINOR_INTEGER}`, where `MAJOR_INTEGER` is the major version (the number before the period) as an integer, and `MINOR_INTEGER` is the minor version (the number after the period) as an integer. This is intended for version checking purposes.
|
||||
|
||||
### value = worldedit.version_string
|
||||
|
||||
Contains the current version of WorldEdit in the form of a string `"MAJOR_INTEGER.MINOR_INTEGER"`, where `MAJOR_INTEGER` is the major version (the number before the period) as an integer, and `MINOR_INTEGER` is the minor version (the number after the period) as an integer. This is intended for display purposes.
|
||||
|
||||
Manipulations
|
||||
-------------
|
||||
Contained in manipulations.lua, this module allows several node operations to be applied over a region.
|
||||
|
||||
### 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`.
|
||||
|
||||
Returns the number of nodes set.
|
||||
|
||||
### count = worldedit.replace(pos1, pos2, searchnode, replacenode)
|
||||
|
||||
Replaces all instances of `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns the number of nodes replaced.
|
||||
|
||||
### count = worldedit.replaceinverse(pos1, pos2, searchnode, replacenode)
|
||||
|
||||
Replaces all nodes other than `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns the number of nodes replaced.
|
||||
|
||||
### count = worldedit.copy(pos1, pos2, axis, amount)
|
||||
|
||||
Copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.
|
||||
|
||||
Returns the number of nodes copied.
|
||||
|
||||
### count = worldedit.move(pos1, pos2, axis, amount)
|
||||
|
||||
Moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes.
|
||||
|
||||
Returns the number of nodes moved.
|
||||
|
||||
### count = worldedit.stack(pos1, pos2, axis, count)
|
||||
|
||||
Duplicates the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") `count` times.
|
||||
|
||||
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`.
|
||||
|
||||
Returns the number of nodes stacked.
|
||||
|
||||
### count, newpos1, newpos2 = worldedit.stretch(pos1, pos2, stretchx, stretchy, stretchz)
|
||||
|
||||
Stretches the region defined by positions `pos1` and `pos2` by an factor of positive integers `stretchx`, `stretchy`. and `stretchz` along the X, Y, and Z axes, respectively, with `pos1` as the origin.
|
||||
|
||||
Returns the number of nodes stretched, the new scaled position 1, and the new scaled position 2.
|
||||
|
||||
### count, newpos1, newpos2 = worldedit.transpose(pos1, pos2, axis1, axis2)
|
||||
|
||||
Transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes ("x" or "y" or "z").
|
||||
|
||||
Returns the number of nodes transposed, the new transposed position 1, and the new transposed position 2.
|
||||
|
||||
### count = worldedit.flip(pos1, pos2, axis)
|
||||
|
||||
Flips a region defined by the positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z").
|
||||
|
||||
Returns the number of nodes flipped.
|
||||
|
||||
### count, newpos2, newpos2 = worldedit.rotate(pos1, pos2, angle)
|
||||
|
||||
Rotates a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise around the y axis (supporting 90 degree increments only).
|
||||
|
||||
Returns the number of nodes rotated, the new position 1, and the new position 2.
|
||||
|
||||
### count = worldedit.orient(pos1, pos2, angle)
|
||||
|
||||
Rotates all oriented nodes in a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise (90 degree increment) around the Y axis.
|
||||
|
||||
Returns the number of nodes oriented.
|
||||
|
||||
### count = worldedit.fixlight(pos1, pos2)
|
||||
|
||||
Fixes the lighting in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns the number of nodes updated.
|
||||
|
||||
### count = worldedit.clearobjects(pos1, pos2)
|
||||
|
||||
Clears all objects in a region defined by the positions `pos1` and `pos2`.
|
||||
|
||||
Returns the number of objects cleared.
|
||||
|
||||
Primitives
|
||||
----------
|
||||
Contained in primitives.lua, this module allows the creation of several geometric primitives.
|
||||
|
||||
### count = worldedit.sphere(pos, radius, node_name, hollow)
|
||||
|
||||
Adds a sphere centered at `pos` with radius `radius`, composed of `node_name`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
### count = worldedit.dome(pos, radius, node_name, hollow)
|
||||
|
||||
Adds a dome centered at `pos` with radius `radius`, composed of `node_name`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
### count = worldedit.cylinder(pos, axis, length, radius, node_name, hollow)
|
||||
|
||||
Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `node_name`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
### count = worldedit.pyramid(pos, axis, height, node_name)
|
||||
|
||||
Adds a pyramid centered at `pos` along the `axis` axis ("x" or "y" or "z") with height `height`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
### count = worldedit.spiral(pos, length, height, spacer, node_name)
|
||||
|
||||
Adds a spiral centered at `pos` with side length `length`, height `height`, space between walls `spacer`, composed of `node_name`.
|
||||
|
||||
Returns the number of nodes added.
|
||||
|
||||
Visualization
|
||||
-------------
|
||||
Contained in visualization.lua, this module allows nodes to be visualized in different ways.
|
||||
|
||||
### volume = worldedit.volume(pos1, pos2)
|
||||
|
||||
Determines the volume of the region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns the volume.
|
||||
|
||||
### count = worldedit.hide(pos1, pos2)
|
||||
|
||||
Hides all nodes in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.
|
||||
|
||||
Returns the number of nodes hidden.
|
||||
|
||||
### count = worldedit.suppress(pos1, pos2, node_name)
|
||||
|
||||
Suppresses all instances of `node_name` in a region defined by positions `pos1` and `pos2` by non-destructively replacing them with invisible nodes.
|
||||
|
||||
Returns the number of nodes suppressed.
|
||||
|
||||
### count = worldedit.highlight(pos1, pos2, node_name)
|
||||
|
||||
Highlights all instances of `node_name` in a region defined by positions `pos1` and `pos2` by non-destructively hiding all other nodes.
|
||||
|
||||
Returns the number of nodes found.
|
||||
|
||||
### count = worldedit.restore(pos1, pos2)
|
||||
|
||||
Restores all nodes hidden with WorldEdit functions in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
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.
|
||||
|
||||
### version, extra_fields, content = worldedit.read_header(value)
|
||||
|
||||
Reads the header from serialized data `value`.
|
||||
|
||||
Returns the version as a positive integer (nil for unknown versions),
|
||||
extra header fields (nil if not supported), and the content after the header.
|
||||
|
||||
### data, count = worldedit.serialize(pos1, pos2)
|
||||
|
||||
Converts the region defined by positions `pos1` and `pos2` into a single string.
|
||||
|
||||
Returns the serialized data and the number of nodes serialized, or nil.
|
||||
|
||||
### pos1, pos2, count = worldedit.allocate(origin_pos, value)
|
||||
|
||||
Determines the volume the nodes represented by string `value` would occupy if deserialized at `origin_pos`.
|
||||
|
||||
Returns the two corner positions and the number of nodes, or nil.
|
||||
|
||||
### count = worldedit.deserialize(origin_pos, value)
|
||||
|
||||
Loads the nodes represented by string `value` at position `origin_pos`.
|
||||
|
||||
Returns the number of nodes deserialized or nil.
|
||||
|
||||
Code
|
||||
----
|
||||
Contained in code.lua, this module allows arbitrary Lua code to be used with WorldEdit.
|
||||
|
||||
### error = worldedit.lua(code)
|
||||
|
||||
Executes `code` as a Lua chunk in the global namespace.
|
||||
|
||||
Returns an error if the code fails or nil otherwise.
|
||||
|
||||
### error = worldedit.luatransform(pos1, pos2, code)
|
||||
|
||||
Executes `code` as a Lua chunk in the global namespace with the variable `pos` available, for each node in a region defined by positions `pos1` and `pos2`.
|
||||
|
||||
Returns an error if the code fails or nil otherwise.
|
0
minetestforfun-bros/mods/WorldEdit/config.ld → mods/WorldEdit/config.ld
Executable file → Normal file
0
minetestforfun-bros/mods/WorldEdit/modpack.txt → mods/WorldEdit/modpack.txt
Executable file → Normal file
104
minetestforfun-bros/mods/WorldEdit/worldedit/code.lua → mods/WorldEdit/worldedit/code.lua
Executable file → Normal file
@ -1,52 +1,52 @@
|
||||
--- Lua code execution functions.
|
||||
-- @module worldedit.code
|
||||
|
||||
--- Executes `code` as a Lua chunk in the global namespace.
|
||||
-- @return An error message if the code fails, or nil on success.
|
||||
function worldedit.lua(code)
|
||||
local func, err = loadstring(code)
|
||||
if not func then -- Syntax error
|
||||
return err
|
||||
end
|
||||
local good, err = pcall(func)
|
||||
if not good then -- Runtime error
|
||||
return err
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Executes `code` as a Lua chunk in the global namespace with the variable
|
||||
-- pos available, for each node in a region defined by positions `pos1` and
|
||||
-- `pos2`.
|
||||
-- @return An error message if the code fails, or nil on success.
|
||||
function worldedit.luatransform(pos1, pos2, code)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local factory, err = loadstring("return function(pos) " .. code .. " end")
|
||||
if not factory then -- Syntax error
|
||||
return err
|
||||
end
|
||||
local func = factory()
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
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 good, err = pcall(func, pos)
|
||||
if not good then -- Runtime error
|
||||
return err
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Lua code execution functions.
|
||||
-- @module worldedit.code
|
||||
|
||||
--- Executes `code` as a Lua chunk in the global namespace.
|
||||
-- @return An error message if the code fails, or nil on success.
|
||||
function worldedit.lua(code)
|
||||
local func, err = loadstring(code)
|
||||
if not func then -- Syntax error
|
||||
return err
|
||||
end
|
||||
local good, err = pcall(func)
|
||||
if not good then -- Runtime error
|
||||
return err
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Executes `code` as a Lua chunk in the global namespace with the variable
|
||||
-- pos available, for each node in a region defined by positions `pos1` and
|
||||
-- `pos2`.
|
||||
-- @return An error message if the code fails, or nil on success.
|
||||
function worldedit.luatransform(pos1, pos2, code)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local factory, err = loadstring("return function(pos) " .. code .. " end")
|
||||
if not factory then -- Syntax error
|
||||
return err
|
||||
end
|
||||
local func = factory()
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
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 good, err = pcall(func, pos)
|
||||
if not good then -- Runtime error
|
||||
return err
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
0
minetestforfun-bros/mods/WorldEdit/worldedit/common.lua → mods/WorldEdit/worldedit/common.lua
Executable file → Normal file
148
minetestforfun-bros/mods/WorldEdit/worldedit/compatibility.lua → mods/WorldEdit/worldedit/compatibility.lua
Executable file → Normal file
@ -1,74 +1,74 @@
|
||||
--- Compatibility functions.
|
||||
-- @module worldedit.compatibility
|
||||
|
||||
local function deprecated(new_func)
|
||||
local info = debug.getinfo(1, "n")
|
||||
local msg = "worldedit." .. info.name .. "() is deprecated."
|
||||
if new_func then
|
||||
msg = msg .. " Use worldedit." .. new_func .. "() instead."
|
||||
end
|
||||
minetest.log("deprecated", msg)
|
||||
end
|
||||
|
||||
worldedit.allocate_old = worldedit.allocate
|
||||
|
||||
worldedit.deserialize_old = worldedit.deserialize
|
||||
|
||||
function worldedit.metasave(pos1, pos2, filename)
|
||||
deprecated("save")
|
||||
local file, err = io.open(filename, "wb")
|
||||
if err then return 0 end
|
||||
local data, count = worldedit.serialize(pos1, pos2)
|
||||
file:write(data)
|
||||
file:close()
|
||||
return count
|
||||
end
|
||||
|
||||
function worldedit.metaload(originpos, filename)
|
||||
deprecated("load")
|
||||
filename = minetest.get_worldpath() .. "/schems/" .. file .. ".wem"
|
||||
local file, err = io.open(filename, "wb")
|
||||
if err then return 0 end
|
||||
local data = file:read("*a")
|
||||
return worldedit.deserialize(originpos, data)
|
||||
end
|
||||
|
||||
function worldedit.scale(pos1, pos2, factor)
|
||||
deprecated("stretch")
|
||||
return worldedit.stretch(pos1, pos2, factor, factor, factor)
|
||||
end
|
||||
|
||||
function worldedit.valueversion(value)
|
||||
deprecated("read_header")
|
||||
local version = worldedit.read_header(value)
|
||||
if not version or version > worldedit.LATEST_SERIALIZATION_VERSION then
|
||||
return 0
|
||||
end
|
||||
return version
|
||||
end
|
||||
|
||||
function worldedit.replaceinverse(pos1, pos2, search_node, replace_node)
|
||||
deprecated("replace")
|
||||
return worldedit.replace(pos1, pos2, search_node, replace_node, true)
|
||||
end
|
||||
|
||||
function worldedit.clearobjects(...)
|
||||
deprecated("clear_objects")
|
||||
return worldedit.clear_objects(...)
|
||||
end
|
||||
|
||||
function worldedit.hollow_sphere(pos, radius, node_name)
|
||||
deprecated("sphere")
|
||||
return worldedit.sphere(pos, radius, node_name, true)
|
||||
end
|
||||
|
||||
function worldedit.hollow_dome(pos, radius, node_name)
|
||||
deprecated("dome")
|
||||
return worldedit.dome(pos, radius, node_name, true)
|
||||
end
|
||||
|
||||
function worldedit.hollow_cylinder(pos, axis, length, radius, node_name)
|
||||
deprecated("cylinder")
|
||||
return worldedit.cylinder(pos, axis, length, radius, node_name, true)
|
||||
end
|
||||
|
||||
--- Compatibility functions.
|
||||
-- @module worldedit.compatibility
|
||||
|
||||
local function deprecated(new_func)
|
||||
local info = debug.getinfo(1, "n")
|
||||
local msg = "worldedit." .. info.name .. "() is deprecated."
|
||||
if new_func then
|
||||
msg = msg .. " Use worldedit." .. new_func .. "() instead."
|
||||
end
|
||||
minetest.log("deprecated", msg)
|
||||
end
|
||||
|
||||
worldedit.allocate_old = worldedit.allocate
|
||||
|
||||
worldedit.deserialize_old = worldedit.deserialize
|
||||
|
||||
function worldedit.metasave(pos1, pos2, filename)
|
||||
deprecated("save")
|
||||
local file, err = io.open(filename, "wb")
|
||||
if err then return 0 end
|
||||
local data, count = worldedit.serialize(pos1, pos2)
|
||||
file:write(data)
|
||||
file:close()
|
||||
return count
|
||||
end
|
||||
|
||||
function worldedit.metaload(originpos, filename)
|
||||
deprecated("load")
|
||||
filename = minetest.get_worldpath() .. "/schems/" .. file .. ".wem"
|
||||
local file, err = io.open(filename, "wb")
|
||||
if err then return 0 end
|
||||
local data = file:read("*a")
|
||||
return worldedit.deserialize(originpos, data)
|
||||
end
|
||||
|
||||
function worldedit.scale(pos1, pos2, factor)
|
||||
deprecated("stretch")
|
||||
return worldedit.stretch(pos1, pos2, factor, factor, factor)
|
||||
end
|
||||
|
||||
function worldedit.valueversion(value)
|
||||
deprecated("read_header")
|
||||
local version = worldedit.read_header(value)
|
||||
if not version or version > worldedit.LATEST_SERIALIZATION_VERSION then
|
||||
return 0
|
||||
end
|
||||
return version
|
||||
end
|
||||
|
||||
function worldedit.replaceinverse(pos1, pos2, search_node, replace_node)
|
||||
deprecated("replace")
|
||||
return worldedit.replace(pos1, pos2, search_node, replace_node, true)
|
||||
end
|
||||
|
||||
function worldedit.clearobjects(...)
|
||||
deprecated("clear_objects")
|
||||
return worldedit.clear_objects(...)
|
||||
end
|
||||
|
||||
function worldedit.hollow_sphere(pos, radius, node_name)
|
||||
deprecated("sphere")
|
||||
return worldedit.sphere(pos, radius, node_name, true)
|
||||
end
|
||||
|
||||
function worldedit.hollow_dome(pos, radius, node_name)
|
||||
deprecated("dome")
|
||||
return worldedit.dome(pos, radius, node_name, true)
|
||||
end
|
||||
|
||||
function worldedit.hollow_cylinder(pos, axis, length, radius, node_name)
|
||||
deprecated("cylinder")
|
||||
return worldedit.cylinder(pos, axis, length, radius, node_name, true)
|
||||
end
|
||||
|
88
minetestforfun-bros/mods/WorldEdit/worldedit/init.lua → mods/WorldEdit/worldedit/init.lua
Executable file → Normal file
@ -1,44 +1,44 @@
|
||||
--- Worldedit.
|
||||
-- @module worldedit
|
||||
-- @release 1.1
|
||||
-- @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 = {}
|
||||
worldedit.version = {1, 1, major=1, minor=1}
|
||||
worldedit.version_string = table.concat(worldedit.version, ".")
|
||||
|
||||
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)
|
||||
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")
|
||||
|
||||
|
||||
if minetest.setting_getbool("log_mods") then
|
||||
print("[WorldEdit] Loaded!")
|
||||
end
|
||||
|
||||
--- Worldedit.
|
||||
-- @module worldedit
|
||||
-- @release 1.1
|
||||
-- @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 = {}
|
||||
worldedit.version = {1, 1, major=1, minor=1}
|
||||
worldedit.version_string = table.concat(worldedit.version, ".")
|
||||
|
||||
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)
|
||||
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")
|
||||
|
||||
|
||||
if minetest.setting_getbool("log_mods") then
|
||||
print("[WorldEdit] Loaded!")
|
||||
end
|
||||
|
1194
minetestforfun-bros/mods/WorldEdit/worldedit/manipulations.lua → mods/WorldEdit/worldedit/manipulations.lua
Executable file → Normal file
546
minetestforfun-bros/mods/WorldEdit/worldedit/primitives.lua → mods/WorldEdit/worldedit/primitives.lua
Executable file → Normal file
@ -1,273 +1,273 @@
|
||||
--- Functions for creating primitive shapes.
|
||||
-- @module worldedit.primitives
|
||||
|
||||
local mh = worldedit.manip_helpers
|
||||
|
||||
|
||||
--- Adds a sphere of `node_name` centered at `pos`.
|
||||
-- @param pos Position to center sphere at.
|
||||
-- @param radius Sphere radius.
|
||||
-- @param node_name Name of node to make shere of.
|
||||
-- @param hollow Whether the sphere should be hollow.
|
||||
-- @return The number of nodes added.
|
||||
function worldedit.sphere(pos, radius, node_name, hollow)
|
||||
local manip, area = mh.init_radius(pos, radius)
|
||||
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Fill selected area with node
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
local offset_x, offset_y, offset_z = pos.x - area.MinEdge.x, pos.y - area.MinEdge.y, pos.z - area.MinEdge.z
|
||||
local stride_z, stride_y = area.zstride, area.ystride
|
||||
local count = 0
|
||||
for z = -radius, radius do
|
||||
-- Offset contributed by z plus 1 to make it 1-indexed
|
||||
local new_z = (z + offset_z) * stride_z + 1
|
||||
for y = -radius, radius do
|
||||
local new_y = new_z + (y + offset_y) * stride_y
|
||||
for x = -radius, radius do
|
||||
local squared = x * x + y * y + z * z
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
-- Position is on surface of sphere
|
||||
local i = new_y + (x + offset_x)
|
||||
data[i] = node_id
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
|
||||
--- Adds a dome.
|
||||
-- @param pos Position to center dome at.
|
||||
-- @param radius Dome radius. Negative for concave domes.
|
||||
-- @param node_name Name of node to make dome of.
|
||||
-- @param hollow Whether the dome should be hollow.
|
||||
-- @return The number of nodes added.
|
||||
-- TODO: Add axis option.
|
||||
function worldedit.dome(pos, radius, node_name, hollow)
|
||||
local min_y, max_y = 0, radius
|
||||
if radius < 0 then
|
||||
radius = -radius
|
||||
min_y, max_y = -radius, 0
|
||||
end
|
||||
|
||||
local manip, area = mh.init_axis_radius(pos, "y", radius)
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Add dome
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
local offset_x, offset_y, offset_z = pos.x - area.MinEdge.x, pos.y - area.MinEdge.y, pos.z - area.MinEdge.z
|
||||
local stride_z, stride_y = area.zstride, area.ystride
|
||||
local count = 0
|
||||
for z = -radius, radius do
|
||||
local new_z = (z + offset_z) * stride_z + 1 --offset contributed by z plus 1 to make it 1-indexed
|
||||
for y = min_y, max_y do
|
||||
local new_y = new_z + (y + offset_y) * stride_y
|
||||
for x = -radius, radius do
|
||||
local squared = x * x + y * y + z * z
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
-- Position is in dome
|
||||
local i = new_y + (x + offset_x)
|
||||
data[i] = node_id
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
--- Adds a cylinder.
|
||||
-- @param pos Position to center base of cylinder at.
|
||||
-- @param axis Axis ("x", "y", or "z")
|
||||
-- @param length Cylinder length.
|
||||
-- @param radius Cylinder radius.
|
||||
-- @param node_name Name of node to make cylinder of.
|
||||
-- @param hollow Whether the cylinder should be hollow.
|
||||
-- @return The number of nodes added.
|
||||
function worldedit.cylinder(pos, axis, length, radius, node_name, hollow)
|
||||
local other1, other2 = worldedit.get_axis_others(axis)
|
||||
|
||||
-- Handle negative lengths
|
||||
local current_pos = {x=pos.x, y=pos.y, z=pos.z}
|
||||
if length < 0 then
|
||||
length = -length
|
||||
current_pos[axis] = current_pos[axis] - length
|
||||
end
|
||||
|
||||
-- Set up voxel manipulator
|
||||
local manip, area = mh.init_axis_radius_length(current_pos, axis, radius, length)
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Add cylinder
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
local stride = {x=1, y=area.ystride, z=area.zstride}
|
||||
local offset = {
|
||||
x = current_pos.x - area.MinEdge.x,
|
||||
y = current_pos.y - area.MinEdge.y,
|
||||
z = current_pos.z - area.MinEdge.z,
|
||||
}
|
||||
local min_slice, max_slice = offset[axis], offset[axis] + length - 1
|
||||
local count = 0
|
||||
for index2 = -radius, radius do
|
||||
-- Offset contributed by other axis 1 plus 1 to make it 1-indexed
|
||||
local new_index2 = (index2 + offset[other1]) * stride[other1] + 1
|
||||
for index3 = -radius, radius do
|
||||
local new_index3 = new_index2 + (index3 + offset[other2]) * stride[other2]
|
||||
local squared = index2 * index2 + index3 * index3
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
-- Position is in cylinder
|
||||
-- Add column along axis
|
||||
for index1 = min_slice, max_slice do
|
||||
local vi = new_index3 + index1 * stride[axis]
|
||||
data[vi] = node_id
|
||||
end
|
||||
count = count + length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
|
||||
--- Adds a pyramid.
|
||||
-- @param pos Position to center base of pyramid at.
|
||||
-- @param axis Axis ("x", "y", or "z")
|
||||
-- @param height Pyramid height.
|
||||
-- @param node_name Name of node to make pyramid of.
|
||||
-- @return The number of nodes added.
|
||||
function worldedit.pyramid(pos, axis, height, node_name)
|
||||
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)
|
||||
local data = mh.get_empty_data()
|
||||
|
||||
-- Handle inverted pyramids
|
||||
local start_axis, end_axis, step
|
||||
if height > 0 then
|
||||
height = height - 1
|
||||
step = 1
|
||||
else
|
||||
height = height + 1
|
||||
step = -1
|
||||
end
|
||||
|
||||
-- Add pyramid
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local stride = {x=1, y=area.ystride, z=area.zstride}
|
||||
local offset = {
|
||||
x = pos.x - area.MinEdge.x,
|
||||
y = pos.y - area.MinEdge.y,
|
||||
z = pos.z - area.MinEdge.z,
|
||||
}
|
||||
local size = height * step
|
||||
local count = 0
|
||||
-- For each level of the pyramid
|
||||
for index1 = 0, height, step do
|
||||
-- Offset contributed by axis plus 1 to make it 1-indexed
|
||||
local new_index1 = (index1 + offset[axis]) * stride[axis] + 1
|
||||
for index2 = -size, size do
|
||||
local new_index2 = new_index1 + (index2 + offset[other1]) * stride[other1]
|
||||
for index3 = -size, size do
|
||||
local i = new_index2 + (index3 + offset[other2]) * stride[other2]
|
||||
data[i] = node_id
|
||||
end
|
||||
end
|
||||
count = count + (size * 2 + 1) ^ 2
|
||||
size = size - 1
|
||||
end
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
--- Adds a spiral.
|
||||
-- @param pos Position to center spiral at.
|
||||
-- @param length Spral length.
|
||||
-- @param height Spiral height.
|
||||
-- @param spacer Space between walls.
|
||||
-- @param node_name Name of node to make spiral of.
|
||||
-- @return Number of nodes added.
|
||||
-- TODO: Add axis option.
|
||||
function worldedit.spiral(pos, length, height, spacer, node_name)
|
||||
local extent = math.ceil(length / 2)
|
||||
|
||||
local manip, area = mh.init_axis_radius_length(pos, "y", extent, height)
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Set up variables
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local stride = {x=1, y=area.ystride, z=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
|
||||
|
||||
-- Add first column
|
||||
local count = height
|
||||
local column = i
|
||||
for y = 1, height do
|
||||
data[column] = node_id
|
||||
column = column + stride.y
|
||||
end
|
||||
|
||||
-- Add spiral segments
|
||||
local stride_axis, stride_other = stride.x, stride.z
|
||||
local sign = -1
|
||||
local segment_length = 0
|
||||
spacer = spacer + 1
|
||||
-- Go through each segment except the last
|
||||
for segment = 1, math.floor(length / spacer) * 2 do
|
||||
-- Change sign and length every other turn starting with the first
|
||||
if segment % 2 == 1 then
|
||||
sign = -sign
|
||||
segment_length = segment_length + spacer
|
||||
end
|
||||
-- Fill segment
|
||||
for index = 1, segment_length do
|
||||
-- Move along the direction of the segment
|
||||
i = i + stride_axis * sign
|
||||
local column = i
|
||||
-- Add column
|
||||
for y = 1, height do
|
||||
data[column] = node_id
|
||||
column = column + stride.y
|
||||
end
|
||||
end
|
||||
count = count + segment_length * height
|
||||
stride_axis, stride_other = stride_other, stride_axis -- Swap axes
|
||||
end
|
||||
|
||||
-- Add shorter final segment
|
||||
sign = -sign
|
||||
for index = 1, segment_length do
|
||||
i = i + stride_axis * sign
|
||||
local column = i
|
||||
-- Add column
|
||||
for y = 1, height do
|
||||
data[column] = node_id
|
||||
column = column + stride.y
|
||||
end
|
||||
end
|
||||
count = count + segment_length * height
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
--- Functions for creating primitive shapes.
|
||||
-- @module worldedit.primitives
|
||||
|
||||
local mh = worldedit.manip_helpers
|
||||
|
||||
|
||||
--- Adds a sphere of `node_name` centered at `pos`.
|
||||
-- @param pos Position to center sphere at.
|
||||
-- @param radius Sphere radius.
|
||||
-- @param node_name Name of node to make shere of.
|
||||
-- @param hollow Whether the sphere should be hollow.
|
||||
-- @return The number of nodes added.
|
||||
function worldedit.sphere(pos, radius, node_name, hollow)
|
||||
local manip, area = mh.init_radius(pos, radius)
|
||||
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Fill selected area with node
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
local offset_x, offset_y, offset_z = pos.x - area.MinEdge.x, pos.y - area.MinEdge.y, pos.z - area.MinEdge.z
|
||||
local stride_z, stride_y = area.zstride, area.ystride
|
||||
local count = 0
|
||||
for z = -radius, radius do
|
||||
-- Offset contributed by z plus 1 to make it 1-indexed
|
||||
local new_z = (z + offset_z) * stride_z + 1
|
||||
for y = -radius, radius do
|
||||
local new_y = new_z + (y + offset_y) * stride_y
|
||||
for x = -radius, radius do
|
||||
local squared = x * x + y * y + z * z
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
-- Position is on surface of sphere
|
||||
local i = new_y + (x + offset_x)
|
||||
data[i] = node_id
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
|
||||
--- Adds a dome.
|
||||
-- @param pos Position to center dome at.
|
||||
-- @param radius Dome radius. Negative for concave domes.
|
||||
-- @param node_name Name of node to make dome of.
|
||||
-- @param hollow Whether the dome should be hollow.
|
||||
-- @return The number of nodes added.
|
||||
-- TODO: Add axis option.
|
||||
function worldedit.dome(pos, radius, node_name, hollow)
|
||||
local min_y, max_y = 0, radius
|
||||
if radius < 0 then
|
||||
radius = -radius
|
||||
min_y, max_y = -radius, 0
|
||||
end
|
||||
|
||||
local manip, area = mh.init_axis_radius(pos, "y", radius)
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Add dome
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
local offset_x, offset_y, offset_z = pos.x - area.MinEdge.x, pos.y - area.MinEdge.y, pos.z - area.MinEdge.z
|
||||
local stride_z, stride_y = area.zstride, area.ystride
|
||||
local count = 0
|
||||
for z = -radius, radius do
|
||||
local new_z = (z + offset_z) * stride_z + 1 --offset contributed by z plus 1 to make it 1-indexed
|
||||
for y = min_y, max_y do
|
||||
local new_y = new_z + (y + offset_y) * stride_y
|
||||
for x = -radius, radius do
|
||||
local squared = x * x + y * y + z * z
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
-- Position is in dome
|
||||
local i = new_y + (x + offset_x)
|
||||
data[i] = node_id
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
--- Adds a cylinder.
|
||||
-- @param pos Position to center base of cylinder at.
|
||||
-- @param axis Axis ("x", "y", or "z")
|
||||
-- @param length Cylinder length.
|
||||
-- @param radius Cylinder radius.
|
||||
-- @param node_name Name of node to make cylinder of.
|
||||
-- @param hollow Whether the cylinder should be hollow.
|
||||
-- @return The number of nodes added.
|
||||
function worldedit.cylinder(pos, axis, length, radius, node_name, hollow)
|
||||
local other1, other2 = worldedit.get_axis_others(axis)
|
||||
|
||||
-- Handle negative lengths
|
||||
local current_pos = {x=pos.x, y=pos.y, z=pos.z}
|
||||
if length < 0 then
|
||||
length = -length
|
||||
current_pos[axis] = current_pos[axis] - length
|
||||
end
|
||||
|
||||
-- Set up voxel manipulator
|
||||
local manip, area = mh.init_axis_radius_length(current_pos, axis, radius, length)
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Add cylinder
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
local stride = {x=1, y=area.ystride, z=area.zstride}
|
||||
local offset = {
|
||||
x = current_pos.x - area.MinEdge.x,
|
||||
y = current_pos.y - area.MinEdge.y,
|
||||
z = current_pos.z - area.MinEdge.z,
|
||||
}
|
||||
local min_slice, max_slice = offset[axis], offset[axis] + length - 1
|
||||
local count = 0
|
||||
for index2 = -radius, radius do
|
||||
-- Offset contributed by other axis 1 plus 1 to make it 1-indexed
|
||||
local new_index2 = (index2 + offset[other1]) * stride[other1] + 1
|
||||
for index3 = -radius, radius do
|
||||
local new_index3 = new_index2 + (index3 + offset[other2]) * stride[other2]
|
||||
local squared = index2 * index2 + index3 * index3
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
-- Position is in cylinder
|
||||
-- Add column along axis
|
||||
for index1 = min_slice, max_slice do
|
||||
local vi = new_index3 + index1 * stride[axis]
|
||||
data[vi] = node_id
|
||||
end
|
||||
count = count + length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
|
||||
--- Adds a pyramid.
|
||||
-- @param pos Position to center base of pyramid at.
|
||||
-- @param axis Axis ("x", "y", or "z")
|
||||
-- @param height Pyramid height.
|
||||
-- @param node_name Name of node to make pyramid of.
|
||||
-- @return The number of nodes added.
|
||||
function worldedit.pyramid(pos, axis, height, node_name)
|
||||
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)
|
||||
local data = mh.get_empty_data()
|
||||
|
||||
-- Handle inverted pyramids
|
||||
local start_axis, end_axis, step
|
||||
if height > 0 then
|
||||
height = height - 1
|
||||
step = 1
|
||||
else
|
||||
height = height + 1
|
||||
step = -1
|
||||
end
|
||||
|
||||
-- Add pyramid
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local stride = {x=1, y=area.ystride, z=area.zstride}
|
||||
local offset = {
|
||||
x = pos.x - area.MinEdge.x,
|
||||
y = pos.y - area.MinEdge.y,
|
||||
z = pos.z - area.MinEdge.z,
|
||||
}
|
||||
local size = height * step
|
||||
local count = 0
|
||||
-- For each level of the pyramid
|
||||
for index1 = 0, height, step do
|
||||
-- Offset contributed by axis plus 1 to make it 1-indexed
|
||||
local new_index1 = (index1 + offset[axis]) * stride[axis] + 1
|
||||
for index2 = -size, size do
|
||||
local new_index2 = new_index1 + (index2 + offset[other1]) * stride[other1]
|
||||
for index3 = -size, size do
|
||||
local i = new_index2 + (index3 + offset[other2]) * stride[other2]
|
||||
data[i] = node_id
|
||||
end
|
||||
end
|
||||
count = count + (size * 2 + 1) ^ 2
|
||||
size = size - 1
|
||||
end
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
--- Adds a spiral.
|
||||
-- @param pos Position to center spiral at.
|
||||
-- @param length Spral length.
|
||||
-- @param height Spiral height.
|
||||
-- @param spacer Space between walls.
|
||||
-- @param node_name Name of node to make spiral of.
|
||||
-- @return Number of nodes added.
|
||||
-- TODO: Add axis option.
|
||||
function worldedit.spiral(pos, length, height, spacer, node_name)
|
||||
local extent = math.ceil(length / 2)
|
||||
|
||||
local manip, area = mh.init_axis_radius_length(pos, "y", extent, height)
|
||||
local data = mh.get_empty_data(area)
|
||||
|
||||
-- Set up variables
|
||||
local node_id = minetest.get_content_id(node_name)
|
||||
local stride = {x=1, y=area.ystride, z=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
|
||||
|
||||
-- Add first column
|
||||
local count = height
|
||||
local column = i
|
||||
for y = 1, height do
|
||||
data[column] = node_id
|
||||
column = column + stride.y
|
||||
end
|
||||
|
||||
-- Add spiral segments
|
||||
local stride_axis, stride_other = stride.x, stride.z
|
||||
local sign = -1
|
||||
local segment_length = 0
|
||||
spacer = spacer + 1
|
||||
-- Go through each segment except the last
|
||||
for segment = 1, math.floor(length / spacer) * 2 do
|
||||
-- Change sign and length every other turn starting with the first
|
||||
if segment % 2 == 1 then
|
||||
sign = -sign
|
||||
segment_length = segment_length + spacer
|
||||
end
|
||||
-- Fill segment
|
||||
for index = 1, segment_length do
|
||||
-- Move along the direction of the segment
|
||||
i = i + stride_axis * sign
|
||||
local column = i
|
||||
-- Add column
|
||||
for y = 1, height do
|
||||
data[column] = node_id
|
||||
column = column + stride.y
|
||||
end
|
||||
end
|
||||
count = count + segment_length * height
|
||||
stride_axis, stride_other = stride_other, stride_axis -- Swap axes
|
||||
end
|
||||
|
||||
-- Add shorter final segment
|
||||
sign = -sign
|
||||
for index = 1, segment_length do
|
||||
i = i + stride_axis * sign
|
||||
local column = i
|
||||
-- Add column
|
||||
for y = 1, height do
|
||||
data[column] = node_id
|
||||
column = column + stride.y
|
||||
end
|
||||
end
|
||||
count = count + segment_length * height
|
||||
|
||||
mh.finish(manip, data)
|
||||
|
||||
return count
|
||||
end
|
478
minetestforfun-bros/mods/WorldEdit/worldedit/serialization.lua → mods/WorldEdit/worldedit/serialization.lua
Executable file → Normal file
@ -1,239 +1,239 @@
|
||||
--- Schematic serialization and deserialiation.
|
||||
-- @module worldedit.serialization
|
||||
|
||||
worldedit.LATEST_SERIALIZATION_VERSION = 5
|
||||
local LATEST_SERIALIZATION_HEADER = worldedit.LATEST_SERIALIZATION_VERSION .. ":"
|
||||
|
||||
|
||||
--[[
|
||||
Serialization version history:
|
||||
1: Original format. Serialized Lua table with a weird linked format...
|
||||
2: Position and node seperated into sub-tables in fields `1` and `2`.
|
||||
3: List of nodes, one per line, with fields seperated by spaces.
|
||||
Format: <X> <Y> <Z> <Name> <Param1> <Param2>
|
||||
4: Serialized Lua table containing a list of nodes with `x`, `y`, `z`,
|
||||
`name`, `param1`, `param2`, and `meta` fields.
|
||||
5: Added header and made `param1`, `param2`, and `meta` fields optional.
|
||||
Header format: <Version>,<ExtraHeaderField1>,...:<Content>
|
||||
--]]
|
||||
|
||||
|
||||
--- Reads the header of serialized data.
|
||||
-- @param value Serialized WorldEdit data.
|
||||
-- @return The version as a positive natural number, or 0 for unknown versions.
|
||||
-- @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
|
||||
local header_end = value:find(":", 1, true)
|
||||
local header = value:sub(1, header_end - 1):split(",")
|
||||
local version = tonumber(header[1])
|
||||
table.remove(header, 1)
|
||||
local content = value:sub(header_end + 1)
|
||||
return version, header, content
|
||||
end
|
||||
-- Old versions that didn't include a header with a version number
|
||||
if value:find("([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)") and not value:find("%{") then -- List format
|
||||
return 3, nil, value
|
||||
elseif value:find("^[^\"']+%{%d+%}") then
|
||||
if value:find("%[\"meta\"%]") then -- Meta flat table format
|
||||
return 2, nil, value
|
||||
end
|
||||
return 1, nil, value -- Flat table format
|
||||
elseif value:find("%{") then -- Raw nested table format
|
||||
return 4, nil, value
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Converts the region defined by positions `pos1` and `pos2`
|
||||
-- into a single string.
|
||||
-- @return The serialized data.
|
||||
-- @return The number of nodes serialized.
|
||||
function worldedit.serialize(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=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
|
||||
pos.z = pos1.z
|
||||
while pos.z <= pos2.z do
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
result[count] = {
|
||||
x = pos.x - pos1.x,
|
||||
y = pos.y - pos1.y,
|
||||
z = pos.z - pos1.z,
|
||||
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,
|
||||
}
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
-- Serialize entries
|
||||
result = minetest.serialize(result)
|
||||
return LATEST_SERIALIZATION_HEADER .. result, count
|
||||
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 nodes = {}
|
||||
if version == 1 or version == 2 then -- Original flat table format
|
||||
local tables = minetest.deserialize(content)
|
||||
if not tables then return nil end
|
||||
|
||||
-- Transform the node table into an array of nodes
|
||||
for i = 1, #tables do
|
||||
for j, v in pairs(tables[i]) do
|
||||
if type(v) == "table" then
|
||||
tables[i][j] = tables[v[1]]
|
||||
end
|
||||
end
|
||||
end
|
||||
nodes = tables[1]
|
||||
|
||||
if version == 1 then --original flat table format
|
||||
for i, entry in ipairs(nodes) do
|
||||
local pos = entry[1]
|
||||
entry.x, entry.y, entry.z = pos.x, pos.y, pos.z
|
||||
entry[1] = nil
|
||||
local node = entry[2]
|
||||
entry.name, entry.param1, entry.param2 = node.name, node.param1, node.param2
|
||||
entry[2] = nil
|
||||
end
|
||||
end
|
||||
elseif version == 3 then -- List format
|
||||
for x, y, z, name, param1, param2 in content:gmatch(
|
||||
"([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)%s+" ..
|
||||
"([^%s]+)%s+(%d+)%s+(%d+)[^\r\n]*[\r\n]*") do
|
||||
param1, param2 = tonumber(param1), tonumber(param2)
|
||||
table.insert(nodes, {
|
||||
x = originx + tonumber(x),
|
||||
y = originy + tonumber(y),
|
||||
z = originz + tonumber(z),
|
||||
name = name,
|
||||
param1 = param1 ~= 0 and param1 or nil,
|
||||
param2 = param2 ~= 0 and param2 or nil,
|
||||
})
|
||||
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
|
||||
else
|
||||
return nil
|
||||
end
|
||||
return nodes
|
||||
end
|
||||
|
||||
--- Determines the volume the nodes represented by string `value` would occupy
|
||||
-- if deserialized at `origin_pos`.
|
||||
-- @return Low corner position.
|
||||
-- @return High corner position.
|
||||
-- @return The number of nodes.
|
||||
function worldedit.allocate(origin_pos, value)
|
||||
local nodes = load_schematic(value)
|
||||
if not nodes then return nil end
|
||||
return worldedit.allocate_with_nodes(origin_pos, nodes)
|
||||
end
|
||||
|
||||
|
||||
-- Internal
|
||||
function worldedit.allocate_with_nodes(origin_pos, nodes)
|
||||
local huge = math.huge
|
||||
local pos1x, pos1y, pos1z = huge, huge, huge
|
||||
local pos2x, pos2y, pos2z = -huge, -huge, -huge
|
||||
local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z
|
||||
for i, entry in ipairs(nodes) do
|
||||
local x, y, z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z
|
||||
if x < pos1x then pos1x = x end
|
||||
if y < pos1y then pos1y = y end
|
||||
if z < pos1z then pos1z = z end
|
||||
if x > pos2x then pos2x = x end
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
--- Loads the nodes represented by string `value` at position `origin_pos`.
|
||||
-- @return The number of nodes deserialized.
|
||||
function worldedit.deserialize(origin_pos, value)
|
||||
local nodes = load_schematic(value)
|
||||
if not nodes then return nil 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
|
||||
-- Entry acts as both position and node
|
||||
add_node(entry, entry)
|
||||
if entry.meta then
|
||||
get_meta(entry):from_table(entry.meta)
|
||||
end
|
||||
end
|
||||
return #nodes
|
||||
end
|
||||
|
||||
--- Schematic serialization and deserialiation.
|
||||
-- @module worldedit.serialization
|
||||
|
||||
worldedit.LATEST_SERIALIZATION_VERSION = 5
|
||||
local LATEST_SERIALIZATION_HEADER = worldedit.LATEST_SERIALIZATION_VERSION .. ":"
|
||||
|
||||
|
||||
--[[
|
||||
Serialization version history:
|
||||
1: Original format. Serialized Lua table with a weird linked format...
|
||||
2: Position and node seperated into sub-tables in fields `1` and `2`.
|
||||
3: List of nodes, one per line, with fields seperated by spaces.
|
||||
Format: <X> <Y> <Z> <Name> <Param1> <Param2>
|
||||
4: Serialized Lua table containing a list of nodes with `x`, `y`, `z`,
|
||||
`name`, `param1`, `param2`, and `meta` fields.
|
||||
5: Added header and made `param1`, `param2`, and `meta` fields optional.
|
||||
Header format: <Version>,<ExtraHeaderField1>,...:<Content>
|
||||
--]]
|
||||
|
||||
|
||||
--- Reads the header of serialized data.
|
||||
-- @param value Serialized WorldEdit data.
|
||||
-- @return The version as a positive natural number, or 0 for unknown versions.
|
||||
-- @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
|
||||
local header_end = value:find(":", 1, true)
|
||||
local header = value:sub(1, header_end - 1):split(",")
|
||||
local version = tonumber(header[1])
|
||||
table.remove(header, 1)
|
||||
local content = value:sub(header_end + 1)
|
||||
return version, header, content
|
||||
end
|
||||
-- Old versions that didn't include a header with a version number
|
||||
if value:find("([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)") and not value:find("%{") then -- List format
|
||||
return 3, nil, value
|
||||
elseif value:find("^[^\"']+%{%d+%}") then
|
||||
if value:find("%[\"meta\"%]") then -- Meta flat table format
|
||||
return 2, nil, value
|
||||
end
|
||||
return 1, nil, value -- Flat table format
|
||||
elseif value:find("%{") then -- Raw nested table format
|
||||
return 4, nil, value
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Converts the region defined by positions `pos1` and `pos2`
|
||||
-- into a single string.
|
||||
-- @return The serialized data.
|
||||
-- @return The number of nodes serialized.
|
||||
function worldedit.serialize(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=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
|
||||
pos.z = pos1.z
|
||||
while pos.z <= pos2.z do
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
result[count] = {
|
||||
x = pos.x - pos1.x,
|
||||
y = pos.y - pos1.y,
|
||||
z = pos.z - pos1.z,
|
||||
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,
|
||||
}
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
-- Serialize entries
|
||||
result = minetest.serialize(result)
|
||||
return LATEST_SERIALIZATION_HEADER .. result, count
|
||||
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 nodes = {}
|
||||
if version == 1 or version == 2 then -- Original flat table format
|
||||
local tables = minetest.deserialize(content)
|
||||
if not tables then return nil end
|
||||
|
||||
-- Transform the node table into an array of nodes
|
||||
for i = 1, #tables do
|
||||
for j, v in pairs(tables[i]) do
|
||||
if type(v) == "table" then
|
||||
tables[i][j] = tables[v[1]]
|
||||
end
|
||||
end
|
||||
end
|
||||
nodes = tables[1]
|
||||
|
||||
if version == 1 then --original flat table format
|
||||
for i, entry in ipairs(nodes) do
|
||||
local pos = entry[1]
|
||||
entry.x, entry.y, entry.z = pos.x, pos.y, pos.z
|
||||
entry[1] = nil
|
||||
local node = entry[2]
|
||||
entry.name, entry.param1, entry.param2 = node.name, node.param1, node.param2
|
||||
entry[2] = nil
|
||||
end
|
||||
end
|
||||
elseif version == 3 then -- List format
|
||||
for x, y, z, name, param1, param2 in content:gmatch(
|
||||
"([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)%s+" ..
|
||||
"([^%s]+)%s+(%d+)%s+(%d+)[^\r\n]*[\r\n]*") do
|
||||
param1, param2 = tonumber(param1), tonumber(param2)
|
||||
table.insert(nodes, {
|
||||
x = originx + tonumber(x),
|
||||
y = originy + tonumber(y),
|
||||
z = originz + tonumber(z),
|
||||
name = name,
|
||||
param1 = param1 ~= 0 and param1 or nil,
|
||||
param2 = param2 ~= 0 and param2 or nil,
|
||||
})
|
||||
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
|
||||
else
|
||||
return nil
|
||||
end
|
||||
return nodes
|
||||
end
|
||||
|
||||
--- Determines the volume the nodes represented by string `value` would occupy
|
||||
-- if deserialized at `origin_pos`.
|
||||
-- @return Low corner position.
|
||||
-- @return High corner position.
|
||||
-- @return The number of nodes.
|
||||
function worldedit.allocate(origin_pos, value)
|
||||
local nodes = load_schematic(value)
|
||||
if not nodes then return nil end
|
||||
return worldedit.allocate_with_nodes(origin_pos, nodes)
|
||||
end
|
||||
|
||||
|
||||
-- Internal
|
||||
function worldedit.allocate_with_nodes(origin_pos, nodes)
|
||||
local huge = math.huge
|
||||
local pos1x, pos1y, pos1z = huge, huge, huge
|
||||
local pos2x, pos2y, pos2z = -huge, -huge, -huge
|
||||
local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z
|
||||
for i, entry in ipairs(nodes) do
|
||||
local x, y, z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z
|
||||
if x < pos1x then pos1x = x end
|
||||
if y < pos1y then pos1y = y end
|
||||
if z < pos1z then pos1z = z end
|
||||
if x > pos2x then pos2x = x end
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
--- Loads the nodes represented by string `value` at position `origin_pos`.
|
||||
-- @return The number of nodes deserialized.
|
||||
function worldedit.deserialize(origin_pos, value)
|
||||
local nodes = load_schematic(value)
|
||||
if not nodes then return nil 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
|
||||
-- Entry acts as both position and node
|
||||
add_node(entry, entry)
|
||||
if entry.meta then
|
||||
get_meta(entry):from_table(entry.meta)
|
||||
end
|
||||
end
|
||||
return #nodes
|
||||
end
|
||||
|
262
minetestforfun-bros/mods/WorldEdit/worldedit/visualization.lua → mods/WorldEdit/worldedit/visualization.lua
Executable file → Normal file
@ -1,131 +1,131 @@
|
||||
--- Functions for visibly hiding nodes
|
||||
-- @module worldedit.visualization
|
||||
|
||||
minetest.register_node("worldedit:placeholder", {
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
diggable = false,
|
||||
walkable = false,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
--- Hides all nodes in a region defined by positions `pos1` and `pos2` by
|
||||
-- non-destructively replacing them with invisible nodes.
|
||||
-- @return The number of nodes hidden.
|
||||
function worldedit.hide(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
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)
|
||||
if node.name ~= "air" and node.name ~= "worldedit:placeholder" then
|
||||
-- Save the node's original name
|
||||
get_meta(pos):set_string("worldedit_placeholder", node.name)
|
||||
-- Swap in placeholder node
|
||||
node.name = "worldedit:placeholder"
|
||||
swap_node(pos, node)
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
return worldedit.volume(pos1, pos2)
|
||||
end
|
||||
|
||||
--- Suppresses all instances of `node_name` in a region defined by positions
|
||||
-- `pos1` and `pos2` by non-destructively replacing them with invisible nodes.
|
||||
-- @return The number of nodes suppressed.
|
||||
function worldedit.suppress(pos1, pos2, node_name)
|
||||
-- Ignore placeholder supression
|
||||
if node_name == "worldedit:placeholder" then
|
||||
return 0
|
||||
end
|
||||
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local nodes = minetest.find_nodes_in_area(pos1, pos2, node_name)
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
for _, pos in ipairs(nodes) do
|
||||
local node = get_node(pos)
|
||||
-- Save the node's original name
|
||||
get_meta(pos):set_string("worldedit_placeholder", node.name)
|
||||
-- Swap in placeholder node
|
||||
node.name = "worldedit:placeholder"
|
||||
swap_node(pos, node)
|
||||
end
|
||||
return #nodes
|
||||
end
|
||||
|
||||
--- Highlights all instances of `node_name` in a region defined by positions
|
||||
-- `pos1` and `pos2` by non-destructively hiding all other nodes.
|
||||
-- @return The number of nodes found.
|
||||
function worldedit.highlight(pos1, pos2, node_name)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
local count = 0
|
||||
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)
|
||||
if node.name == node_name then -- Node found
|
||||
count = count + 1
|
||||
elseif node.name ~= "worldedit:placeholder" then -- Hide other nodes
|
||||
-- Save the node's original name
|
||||
get_meta(pos):set_string("worldedit_placeholder", node.name)
|
||||
-- Swap in placeholder node
|
||||
node.name = "worldedit:placeholder"
|
||||
swap_node(pos, node)
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Restores all nodes hidden with WorldEdit functions in a region defined
|
||||
-- by positions `pos1` and `pos2`.
|
||||
-- @return The number of nodes restored.
|
||||
function worldedit.restore(pos1, pos2)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local nodes = minetest.find_nodes_in_area(pos1, pos2, "worldedit:placeholder")
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
for _, pos in ipairs(nodes) do
|
||||
local node = get_node(pos)
|
||||
local meta = get_meta(pos)
|
||||
local data = meta:to_table()
|
||||
node.name = data.fields.worldedit_placeholder
|
||||
data.fields.worldedit_placeholder = nil
|
||||
meta:from_table(data)
|
||||
swap_node(pos, node)
|
||||
end
|
||||
return #nodes
|
||||
end
|
||||
|
||||
--- Functions for visibly hiding nodes
|
||||
-- @module worldedit.visualization
|
||||
|
||||
minetest.register_node("worldedit:placeholder", {
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
diggable = false,
|
||||
walkable = false,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
--- Hides all nodes in a region defined by positions `pos1` and `pos2` by
|
||||
-- non-destructively replacing them with invisible nodes.
|
||||
-- @return The number of nodes hidden.
|
||||
function worldedit.hide(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
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)
|
||||
if node.name ~= "air" and node.name ~= "worldedit:placeholder" then
|
||||
-- Save the node's original name
|
||||
get_meta(pos):set_string("worldedit_placeholder", node.name)
|
||||
-- Swap in placeholder node
|
||||
node.name = "worldedit:placeholder"
|
||||
swap_node(pos, node)
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
return worldedit.volume(pos1, pos2)
|
||||
end
|
||||
|
||||
--- Suppresses all instances of `node_name` in a region defined by positions
|
||||
-- `pos1` and `pos2` by non-destructively replacing them with invisible nodes.
|
||||
-- @return The number of nodes suppressed.
|
||||
function worldedit.suppress(pos1, pos2, node_name)
|
||||
-- Ignore placeholder supression
|
||||
if node_name == "worldedit:placeholder" then
|
||||
return 0
|
||||
end
|
||||
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local nodes = minetest.find_nodes_in_area(pos1, pos2, node_name)
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
for _, pos in ipairs(nodes) do
|
||||
local node = get_node(pos)
|
||||
-- Save the node's original name
|
||||
get_meta(pos):set_string("worldedit_placeholder", node.name)
|
||||
-- Swap in placeholder node
|
||||
node.name = "worldedit:placeholder"
|
||||
swap_node(pos, node)
|
||||
end
|
||||
return #nodes
|
||||
end
|
||||
|
||||
--- Highlights all instances of `node_name` in a region defined by positions
|
||||
-- `pos1` and `pos2` by non-destructively hiding all other nodes.
|
||||
-- @return The number of nodes found.
|
||||
function worldedit.highlight(pos1, pos2, node_name)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local pos = {x=pos1.x, y=0, z=0}
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
local count = 0
|
||||
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)
|
||||
if node.name == node_name then -- Node found
|
||||
count = count + 1
|
||||
elseif node.name ~= "worldedit:placeholder" then -- Hide other nodes
|
||||
-- Save the node's original name
|
||||
get_meta(pos):set_string("worldedit_placeholder", node.name)
|
||||
-- Swap in placeholder node
|
||||
node.name = "worldedit:placeholder"
|
||||
swap_node(pos, node)
|
||||
end
|
||||
pos.z = pos.z + 1
|
||||
end
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
pos.x = pos.x + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Restores all nodes hidden with WorldEdit functions in a region defined
|
||||
-- by positions `pos1` and `pos2`.
|
||||
-- @return The number of nodes restored.
|
||||
function worldedit.restore(pos1, pos2)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local nodes = minetest.find_nodes_in_area(pos1, pos2, "worldedit:placeholder")
|
||||
local get_node, get_meta, swap_node = minetest.get_node,
|
||||
minetest.get_meta, minetest.swap_node
|
||||
for _, pos in ipairs(nodes) do
|
||||
local node = get_node(pos)
|
||||
local meta = get_meta(pos)
|
||||
local data = meta:to_table()
|
||||
node.name = data.fields.worldedit_placeholder
|
||||
data.fields.worldedit_placeholder = nil
|
||||
meta:from_table(data)
|
||||
swap_node(pos, node)
|
||||
end
|
||||
return #nodes
|
||||
end
|
||||
|
0
minetestforfun-bros/mods/WorldEdit/worldedit_commands/depends.txt → mods/WorldEdit/worldedit_commands/depends.txt
Executable file → Normal file
2320
minetestforfun-bros/mods/WorldEdit/worldedit_commands/init.lua → mods/WorldEdit/worldedit_commands/init.lua
Executable file → Normal file
324
minetestforfun-bros/mods/WorldEdit/worldedit_commands/mark.lua → mods/WorldEdit/worldedit_commands/mark.lua
Executable file → Normal file
@ -1,162 +1,162 @@
|
||||
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]
|
||||
|
||||
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
|
||||
--add marker
|
||||
worldedit.marker1[name] = minetest.add_entity(pos1, "worldedit:pos1")
|
||||
if worldedit.marker1[name] ~= nil then
|
||||
worldedit.marker1[name]:get_luaentity().player_name = name
|
||||
end
|
||||
end
|
||||
worldedit.mark_region(name)
|
||||
end
|
||||
|
||||
--marks worldedit region position 2
|
||||
worldedit.mark_pos2 = function(name)
|
||||
local pos1, pos2 = worldedit.pos1[name], 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
|
||||
--add marker
|
||||
worldedit.marker2[name] = minetest.add_entity(pos2, "worldedit:pos2")
|
||||
if worldedit.marker2[name] ~= nil then
|
||||
worldedit.marker2[name]:get_luaentity().player_name = name
|
||||
end
|
||||
end
|
||||
worldedit.mark_region(name)
|
||||
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
|
||||
worldedit.marker_region[name] = nil
|
||||
end
|
||||
if pos1 ~= nil and pos2 ~= nil then
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
local thickness = 0.2
|
||||
local sizex, sizey, sizez = (1 + pos2.x - pos1.x) / 2, (1 + pos2.y - pos1.y) / 2, (1 + pos2.z - pos1.z) / 2
|
||||
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos2)
|
||||
|
||||
local markers = {}
|
||||
|
||||
--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")
|
||||
marker:set_properties({
|
||||
visual_size={x=sizex * 2, y=sizey * 2},
|
||||
collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness},
|
||||
})
|
||||
marker:get_luaentity().player_name = name
|
||||
table.insert(markers, marker)
|
||||
end
|
||||
|
||||
--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")
|
||||
marker:set_properties({
|
||||
visual_size={x=sizez * 2, y=sizey * 2},
|
||||
collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez},
|
||||
})
|
||||
marker:setyaw(math.pi / 2)
|
||||
marker:get_luaentity().player_name = name
|
||||
table.insert(markers, marker)
|
||||
end
|
||||
|
||||
worldedit.marker_region[name] = markers
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity(":worldedit:pos1", {
|
||||
initial_properties = {
|
||||
visual = "cube",
|
||||
visual_size = {x=1.1, y=1.1},
|
||||
textures = {"worldedit_pos1.png", "worldedit_pos1.png",
|
||||
"worldedit_pos1.png", "worldedit_pos1.png",
|
||||
"worldedit_pos1.png", "worldedit_pos1.png"},
|
||||
collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
|
||||
physical = false,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker1[self.player_name] == nil then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, hitter)
|
||||
self.object:remove()
|
||||
worldedit.marker1[self.player_name] = nil
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_entity(":worldedit:pos2", {
|
||||
initial_properties = {
|
||||
visual = "cube",
|
||||
visual_size = {x=1.1, y=1.1},
|
||||
textures = {"worldedit_pos2.png", "worldedit_pos2.png",
|
||||
"worldedit_pos2.png", "worldedit_pos2.png",
|
||||
"worldedit_pos2.png", "worldedit_pos2.png"},
|
||||
collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
|
||||
physical = false,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker2[self.player_name] == nil then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, hitter)
|
||||
self.object:remove()
|
||||
worldedit.marker2[self.player_name] = nil
|
||||
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,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker_region[self.player_name] == nil then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, hitter)
|
||||
for _, entity in ipairs(worldedit.marker_region[self.player_name]) do
|
||||
entity:remove()
|
||||
end
|
||||
worldedit.marker_region[self.player_name] = nil
|
||||
end,
|
||||
})
|
||||
|
||||
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]
|
||||
|
||||
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
|
||||
--add marker
|
||||
worldedit.marker1[name] = minetest.add_entity(pos1, "worldedit:pos1")
|
||||
if worldedit.marker1[name] ~= nil then
|
||||
worldedit.marker1[name]:get_luaentity().player_name = name
|
||||
end
|
||||
end
|
||||
worldedit.mark_region(name)
|
||||
end
|
||||
|
||||
--marks worldedit region position 2
|
||||
worldedit.mark_pos2 = function(name)
|
||||
local pos1, pos2 = worldedit.pos1[name], 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
|
||||
--add marker
|
||||
worldedit.marker2[name] = minetest.add_entity(pos2, "worldedit:pos2")
|
||||
if worldedit.marker2[name] ~= nil then
|
||||
worldedit.marker2[name]:get_luaentity().player_name = name
|
||||
end
|
||||
end
|
||||
worldedit.mark_region(name)
|
||||
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
|
||||
worldedit.marker_region[name] = nil
|
||||
end
|
||||
if pos1 ~= nil and pos2 ~= nil then
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
local thickness = 0.2
|
||||
local sizex, sizey, sizez = (1 + pos2.x - pos1.x) / 2, (1 + pos2.y - pos1.y) / 2, (1 + pos2.z - pos1.z) / 2
|
||||
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos2)
|
||||
|
||||
local markers = {}
|
||||
|
||||
--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")
|
||||
marker:set_properties({
|
||||
visual_size={x=sizex * 2, y=sizey * 2},
|
||||
collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness},
|
||||
})
|
||||
marker:get_luaentity().player_name = name
|
||||
table.insert(markers, marker)
|
||||
end
|
||||
|
||||
--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")
|
||||
marker:set_properties({
|
||||
visual_size={x=sizez * 2, y=sizey * 2},
|
||||
collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez},
|
||||
})
|
||||
marker:setyaw(math.pi / 2)
|
||||
marker:get_luaentity().player_name = name
|
||||
table.insert(markers, marker)
|
||||
end
|
||||
|
||||
worldedit.marker_region[name] = markers
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity(":worldedit:pos1", {
|
||||
initial_properties = {
|
||||
visual = "cube",
|
||||
visual_size = {x=1.1, y=1.1},
|
||||
textures = {"worldedit_pos1.png", "worldedit_pos1.png",
|
||||
"worldedit_pos1.png", "worldedit_pos1.png",
|
||||
"worldedit_pos1.png", "worldedit_pos1.png"},
|
||||
collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
|
||||
physical = false,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker1[self.player_name] == nil then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, hitter)
|
||||
self.object:remove()
|
||||
worldedit.marker1[self.player_name] = nil
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_entity(":worldedit:pos2", {
|
||||
initial_properties = {
|
||||
visual = "cube",
|
||||
visual_size = {x=1.1, y=1.1},
|
||||
textures = {"worldedit_pos2.png", "worldedit_pos2.png",
|
||||
"worldedit_pos2.png", "worldedit_pos2.png",
|
||||
"worldedit_pos2.png", "worldedit_pos2.png"},
|
||||
collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
|
||||
physical = false,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker2[self.player_name] == nil then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, hitter)
|
||||
self.object:remove()
|
||||
worldedit.marker2[self.player_name] = nil
|
||||
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,
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
if worldedit.marker_region[self.player_name] == nil then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, hitter)
|
||||
for _, entity in ipairs(worldedit.marker_region[self.player_name]) do
|
||||
entity:remove()
|
||||
end
|
||||
worldedit.marker_region[self.player_name] = nil
|
||||
end,
|
||||
})
|
||||
|
136
minetestforfun-bros/mods/WorldEdit/worldedit_commands/safe.lua → mods/WorldEdit/worldedit_commands/safe.lua
Executable file → Normal file
@ -1,68 +1,68 @@
|
||||
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
|
||||
|
||||
--`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")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("/y", {
|
||||
params = "",
|
||||
description = "Confirm a pending operation",
|
||||
func = function(name)
|
||||
local callback, param = safe_region_callback[name], safe_region_param[name]
|
||||
if not callback then
|
||||
worldedit.player_notify(name, "no operation pending")
|
||||
return
|
||||
end
|
||||
|
||||
--obtain positions
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
if pos1 == nil or pos2 == nil then
|
||||
worldedit.player_notify(name, "no region selected")
|
||||
return
|
||||
end
|
||||
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil --reset pending operation
|
||||
callback(name, param, pos1, pos2)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("/n", {
|
||||
params = "",
|
||||
description = "Confirm a pending operation",
|
||||
func = function(name)
|
||||
if not safe_region_callback[name] then
|
||||
worldedit.player_notify(name, "no operation pending")
|
||||
return
|
||||
end
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil
|
||||
end,
|
||||
})
|
||||
|
||||
return safe_region, check_region
|
||||
|
||||
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
|
||||
|
||||
--`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")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("/y", {
|
||||
params = "",
|
||||
description = "Confirm a pending operation",
|
||||
func = function(name)
|
||||
local callback, param = safe_region_callback[name], safe_region_param[name]
|
||||
if not callback then
|
||||
worldedit.player_notify(name, "no operation pending")
|
||||
return
|
||||
end
|
||||
|
||||
--obtain positions
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
if pos1 == nil or pos2 == nil then
|
||||
worldedit.player_notify(name, "no region selected")
|
||||
return
|
||||
end
|
||||
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil --reset pending operation
|
||||
callback(name, param, pos1, pos2)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("/n", {
|
||||
params = "",
|
||||
description = "Confirm a pending operation",
|
||||
func = function(name)
|
||||
if not safe_region_callback[name] then
|
||||
worldedit.player_notify(name, "no operation pending")
|
||||
return
|
||||
end
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil
|
||||
end,
|
||||
})
|
||||
|
||||
return safe_region, check_region
|
||||
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 134 B |
0
minetestforfun-bros/mods/WorldEdit/worldedit_gui/depends.txt → mods/WorldEdit/worldedit_gui/depends.txt
Executable file → Normal file
1314
minetestforfun-bros/mods/WorldEdit/worldedit_gui/functionality.lua → mods/WorldEdit/worldedit_gui/functionality.lua
Executable file → Normal file
0
minetestforfun-bros/mods/WorldEdit/worldedit_gui/init.lua → mods/WorldEdit/worldedit_gui/init.lua
Executable file → Normal file
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
0
minetestforfun-bros/mods/WorldEdit/worldedit_infinity/depends.txt → mods/WorldEdit/worldedit_infinity/depends.txt
Executable file → Normal file
206
minetestforfun-bros/mods/WorldEdit/worldedit_infinity/init.lua → mods/WorldEdit/worldedit_infinity/init.lua
Executable file → Normal file
@ -1,103 +1,103 @@
|
||||
worldedit = rawget(_G, "worldedit") or {}
|
||||
local minetest = minetest --local copy of global
|
||||
|
||||
local get_pointed = function(pos, nearest, distance)
|
||||
if distance > 100 then
|
||||
return false
|
||||
end
|
||||
|
||||
--check for collision with node
|
||||
local nodename = minetest.get_node(pos).name
|
||||
if nodename ~= "air"
|
||||
and nodename ~= "default:water_source"
|
||||
and nodename ~= "default:water_flowing" then
|
||||
if nodename ~= "ignore" then
|
||||
return nearest
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "nothing" then --pointing at nothing
|
||||
local placepos = worldedit.raytrace(user:getpos(), user:get_look_dir(), get_pointed)
|
||||
if placepos then --extended reach
|
||||
pointed_thing.type = "node"
|
||||
pointed_thing.under = nil --wip
|
||||
pointed_thing.above = nil --wip
|
||||
end
|
||||
end
|
||||
return minetest.item_place_node(itemstack, user, pointed_thing)
|
||||
end
|
||||
--
|
||||
|
||||
worldedit.raytrace = function(pos, dir, callback)
|
||||
local base = {x=math.floor(pos.x), y=math.floor(pos.y), z=math.floor(pos.z)}
|
||||
local stepx, stepy, stepz = 0, 0, 0
|
||||
local componentx, componenty, componentz = 0, 0, 0
|
||||
local intersectx, intersecty, intersectz = 0, 0, 0
|
||||
|
||||
if dir.x == 0 then
|
||||
intersectx = math.huge
|
||||
elseif dir.x > 0 then
|
||||
stepx = 1
|
||||
componentx = 1 / dir.x
|
||||
intersectx = ((base.x - pos.x) + 1) * componentx
|
||||
else
|
||||
stepx = -1
|
||||
componentx = 1 / -dir.x
|
||||
intersectx = (pos.x - base.x) * componentx
|
||||
end
|
||||
if dir.y == 0 then
|
||||
intersecty = math.huge
|
||||
elseif dir.y > 0 then
|
||||
stepy = 1
|
||||
componenty = 1 / dir.y
|
||||
intersecty = ((base.y - pos.y) + 1) * componenty
|
||||
else
|
||||
stepy = -1
|
||||
componenty = 1 / -dir.y
|
||||
intersecty = (pos.y - base.y) * componenty
|
||||
end
|
||||
if dir.z == 0 then
|
||||
intersectz = math.huge
|
||||
elseif dir.z > 0 then
|
||||
stepz = 1
|
||||
componentz = 1 / dir.z
|
||||
intersectz = ((base.z - pos.z) + 1) * componentz
|
||||
else
|
||||
stepz = -1
|
||||
componentz = 1 / -dir.z
|
||||
intersectz = (pos.z - base.z) * componentz
|
||||
end
|
||||
|
||||
local distance = 0
|
||||
local nearest = {x=base.x, y=base.y, z=base.z}
|
||||
while true do
|
||||
local values = {callback(base, nearest, distance)}
|
||||
if #values > 0 then
|
||||
return unpack(values)
|
||||
end
|
||||
|
||||
nearest.x, nearest.y, nearest.z = base.x, base.y, base.z
|
||||
if intersectx < intersecty then
|
||||
if intersectx < intersectz then
|
||||
base.x = base.x + stepx
|
||||
distance = intersectx
|
||||
intersectx = intersectx + componentx
|
||||
else
|
||||
base.z = base.z + stepz
|
||||
distance = intersectz
|
||||
intersectz = intersectz + componentz
|
||||
end
|
||||
elseif intersecty < intersectz then
|
||||
base.y = base.y + stepy
|
||||
distance = intersecty
|
||||
intersecty = intersecty + componenty
|
||||
else
|
||||
base.z = base.z + stepz
|
||||
distance = intersectz
|
||||
intersectz = intersectz + componentz
|
||||
end
|
||||
end
|
||||
end
|
||||
worldedit = rawget(_G, "worldedit") or {}
|
||||
local minetest = minetest --local copy of global
|
||||
|
||||
local get_pointed = function(pos, nearest, distance)
|
||||
if distance > 100 then
|
||||
return false
|
||||
end
|
||||
|
||||
--check for collision with node
|
||||
local nodename = minetest.get_node(pos).name
|
||||
if nodename ~= "air"
|
||||
and nodename ~= "default:water_source"
|
||||
and nodename ~= "default:water_flowing" then
|
||||
if nodename ~= "ignore" then
|
||||
return nearest
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "nothing" then --pointing at nothing
|
||||
local placepos = worldedit.raytrace(user:getpos(), user:get_look_dir(), get_pointed)
|
||||
if placepos then --extended reach
|
||||
pointed_thing.type = "node"
|
||||
pointed_thing.under = nil --wip
|
||||
pointed_thing.above = nil --wip
|
||||
end
|
||||
end
|
||||
return minetest.item_place_node(itemstack, user, pointed_thing)
|
||||
end
|
||||
--
|
||||
|
||||
worldedit.raytrace = function(pos, dir, callback)
|
||||
local base = {x=math.floor(pos.x), y=math.floor(pos.y), z=math.floor(pos.z)}
|
||||
local stepx, stepy, stepz = 0, 0, 0
|
||||
local componentx, componenty, componentz = 0, 0, 0
|
||||
local intersectx, intersecty, intersectz = 0, 0, 0
|
||||
|
||||
if dir.x == 0 then
|
||||
intersectx = math.huge
|
||||
elseif dir.x > 0 then
|
||||
stepx = 1
|
||||
componentx = 1 / dir.x
|
||||
intersectx = ((base.x - pos.x) + 1) * componentx
|
||||
else
|
||||
stepx = -1
|
||||
componentx = 1 / -dir.x
|
||||
intersectx = (pos.x - base.x) * componentx
|
||||
end
|
||||
if dir.y == 0 then
|
||||
intersecty = math.huge
|
||||
elseif dir.y > 0 then
|
||||
stepy = 1
|
||||
componenty = 1 / dir.y
|
||||
intersecty = ((base.y - pos.y) + 1) * componenty
|
||||
else
|
||||
stepy = -1
|
||||
componenty = 1 / -dir.y
|
||||
intersecty = (pos.y - base.y) * componenty
|
||||
end
|
||||
if dir.z == 0 then
|
||||
intersectz = math.huge
|
||||
elseif dir.z > 0 then
|
||||
stepz = 1
|
||||
componentz = 1 / dir.z
|
||||
intersectz = ((base.z - pos.z) + 1) * componentz
|
||||
else
|
||||
stepz = -1
|
||||
componentz = 1 / -dir.z
|
||||
intersectz = (pos.z - base.z) * componentz
|
||||
end
|
||||
|
||||
local distance = 0
|
||||
local nearest = {x=base.x, y=base.y, z=base.z}
|
||||
while true do
|
||||
local values = {callback(base, nearest, distance)}
|
||||
if #values > 0 then
|
||||
return unpack(values)
|
||||
end
|
||||
|
||||
nearest.x, nearest.y, nearest.z = base.x, base.y, base.z
|
||||
if intersectx < intersecty then
|
||||
if intersectx < intersectz then
|
||||
base.x = base.x + stepx
|
||||
distance = intersectx
|
||||
intersectx = intersectx + componentx
|
||||
else
|
||||
base.z = base.z + stepz
|
||||
distance = intersectz
|
||||
intersectz = intersectz + componentz
|
||||
end
|
||||
elseif intersecty < intersectz then
|
||||
base.y = base.y + stepy
|
||||
distance = intersecty
|
||||
intersecty = intersecty + componenty
|
||||
else
|
||||
base.z = base.z + stepz
|
||||
distance = intersectz
|
||||
intersectz = intersectz + componentz
|
||||
end
|
||||
end
|
||||
end
|
0
minetestforfun-bros/mods/WorldEdit/worldedit_limited/depends.txt → mods/WorldEdit/worldedit_limited/depends.txt
Executable file → Normal file
0
minetestforfun-bros/mods/WorldEdit/worldedit_limited/init.lua → mods/WorldEdit/worldedit_limited/init.lua
Executable file → Normal file
2
minetestforfun-bros/mods/WorldEdit/worldedit_shortcommands/depends.txt → mods/WorldEdit/worldedit_shortcommands/depends.txt
Executable file → Normal file
@ -1 +1 @@
|
||||
worldedit_commands
|
||||
worldedit_commands
|
98
minetestforfun-bros/mods/WorldEdit/worldedit_shortcommands/init.lua → mods/WorldEdit/worldedit_shortcommands/init.lua
Executable file → Normal file
@ -1,50 +1,50 @@
|
||||
--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
|
||||
end
|
||||
if minetest.chatcommands[alias] then
|
||||
minetest.log("error", "worldedit_shortcommands: alias " .. alias .. " already exists")
|
||||
return true
|
||||
end
|
||||
minetest.register_chatcommand(alias, minetest.chatcommands[original_command])
|
||||
return false
|
||||
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("/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("/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")
|
||||
--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
|
||||
end
|
||||
if minetest.chatcommands[alias] then
|
||||
minetest.log("error", "worldedit_shortcommands: alias " .. alias .. " already exists")
|
||||
return true
|
||||
end
|
||||
minetest.register_chatcommand(alias, minetest.chatcommands[original_command])
|
||||
return false
|
||||
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("/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("/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")
|
0
minetestforfun-bros/mods/construct/init.lua → mods/construct/init.lua
Executable file → Normal file
0
minetestforfun-bros/mods/construct/parcours/nodes.txt → mods/construct/parcours/nodes.txt
Executable file → Normal file
0
minetestforfun-bros/mods/construct/parcours/parcours1.txt → mods/construct/parcours/parcours1.txt
Executable file → Normal file
0
minetestforfun-bros/mods/creative/README.txt → mods/creative/README.txt
Executable file → Normal file
0
minetestforfun-bros/mods/creative/depends.txt → mods/creative/depends.txt
Executable file → Normal file
0
minetestforfun-bros/mods/creative/init.lua → mods/creative/init.lua
Executable file → Normal file
0
minetestforfun-bros/mods/default/engine.lua → mods/default/engine.lua
Executable file → Normal file
0
minetestforfun-bros/mods/default/functions.lua → mods/default/functions.lua
Executable file → Normal file
0
minetestforfun-bros/mods/default/init.lua → mods/default/init.lua
Executable file → Normal file
0
minetestforfun-bros/mods/default/mapgen.lua → mods/default/mapgen.lua
Executable file → Normal file
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |