Compare commits
3 Commits
0ec710cb03
...
4902d9bcee
Author | SHA1 | Date |
---|---|---|
Valentin Anger | 4902d9bcee | |
Valentin Anger | 6329fa31aa | |
Valentin Anger | 614aaf1dcc |
|
@ -0,0 +1,48 @@
|
|||
local NAME = minetest.get_current_modname()
|
||||
|
||||
local formspec =
|
||||
"size[5.5,2.75]" ..
|
||||
"textarea[0.5,0;3.5,3.5;name;Name;]" ..
|
||||
"button_exit[3.75,2;1.5,1;confirm;Confirm]" ..
|
||||
"bgcolor[#FC05E344;false]"
|
||||
|
||||
local player_pointed_pos = {}
|
||||
|
||||
minetest.register_tool(NAME .. ":nametag", {
|
||||
description = "Nametag",
|
||||
inventory_image = "nametag.png",
|
||||
stack_max = 128,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
-- TODO Check that nodes does not already interact with the grid
|
||||
if pointed_thing["type"] == "node" then
|
||||
local n = placer:get_player_name()
|
||||
player_pointed_pos[n] = pointed_thing.under
|
||||
minetest.show_formspec(n, NAME .. ":nametag", formspec)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, form, fields)
|
||||
if form ~= NAME .. ":nametag" then
|
||||
return false
|
||||
end
|
||||
|
||||
local p = player_pointed_pos[player:get_player_name()]
|
||||
|
||||
if p and fields.name then
|
||||
local meta = minetest.get_meta(p)
|
||||
meta:set_string("infotext", fields.name)
|
||||
return true
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = NAME .. ":nametag",
|
||||
recipe = {
|
||||
"farming:string", "default:paper"
|
||||
}
|
||||
})
|
Binary file not shown.
After Width: | Height: | Size: 379 B |
Binary file not shown.
After Width: | Height: | Size: 322 B |
Reference in New Issue