infotext / nametag
This commit is contained in:
parent
c8622a4847
commit
0e24155cc9
@ -18,3 +18,9 @@ function pick_and_place.sort_pos(pos1, pos2)
|
||||
end
|
||||
return pos1, pos2
|
||||
end
|
||||
|
||||
function pick_and_place.get_formatted_size(pos1, pos2)
|
||||
pos2 = pos2 or pos1
|
||||
pos1, pos2 = pick_and_place.sort_pos(pos1, pos2)
|
||||
return minetest.pos_to_string(vector.add(vector.subtract(pos2, pos1), 1))
|
||||
end
|
@ -38,9 +38,11 @@ minetest.register_tool("pick_and_place:configure", {
|
||||
on_step = function(_, player)
|
||||
local playername = player:get_player_name()
|
||||
local pointed_pos = pick_and_place.get_pointed_position(player)
|
||||
local pointed_pos2 = pos1[playername]
|
||||
local text = pick_and_place.get_formatted_size(pointed_pos, pointed_pos2)
|
||||
|
||||
-- update preview
|
||||
pick_and_place.show_preview(playername, "pick_and_place.png", "#ffffff", pointed_pos, pos1[playername])
|
||||
pick_and_place.show_preview(playername, "pick_and_place.png", "#ffffff", pointed_pos, pointed_pos2, text)
|
||||
end,
|
||||
on_deselect = function(_, player)
|
||||
local playername = player:get_player_name()
|
||||
|
@ -32,10 +32,12 @@ minetest.register_tool("pick_and_place:pick", {
|
||||
on_step = function(_, player)
|
||||
local playername = player:get_player_name()
|
||||
local pointed_pos = pick_and_place.get_pointed_position(player)
|
||||
local pointed_pos2 = pos1[playername]
|
||||
|
||||
if pos1[playername] then
|
||||
if pointed_pos2 then
|
||||
-- first position already selected
|
||||
pick_and_place.show_preview(playername, "pick_and_place.png", "#00ff00", pointed_pos, pos1[playername])
|
||||
local text = pick_and_place.get_formatted_size(pointed_pos, pointed_pos2)
|
||||
pick_and_place.show_preview(playername, "pick_and_place.png", "#00ff00", pointed_pos, pointed_pos2, text)
|
||||
else
|
||||
-- nothing selected yet
|
||||
pick_and_place.show_preview(playername, "pick_and_place.png", "#00ff00", pointed_pos)
|
||||
|
@ -2,7 +2,7 @@
|
||||
-- playername => key
|
||||
local active_preview = {}
|
||||
|
||||
function pick_and_place.show_preview(playername, texture, color, pos1, pos2)
|
||||
function pick_and_place.show_preview(playername, texture, color, pos1, pos2, text)
|
||||
pos2 = pos2 or pos1
|
||||
texture = texture .. "^[colorize:" .. color
|
||||
|
||||
@ -11,7 +11,8 @@ function pick_and_place.show_preview(playername, texture, color, pos1, pos2)
|
||||
local key =
|
||||
minetest.pos_to_string(pos1) .. "/" ..
|
||||
minetest.pos_to_string(pos2) .. "/" ..
|
||||
texture
|
||||
texture .. "/" ..
|
||||
(text or "")
|
||||
|
||||
if active_preview[playername] == key then
|
||||
-- already active on the same region
|
||||
@ -28,6 +29,7 @@ function pick_and_place.show_preview(playername, texture, color, pos1, pos2)
|
||||
local ent = pick_and_place.add_entity(origin, key)
|
||||
ent:set_properties({
|
||||
visual_size = visual_size,
|
||||
nametag = text,
|
||||
textures = {
|
||||
texture,
|
||||
texture,
|
||||
|
Loading…
x
Reference in New Issue
Block a user