mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-08-20 05:24:20 +02:00
refactor func names, move punchnode function
This commit is contained in:
parent
f79871e5d1
commit
5ffa67b7ac
@ -5,7 +5,7 @@
|
|||||||
-- ██████ ███████ ██████ ██████ ██████
|
-- ██████ ███████ ██████ ██████ ██████
|
||||||
worldeditadditions.add_pos = {}
|
worldeditadditions.add_pos = {}
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
function worldeditadditions.add_point(name, pos)
|
function worldeditadditions.selection.add_point(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..")")
|
||||||
if not worldedit.pos1[name] then worldedit.pos1[name] = vector.new(pos) end
|
if not worldedit.pos1[name] then worldedit.pos1[name] = vector.new(pos) end
|
||||||
@ -28,7 +28,7 @@ function worldeditadditions.add_point(name, pos)
|
|||||||
-- print("[set_pos1]", name, "nil")
|
-- print("[set_pos1]", name, "nil")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function worldeditadditions.clear_points(name, pos)
|
function worldeditadditions.selection.clear_points(name)
|
||||||
worldedit.pos1[name] = nil
|
worldedit.pos1[name] = nil
|
||||||
worldedit.pos2[name] = nil
|
worldedit.pos2[name] = nil
|
||||||
worldedit.marker_update(name)
|
worldedit.marker_update(name)
|
||||||
@ -36,13 +36,3 @@ function worldeditadditions.clear_points(name, pos)
|
|||||||
|
|
||||||
worldedit.player_notify(name, "Region cleared")
|
worldedit.player_notify(name, "Region cleared")
|
||||||
end
|
end
|
||||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
|
||||||
local name = puncher:get_player_name()
|
|
||||||
if name ~= "" and wea.add_pos[name] ~= nil then
|
|
||||||
if wea.add_pos[name] > 0 then
|
|
||||||
wea.add_point(name,pos)
|
|
||||||
wea.add_pos[name] = wea.add_pos[name] - 1
|
|
||||||
worldedit.player_notify(name, "You have "..wea.add_pos[name].." nodes left to punch")
|
|
||||||
else wea.add_pos[name] = nil end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
@ -4,6 +4,16 @@
|
|||||||
-- ██ ██ ██ ██ ██ ██ ██ ██ ██
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
-- ██████ ██████ ███████ ██████ ██████ ██████
|
-- ██████ ██████ ███████ ██████ ██████ ██████
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
|
minetest.register_on_punchnode(function(pos, node, puncher)
|
||||||
|
local name = puncher:get_player_name()
|
||||||
|
if name ~= "" and wea.add_pos[name] ~= nil then
|
||||||
|
if wea.add_pos[name] > 0 then
|
||||||
|
wea.selection.add_point(name,pos)
|
||||||
|
wea.add_pos[name] = wea.add_pos[name] - 1
|
||||||
|
worldedit.player_notify(name, "You have "..wea.add_pos[name].." nodes left to punch")
|
||||||
|
else wea.add_pos[name] = nil end
|
||||||
|
end
|
||||||
|
end)
|
||||||
worldedit.register_command("scloud", {
|
worldedit.register_command("scloud", {
|
||||||
params = "<0-6|stop|reset>",
|
params = "<0-6|stop|reset>",
|
||||||
description = "Set and add to WorldEdit region by punching up to six nodes that define the maximums of your target",
|
description = "Set and add to WorldEdit region by punching up to six nodes that define the maximums of your target",
|
||||||
@ -26,7 +36,7 @@ worldedit.register_command("scloud", {
|
|||||||
return true, "selection operation stopped"
|
return true, "selection operation stopped"
|
||||||
elseif param == "reset" then
|
elseif param == "reset" then
|
||||||
wea.add_pos[name] = nil
|
wea.add_pos[name] = nil
|
||||||
wea.clear_points(name)
|
wea.selection.clear_points(name)
|
||||||
return true, "selection cleared"
|
return true, "selection cleared"
|
||||||
else
|
else
|
||||||
return false, (param == "" and "no input" or "invalid input: '"..param).."'! Allowed params are: 0-6, stop, or reset"
|
return false, (param == "" and "no input" or "invalid input: '"..param).."'! Allowed params are: 0-6, stop, or reset"
|
||||||
|
@ -9,14 +9,14 @@ minetest.register_tool(":worldeditadditions:cloudwand", {
|
|||||||
-- 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
|
||||||
wea.clear_points(name)
|
wea.selection.clear_points(name)
|
||||||
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.farwand.do_raycast(player)
|
||||||
wea.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,
|
||||||
|
|
||||||
@ -25,6 +25,6 @@ minetest.register_tool(":worldeditadditions:cloudwand", {
|
|||||||
-- Right click when pointing at nothing
|
-- Right click when pointing at nothing
|
||||||
-- print("[farwand] on_secondary_use", name)
|
-- print("[farwand] on_secondary_use", name)
|
||||||
|
|
||||||
wea.clear_points(name)
|
wea.selection.clear_points(name)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user