mirror of
git://repo.or.cz/minetest_schemedit.git
synced 2025-01-10 01:50:29 +01:00
Shift-punching creator with probtool updates creator region
This commit is contained in:
parent
c9377c0ddd
commit
0e2ae7cd86
42
init.lua
42
init.lua
@ -694,14 +694,24 @@ function advschem.display_node_prob(player, pos, prob, force_place)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Display the node probabilities and force_place status of the nodes near the player.
|
-- Display the node probabilities and force_place status of the nodes in a region.
|
||||||
function advschem.display_node_probs_around_player(player)
|
-- By default, this is done for nodes near the player (distance: 5).
|
||||||
|
-- But the boundaries can optionally be set explicitly with pos1 and pos2.
|
||||||
|
function advschem.display_node_probs_region(player, pos1, pos2)
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local pos = vector.round(player:getpos())
|
local pos = vector.round(player:getpos())
|
||||||
|
|
||||||
local dist = 5
|
local dist = 5
|
||||||
for x=pos.x-dist, pos.x+dist do
|
-- Default: 5 nodes away from player in any direction
|
||||||
for y=pos.y-dist, pos.y+dist do
|
if not pos1 then
|
||||||
for z=pos.z-dist, pos.z+dist do
|
pos1 = vector.subtract(pos, dist)
|
||||||
|
end
|
||||||
|
if not pos2 then
|
||||||
|
pos2 = vector.add(pos, dist)
|
||||||
|
end
|
||||||
|
for x=pos1.x, pos2.x do
|
||||||
|
for y=pos1.y, pos2.y do
|
||||||
|
for z=pos1.z, pos2.z do
|
||||||
local checkpos = {x=x, y=y, z=z}
|
local checkpos = {x=x, y=y, z=z}
|
||||||
local nodehash = minetest.hash_node_position(checkpos)
|
local nodehash = minetest.hash_node_position(checkpos)
|
||||||
|
|
||||||
@ -863,8 +873,24 @@ minetest.register_tool("advschem:probtool", {
|
|||||||
|
|
||||||
-- Use + sneak
|
-- Use + sneak
|
||||||
else
|
else
|
||||||
-- Enable node probablity display
|
-- Display the probability and force_place values for nodes.
|
||||||
advschem.display_node_probs_around_player(user)
|
|
||||||
|
-- If a schematic creator was punched, only enable display for all nodes
|
||||||
|
-- within the creator's region.
|
||||||
|
local use_creator_region = false
|
||||||
|
if pointed_thing and pointed_thing.type == "node" and pointed_thing.under then
|
||||||
|
punchpos = pointed_thing.under
|
||||||
|
local node = minetest.get_node(punchpos)
|
||||||
|
if node.name == "advschem:creator" then
|
||||||
|
local pos1, pos2 = advschem.size(punchpos)
|
||||||
|
pos1, pos2 = advschem.sort_pos(pos1, pos2)
|
||||||
|
advschem.display_node_probs_region(user, pos1, pos2)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Otherwise, just display the region close to the player
|
||||||
|
advschem.display_node_probs_region(user)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||||
@ -905,7 +931,7 @@ minetest.register_tool("advschem:probtool", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Enable node probablity display
|
-- Enable node probablity display
|
||||||
advschem.display_node_probs_around_player(placer)
|
advschem.display_node_probs_region(placer)
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user