Initial refactor

This commit is contained in:
VorTechnix 2024-10-09 20:35:45 -07:00
parent 9d85645444
commit d53f4f8702
No known key found for this signature in database
GPG key ID: 091E91A69545D5BA
25 changed files with 234 additions and 61 deletions

View file

@ -12,7 +12,7 @@ Note to self: See the bottom of this file for the release template text.
- Added [`//ngroups`](https://worldeditadditions.mooncarrot.space/Reference/#ngroups), which lists the groups that a given node is a member of. Useful when paired with [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply)! - Added [`//ngroups`](https://worldeditadditions.mooncarrot.space/Reference/#ngroups), which lists the groups that a given node is a member of. Useful when paired with [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply)!
- Added [`//rotate+`](https://worldeditadditions.mooncarrot.space/Reference/#rotate) to rotate regions through arbitrary series of potentially non-axis-aligned rotations. **Does not support slabs/stairs yet,** but this is on the todo list! - Added [`//rotate+`](https://worldeditadditions.mooncarrot.space/Reference/#rotate) to rotate regions through arbitrary series of potentially non-axis-aligned rotations. **Does not support slabs/stairs yet,** but this is on the todo list!
- Added [`//speed`](https://worldeditadditions.mooncarrot.space/Reference/#speed) to adjust your own movement speed - Added [`//speed`](https://worldeditadditions.mooncarrot.space/Reference/#speed) to adjust your own movement speed
- Also added an associated [movement speed adjustment tool](https://worldeditadditions.mooncarrot.space/Reference/#movement), which looks like this: ![A picture of the move speed adjustment tool. It looks like a monarch butterfly.](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/dev/worldeditadditions_farwand/textures/worldeditadditions_movement.png) - Also added an associated [movement speed adjustment tool](https://worldeditadditions.mooncarrot.space/Reference/#movement), which looks like this: ![A picture of the move speed adjustment tool. It looks like a monarch butterfly.](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/dev/worldeditadditions_tools/textures/worldeditadditions_movement.png)
- Added [`//set+`](https://worldeditadditions.mooncarrot.space/Reference/#set) for setting nodes and param2/light levels quickly. - Added [`//set+`](https://worldeditadditions.mooncarrot.space/Reference/#set) for setting nodes and param2/light levels quickly.
- NOTE TO SELF: Setting light values doesn't appear to be working very well for some reason - NOTE TO SELF: Setting light values doesn't appear to be working very well for some reason
- Added [`//ndef`](https://worldeditadditions.mooncarrot.space/Reference/#ndef) to print a given node's definition table. This is for debugging and development purposes. - Added [`//ndef`](https://worldeditadditions.mooncarrot.space/Reference/#ndef) to print a given node's definition table. This is for debugging and development purposes.
@ -63,7 +63,7 @@ Note to self: See the bottom of this file for the release template text.
- Add `//dome+`, which allows you to change the direction the dome is pointing in, and also create multiple domes at once - Add `//dome+`, which allows you to change the direction the dome is pointing in, and also create multiple domes at once
- Add `//metaball`, which renders 2 or more [metaballs](https://en.wikipedia.org/wiki/Metaballs) in Minetest - Add `//metaball`, which renders 2 or more [metaballs](https://en.wikipedia.org/wiki/Metaballs) in Minetest
- Significant backend refactoring to tidy things up - Significant backend refactoring to tidy things up
- Add new multi-point selection wand ![A picture of the multi-point wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_farwand/textures/worldeditadditions_multiwand.png) to select many points at once. - Add new multi-point selection wand ![A picture of the multi-point wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_tools/textures/worldeditadditions_multiwand.png) to select many points at once.
- Implement custom region boxing UI, which replaces the WorldEdit region box when using WorldEditAdditions wands. - Implement custom region boxing UI, which replaces the WorldEdit region box when using WorldEditAdditions wands.
- Is backwards compatible with regular WorldEdit wands and tools, as WorldEditAdditions keeps the new positioning system in sync with WorldEdit's. - Is backwards compatible with regular WorldEdit wands and tools, as WorldEditAdditions keeps the new positioning system in sync with WorldEdit's.
- The new multipoint wand required this as a prerequisite - The new multipoint wand required this as a prerequisite

View file

@ -11,7 +11,7 @@ Name | Description
--------------------------------|------------------------ --------------------------------|------------------------
`worldeditadditions` | The main mod. Core world manipulation implementations (backed by the `*_core` mod ref core and utility functions) should go in here. `worldeditadditions` | The main mod. Core world manipulation implementations (backed by the `*_core` mod ref core and utility functions) should go in here.
`worldeditadditions_commands` | Chat commands. These interact with the core manipulators in `worldeditadditions` mod. `worldeditadditions_commands` | Chat commands. These interact with the core manipulators in `worldeditadditions` mod.
`worldeditadditions_farwand` | Everything to do with the far wand tool, and now other tools like the cloud wand, multi-point wand, etc. It's different enough to everything else that it warrants it's own separate mod to avoid muddling things. `worldeditadditions_tools` | Everything to do with the far wand tool, and now other tools like the cloud wand, multi-point wand, etc. It's different enough to everything else that it warrants it's own separate mod to avoid muddling things.
`worldeditadditions_core` | Core components such as the positioning system (`worldeditadditions_core.pos`), the command registration function, and utility functions go in here. `worldeditadditions_core` | Core components such as the positioning system (`worldeditadditions_core.pos`), the command registration function, and utility functions go in here.
Additionally, every command should be implemented in its own file. This helps keep things organised and files short. Additionally, every command should be implemented in its own file. This helps keep things organised and files short.

View file

@ -1897,7 +1897,7 @@ Prevents the execution of a command if it could potentially affect a large numbe
--> -->
### Movement speed adjustment tool ### Movement speed adjustment tool
The movement speed adjustment tool, as the name suggests, adjusts your local player movement speed. It looks like this: ![A picture of the move speed adjustment tool. It looks like a monarch butterfly.](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/dev/worldeditadditions_farwand/textures/worldeditadditions_movement.png). The movement speed adjustment tool, as the name suggests, adjusts your local player movement speed. It looks like this: ![A picture of the move speed adjustment tool. It looks like a monarch butterfly.](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/dev/worldeditadditions_tools/textures/worldeditadditions_movement.png).
Primary (left) clicking will increase your movement speed, and secondary (right) clicking will decrease it in x0.5 increments, down to a minimum of x0.5. Primary (left) clicking will increase your movement speed, and secondary (right) clicking will decrease it in x0.5 increments, down to a minimum of x0.5.
@ -1908,7 +1908,7 @@ See also [`//speed`](#speed).
### Far Wand ### Far Wand
> Added in v1.7 > Added in v1.7
The far wand (`worldeditadditions:farwand`) is a variant on the traditional WorldEdit wand (`worldedit:wand`). It looks like this: ![A picture of the far wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_farwand/textures/worldeditadditions_farwand.png) The far wand (`worldeditadditions:farwand`) is a variant on the traditional WorldEdit wand (`worldedit:wand`). It looks like this: ![A picture of the far wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_tools/textures/worldeditadditions_tools.png)
It functions very similarly to the regular WorldEdit wand, except that it has a _much_ longer range - which can be very useful for working on large-scale terrain for example. It also comes with an associated command to control it. It functions very similarly to the regular WorldEdit wand, except that it has a _much_ longer range - which can be very useful for working on large-scale terrain for example. It also comes with an associated command to control it.
@ -1941,7 +1941,7 @@ Note that the number there isn't in blocks (because hard maths). It is however p
### Cloud Wand ### Cloud Wand
> Added in v1.11 > Added in v1.11
The cloud wand (`worldeditadditions:cloudwand`) is a another variant the above _Far Wand_. It looks like this: ![A picture of the far wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_farwand/textures/worldeditadditions_cloudwand.png) The cloud wand (`worldeditadditions:cloudwand`) is a another variant the above _Far Wand_. It looks like this: ![A picture of the far wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_tools/textures/worldeditadditions_cloudwand.png)
Unlike the other 2 wands, this wand functions in an additive manner. Left-click on a node to expand the currently defined region (creating a new one if one isn't defined already) to include that node. Right click to clear the currently defined region. Unlike the other 2 wands, this wand functions in an additive manner. Left-click on a node to expand the currently defined region (creating a new one if one isn't defined already) to include that node. Right click to clear the currently defined region.
@ -1953,7 +1953,7 @@ Note that punching out the positions **does not unset them**. Use `//reset` to r
### MultiPoint Wand ### MultiPoint Wand
> Added in v1.14 > Added in v1.14
The third type of wand provided by WorldEditAdditions is completely different, in that it allows you to select up to **999 points** at once! It looks like this: ![A picture of the multi-point wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_farwand/textures/worldeditadditions_multiwand.png) The third type of wand provided by WorldEditAdditions is completely different, in that it allows you to select up to **999 points** at once! It looks like this: ![A picture of the multi-point wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_tools/textures/worldeditadditions_multiwand.png)
It is important to note that (at present) the points selected by this wand **are not compatible with normal points**. This will change in the future, but requires a lot of work to implement. It is important to note that (at present) the points selected by this wand **are not compatible with normal points**. This will change in the future, but requires a lot of work to implement.

View file

@ -1,14 +0,0 @@
worldeditadditions.farwand = {
player_data = {}
}
local modpath = minetest.get_modpath("worldeditadditions_farwand")
dofile(modpath.."/lib/do_raycast.lua")
dofile(modpath.."/lib/farwand.lua")
dofile(modpath.."/lib/cloudwand.lua")
dofile(modpath.."/lib/multiwand.lua")
dofile(modpath.."/lib/movetool.lua")
dofile(modpath.."/lib/chatcommand.lua")
dofile(modpath.."/lib/settings.lua")

View file

@ -1,17 +0,0 @@
local wea_c = worldeditadditions_core
--- worldeditadditions.raycast() wrapper
function worldeditadditions.farwand.do_raycast(player)
if player == nil then return nil end
local player_name = player:get_player_name()
if worldeditadditions.farwand.player_data[player_name] == nil then
worldeditadditions.farwand.player_data[player_name] = { maxdist = 1000, skip_liquid = true }
end
local looking_pos, node_id = wea_c.raycast(
player,
worldeditadditions.farwand.player_data[player_name].maxdist,
worldeditadditions.farwand.player_data[player_name].skip_liquid
)
return looking_pos, node_id
end

View file

@ -1,3 +0,0 @@
name = worldeditadditions_farwand
description = worldeditadditions: convenient tool items
depends = worldedit, worldeditadditions

View file

@ -1,5 +1,5 @@
local wea_c = worldeditadditions_core local wea_c = worldeditadditions_core
local farwand = worldeditadditions.farwand -- Convenience shurtcut local farwand = worldeditadditions_tools -- Convenience shurtcut
local function parse_params_farwand(params_text) local function parse_params_farwand(params_text)
if params_text == nil then if params_text == nil then

View file

@ -0,0 +1,64 @@
-- ██ ██ ███████ █████ ████████ ██████ ██████ ██
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ █ ██ █████ ███████ ██ ██ ██ ██ ██ ██
-- ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███ ███ ███████ ██ ██ ██ ██████ ██████ ███████
local wea_c = worldeditadditions_core
local wea_t = worldeditadditions_tools
worldeditadditions_core.register_command("tool", {
params = "list || give|exists <tool name> ",
description = "Give WEA tools by name to the calling player or list available tools.",
privs = { worldedit = true, give = true },
require_pos = 0,
parse = function(params_text)
local ret = wea_c.split(params_text)
if #ret < 1 then return false, "Error: No params found!" end
local commands = {list = true, give = true, exists = true}
if not commands[ret[1]] then
return false, "Invalid command: "..ret[1]
end
if wea_t.registered_tools[ret[2]] or ret[1] == "list" then
return true, ret
else return false, "No such WEA tool: "..ret[2] end
end,
func = function(name, params_text)
if params_text[1] == "list" then
-- Return a list of available tools in rows of 7
local ret = "WEA Registered Tools:\n"
local i = 0
for k, _ in pairs(wea_t.registered_tools) do
i = i + 1
if i % 7 == 0 then ret = ret..k.."\n"
else ret = ret..k.." " end
end
return true, ret
elseif params_text[1] == "exists" then
-- NOTE: If tool did not exist it would be flagged by parse function
return true, "WEA tool \""..params_text[2].."\" exists"
else
-- Initiate player variable and check if it is a valid player
local player = minetest.get_player_by_name(name)
if not player or not player:is_player() then
return false, "\""..name.."\" is not a valid player."
end
-- Create inventory and item instances
local inv = player:get_inventory()
local item = "worldeditadditions:"..params_text[2]
-- Make sure the player doesn't already have the item and has room for it
if inv:contains_item("main", item) then
return false, name.." already has (a) \""..params_text[2].."\"."
elseif not inv:room_for_item("main", item) then
return false, name.." does not have room for (a) \""..params_text[2].."\"."
else
-- Give the player the item
inv:add_item("main", item)
return true, "Gave \""..params_text[2].."\" to "..name
end
end
end,
})

View file

@ -0,0 +1,24 @@
worldeditadditions_tools = {
player_data = {},
registered_tools = {},
}
local wea_t = worldeditadditions_tools
local modpath = minetest.get_modpath("worldeditadditions_tools")
-- Libraries
dofile(modpath.."/lib/do_raycast.lua")
dofile(modpath.."/lib/settings.lua")
wea_t.register_tool = dofile(modpath.."/lib/register_tool.lua")
-- Items
dofile(modpath.."/items/farwand.lua")
dofile(modpath.."/items/cloudwand.lua")
dofile(modpath.."/items/multiwand.lua")
dofile(modpath.."/items/movetool.lua")
-- Chat commands
dofile(modpath.."/commands/farwand_config.lua")
dofile(modpath.."/commands/weatool.lua")

View file

@ -1,7 +1,8 @@
local wea = worldeditadditions local wea = worldeditadditions
local wea_c = worldeditadditions_core local wea_c = worldeditadditions_core
local wea_t = worldeditadditions_tools
minetest.register_tool(":worldeditadditions:cloudwand", { wea_t.register_tool("cloudwand", {
description = "WorldEditAdditions far-reaching additive selector wand", description = "WorldEditAdditions far-reaching additive selector wand",
inventory_image = "worldeditadditions_cloudwand.png", inventory_image = "worldeditadditions_cloudwand.png",
@ -16,7 +17,7 @@ minetest.register_tool(":worldeditadditions:cloudwand", {
on_use = function(itemstack, player, pointed_thing) on_use = function(itemstack, player, pointed_thing)
local name = player:get_player_name() local name = player:get_player_name()
-- print("[farwand] on_use", name) -- print("[farwand] on_use", name)
local looking_pos, node_id = worldeditadditions.farwand.do_raycast(player) local looking_pos, node_id = worldeditadditions_tools.do_raycast(player)
wea.selection.add_point(name, looking_pos) wea.selection.add_point(name, looking_pos)
-- Left click when pointing at something or nothing -- Left click when pointing at something or nothing
end, end,

View file

@ -1,3 +1,5 @@
local wea_t = worldeditadditions_tools
local function set_pos1(name, pos) local function set_pos1(name, pos)
if pos ~= nil then if pos ~= nil then
-- print("[set_pos1]", name, "("..pos.x..", "..pos.y..", "..pos.z..")") -- print("[set_pos1]", name, "("..pos.x..", "..pos.y..", "..pos.z..")")
@ -21,23 +23,23 @@ local function set_pos2(name, pos)
end end
end end
minetest.register_tool(":worldeditadditions:farwand", { wea_t.register_tool("farwand", {
description = "WorldEditAdditions far-reaching wand", description = "WorldEditAdditions far-reaching wand",
inventory_image = "worldeditadditions_farwand.png", inventory_image = "worldeditadditions_tools.png",
on_place = function(itemstack, player, pointed_thing) on_place = function(itemstack, player, pointed_thing)
local name = player:get_player_name() local name = player:get_player_name()
-- print("[farwand] on_place", name) -- print("[farwand] on_place", name)
-- Right click when pointing at something -- Right click when pointing at something
-- Pointed thing: https://rubenwardy.com/minetest_modding_book/lua_api.html#pointed_thing -- Pointed thing: https://rubenwardy.com/minetest_modding_book/lua_api.html#pointed_thing
local looking_pos, node_id = worldeditadditions.farwand.do_raycast(player) local looking_pos, node_id = worldeditadditions_tools.do_raycast(player)
set_pos2(name, looking_pos) set_pos2(name, looking_pos)
end, end,
on_use = function(itemstack, player, pointed_thing) on_use = function(itemstack, player, pointed_thing)
local name = player:get_player_name() local name = player:get_player_name()
-- print("[farwand] on_use", name) -- print("[farwand] on_use", name)
local looking_pos, node_id = worldeditadditions.farwand.do_raycast(player) local looking_pos, node_id = worldeditadditions_tools.do_raycast(player)
set_pos1(name, looking_pos) set_pos1(name, looking_pos)
-- Left click when pointing at something or nothing -- Left click when pointing at something or nothing
end, end,
@ -47,7 +49,7 @@ minetest.register_tool(":worldeditadditions:farwand", {
-- Right click when pointing at nothing -- Right click when pointing at nothing
-- print("[farwand] on_secondary_use", name) -- print("[farwand] on_secondary_use", name)
local looking_pos, node_id = worldeditadditions.farwand.do_raycast(player) local looking_pos, node_id = worldeditadditions_tools.do_raycast(player)
set_pos2(name, looking_pos) set_pos2(name, looking_pos)
end end
}) })

View file

@ -1,7 +1,8 @@
local weac = worldeditadditions_core local wea_c = worldeditadditions_core
local wea_t = worldeditadditions_tools
local function adjust_speed_relative(player, offset) local function adjust_speed_relative(player, offset)
local overrides = weac.player_get_physics_override( local overrides = wea_c.player_get_physics_override(
player, "worldeditadditions_movetool" player, "worldeditadditions_movetool"
) )
if overrides == nil then overrides = {} end if overrides == nil then overrides = {} end
@ -10,7 +11,7 @@ local function adjust_speed_relative(player, offset)
local src_speed = overrides.speed or 1 local src_speed = overrides.speed or 1
local src_climb_speed = overrides.climb_speed or 1 local src_climb_speed = overrides.climb_speed or 1
weac.player_set_physics_override( wea_c.player_set_physics_override(
player, "worldeditadditions_movetool", { player, "worldeditadditions_movetool", {
speed = math.max(src_speed + offset, 0.5), speed = math.max(src_speed + offset, 0.5),
climb_speed = math.max(src_climb_speed + offset, 0.5) climb_speed = math.max(src_climb_speed + offset, 0.5)
@ -20,7 +21,7 @@ local function adjust_speed_relative(player, offset)
-- }) -- })
-- Completely paranoid is me -- Completely paranoid is me
local overrides_after = weac.player_get_physics_override( local overrides_after = wea_c.player_get_physics_override(
player, "worldeditadditions_movetool" player, "worldeditadditions_movetool"
) )
worldedit.player_notify(player:get_player_name(), "Movement speed is now x" .. tostring(overrides_after.speed)) worldedit.player_notify(player:get_player_name(), "Movement speed is now x" .. tostring(overrides_after.speed))
@ -36,7 +37,7 @@ local function use_secondary(player)
end end
minetest.register_tool(":worldeditadditions:movetool", { wea_t.register_tool("movetool", {
description = "WorldEditAdditions movement speed adjustment tool", description = "WorldEditAdditions movement speed adjustment tool",
inventory_image = "worldeditadditions_movement.png", inventory_image = "worldeditadditions_movement.png",

View file

@ -1,4 +1,5 @@
local wea_c = worldeditadditions_core local wea_c = worldeditadditions_core
local wea_t = worldeditadditions_tools
local wea = worldeditadditions local wea = worldeditadditions
local Vector3 = wea_c.Vector3 local Vector3 = wea_c.Vector3
@ -25,7 +26,7 @@ local function pop_pos(player_name)
end end
minetest.register_tool(":worldeditadditions:multiwand", { wea_t.register_tool("multiwand", {
description = "WorldEditAdditions multi-point wand", description = "WorldEditAdditions multi-point wand",
inventory_image = "worldeditadditions_multiwand.png", inventory_image = "worldeditadditions_multiwand.png",

View file

@ -0,0 +1,17 @@
local wea_c = worldeditadditions_core
--- worldeditadditions.raycast() wrapper
function worldeditadditions_tools.do_raycast(player)
if player == nil then return nil end
local player_name = player:get_player_name()
if worldeditadditions_tools.player_data[player_name] == nil then
worldeditadditions_tools.player_data[player_name] = { maxdist = 1000, skip_liquid = true }
end
local looking_pos, node_id = wea_c.raycast(
player,
worldeditadditions_tools.player_data[player_name].maxdist,
worldeditadditions_tools.player_data[player_name].skip_liquid
)
return looking_pos, node_id
end

View file

@ -0,0 +1,94 @@
-- ██████ ███████ ██████ ██ ███████ ████████ ███████ ██████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██████ █████ ██ ███ ██ ███████ ██ █████ ██████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ███████ ██████ ██ ███████ ██ ███████ ██ ██
--
-- ████████ ██████ ██████ ██
-- ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██
-- ██ ██████ ██████ ███████
--- WorldEditAdditions tool registration
-- A wrapper for registering tools for WorldEditAdditions.
-- @module worldeditadditions_core
local wea_t = worldeditadditions_tools
-- Helper functions --
local function log_error(toolname, error_message)
minetest.log("error", "register_tool("..toolname..") error: "..error_message)
end
local function log_warn(toolname, error_message)
minetest.log("warning", "register_tool("..toolname..") warning: "..error_message)
end
--- Registers a new WorldEditAdditions tool.
-- @param tool string The name of the tool to register.
-- @param options table A table of options for the tool:
-- - `description` (string) A description of the tool.
-- - `inventory_image` (string) The path to the image for the tool.
-- - `on_use` (function) A function that is called when right click while pointing at something.
-- - `on_place` (function) A function that is called when left click while pointing at something.
-- - `on_secondary_use` (function) A function that is called when left click while pointing at nothing.
-- - `stack_max` (number) The maximum number of the items that can be put in an ItemStack.
-- - `groups` (table) A table of groups that the tool belongs to.
local function register_tool(tool, options)
---
-- 1: Validation
---
if type(options.description) ~= "string" then
log_error(tool, "The description option is not a string.")
return false
end
if type(options.inventory_image) ~= "string" then
log_error(tool, "The inventory_image option is not a string.")
return false
end
if not options.inventory_image:match("^.+%.png$") then
log_error(tool, "The inventory_image option is not a valid image path.")
return false
end
if type(options.on_use) ~= "function" then
if options.on_use == nil then
log_warn(tool, "The on_use option is nil.")
else
log_error(tool, "The on_use option is not a function.")
return false
end
end
if type(options.on_place) ~= "function" then
if options.on_place == nil then
log_warn(tool, "The on_place option is nil.")
else
log_error(tool, "The on_place option is not a function.")
return false
end
end
if type(options.on_secondary_use) ~= "function" then
if options.on_secondary_use == nil then
log_warn(tool, "The on_secondary_use option is nil.")
else
log_error(tool, "The on_secondary_use option is not a function.")
return false
end
end
---
-- 2: Normalisation
---
if not options.stack_max then options.stack_max = 1 end
if not options.groups then options.groups = {wea = 1, wand = 1} end
---
-- 3: Registration
---
minetest.register_tool(":worldeditadditions:" .. tool, options)
wea_t.registered_tools[tool] = options
end
return register_tool

View file

@ -1,9 +1,9 @@
--- If the settings object for the given player name doesn't exist, it is created. --- If the settings object for the given player name doesn't exist, it is created.
-- @param name The name of the player to ensure has a settings object. -- @param name The name of the player to ensure has a settings object.
local function settings_init(name) local function settings_init(name)
if worldeditadditions.farwand.player_data[name] == nil then if worldeditadditions_tools.player_data[name] == nil then
minetest.log("INFO", "Initialising settings for "..name) minetest.log("INFO", "Initialising settings for "..name)
worldeditadditions.farwand.player_data[name] = { worldeditadditions_tools.player_data[name] = {
maxdist = 1000, maxdist = 1000,
skip_liquid = true skip_liquid = true
} }
@ -14,10 +14,10 @@ end
-- @param string name The name of the player to get the setting for. -- @param string name The name of the player to get the setting for.
-- @param string setting_name The name of the setting to fetch. -- @param string setting_name The name of the setting to fetch.
-- @return any The value of the setting. -- @return any The value of the setting.
function worldeditadditions.farwand.setting_get(name, setting_name) function worldeditadditions_tools.setting_get(name, setting_name)
if setting_name == nil then return nil end if setting_name == nil then return nil end
settings_init(name) settings_init(name)
return worldeditadditions.farwand.player_data[name][setting_name] return worldeditadditions_tools.player_data[name][setting_name]
end end
--- Sets a given farwand setting for the given player name to the given value. --- Sets a given farwand setting for the given player name to the given value.
@ -25,9 +25,9 @@ end
-- @param string setting_name The name of the setting to set. -- @param string setting_name The name of the setting to set.
-- @param any setting_value The value to set the setting to. -- @param any setting_value The value to set the setting to.
-- @return bool Whether setting the setting was successful or not. -- @return bool Whether setting the setting was successful or not.
function worldeditadditions.farwand.setting_set(name, setting_name, setting_value) function worldeditadditions_tools.setting_set(name, setting_name, setting_value)
if setting_name == nil then return false end if setting_name == nil then return false end
settings_init(name) settings_init(name)
worldeditadditions.farwand.player_data[name][setting_name] = setting_value worldeditadditions_tools.player_data[name][setting_name] = setting_value
return true return true
end end

View file

@ -0,0 +1,3 @@
name = worldeditadditions_tools
description = worldeditadditions: convenient tool items
depends = worldedit, worldeditadditions, worldeditadditions_core

View file

Before

Width:  |  Height:  |  Size: 715 B

After

Width:  |  Height:  |  Size: 715 B

View file

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 181 B

View file

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View file

Before

Width:  |  Height:  |  Size: 199 B

After

Width:  |  Height:  |  Size: 199 B

View file

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 229 B