mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-11-19 21:33:43 +01:00
Add visual markers for crated Digtron image
This commit is contained in:
parent
9ddec013de
commit
960d4e4155
21
crate.lua
21
crate.lua
@ -50,8 +50,10 @@ local loaded_formspec = "size[4,1.5]" ..
|
|||||||
default.gui_bg_img ..
|
default.gui_bg_img ..
|
||||||
default.gui_slots ..
|
default.gui_slots ..
|
||||||
"field[0.3,0.5;4,0.5;title;Digtron Name;${title}]" ..
|
"field[0.3,0.5;4,0.5;title;Digtron Name;${title}]" ..
|
||||||
"button_exit[0.5,1.2;1,0.1;save;Save Title]" ..
|
"button_exit[0.5,1.2;1,0.1;save;Save\nTitle]" ..
|
||||||
"tooltip[save;Saves the title of this Digtron]" ..
|
"tooltip[save;Saves the title of this Digtron]" ..
|
||||||
|
"button_exit[1.5,1.2;1,0.1;show;Show\nNodes]" ..
|
||||||
|
"tooltip[save;Shows what nodes the packed Digtron will occupy if unpacked]" ..
|
||||||
"button_exit[2.5,1.2;1,0.1;unpack;Unpack]" ..
|
"button_exit[2.5,1.2;1,0.1;unpack;Unpack]" ..
|
||||||
"tooltip[unpack;Attempts to unpack the Digtron on this location]"
|
"tooltip[unpack;Attempts to unpack the Digtron on this location]"
|
||||||
|
|
||||||
@ -71,18 +73,19 @@ minetest.register_node("digtron:loaded_crate", {
|
|||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
if fields.unpack or fields.save then
|
if fields.unpack or fields.save or fields.show then
|
||||||
meta:set_string("title", fields.title)
|
meta:set_string("title", fields.title)
|
||||||
meta:set_string("infotext", fields.title)
|
meta:set_string("infotext", fields.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not fields.unpack then
|
|
||||||
|
if not (fields.unpack or fields.show) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local layout_string = meta:get_string("crated_layout")
|
local layout_string = meta:get_string("crated_layout")
|
||||||
local layout = DigtronLayout.deserialize(layout_string)
|
local layout = DigtronLayout.deserialize(layout_string)
|
||||||
|
|
||||||
if layout == nil then
|
if layout == nil then
|
||||||
meta:set_string("infotext", meta:get_string("title") .. "\nUnable to read layout from crate metadata, regrettably this Digtron may be corrupted or lost.")
|
meta:set_string("infotext", meta:get_string("title") .. "\nUnable to read layout from crate metadata, regrettably this Digtron may be corrupted or lost.")
|
||||||
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
|
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
|
||||||
@ -90,6 +93,16 @@ minetest.register_node("digtron:loaded_crate", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for _, node_image in pairs(layout.all) do
|
||||||
|
if not vector.equals(pos, node_image.pos) then
|
||||||
|
minetest.add_entity(node_image.pos, "digtron:marker_crate")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not fields.unpack then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local pos_diff = vector.subtract(pos, layout.controller)
|
local pos_diff = vector.subtract(pos, layout.controller)
|
||||||
layout.controller = pos
|
layout.controller = pos
|
||||||
for _, node_image in pairs(layout.all) do
|
for _, node_image in pairs(layout.all) do
|
||||||
|
26
entities.lua
26
entities.lua
@ -50,6 +50,32 @@ minetest.register_entity("digtron:marker_vertical", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_entity("digtron:marker_crate", {
|
||||||
|
initial_properties = {
|
||||||
|
visual = "cube",
|
||||||
|
visual_size = {x=1.05, y=1.05},
|
||||||
|
textures = {"digtron_crate.png", "digtron_crate.png", "digtron_crate.png", "digtron_crate.png", "digtron_crate.png", "digtron_crate.png"},
|
||||||
|
collisionbox = {-0.525, -0.525, -0.525, 0.525, 0.525, 0.525},
|
||||||
|
physical = false,
|
||||||
|
},
|
||||||
|
|
||||||
|
on_activate = function(self, staticdata)
|
||||||
|
minetest.after(5.0,
|
||||||
|
function(self)
|
||||||
|
self.object:remove()
|
||||||
|
end,
|
||||||
|
self)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_rightclick=function(self, clicker)
|
||||||
|
self.object:remove()
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_punch = function(self, hitter)
|
||||||
|
self.object:remove()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_entity("digtron:builder_item", {
|
minetest.register_entity("digtron:builder_item", {
|
||||||
|
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
-- Note that inventories are digtron group 2.
|
-- Note that inventories are digtron group 2.
|
||||||
minetest.register_node("digtron:inventory",
|
minetest.register_node("digtron:inventory",
|
||||||
{
|
{
|
||||||
description = "Digtron Inventory Hopper",
|
description = "Digtron Inventory Storage",
|
||||||
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2, tubedevice = 1, tubedevice_receiver = 1},
|
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2, tubedevice = 1, tubedevice_receiver = 1},
|
||||||
drop = "digtron:inventory",
|
drop = "digtron:inventory",
|
||||||
sounds = digtron.metal_sounds,
|
sounds = digtron.metal_sounds,
|
||||||
paramtype2= "facedir",
|
paramtype2= "facedir",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
tiles = {"digtron_plate.png^digtron_inventory.png"},
|
tiles = {"digtron_plate.png^digtron_inventory.png"},
|
||||||
|
|
||||||
@ -61,11 +63,13 @@ minetest.register_node("digtron:inventory",
|
|||||||
-- Note that fuel stores are digtron group 5.
|
-- Note that fuel stores are digtron group 5.
|
||||||
minetest.register_node("digtron:fuelstore",
|
minetest.register_node("digtron:fuelstore",
|
||||||
{
|
{
|
||||||
description = "Digtron Fuel Hopper",
|
description = "Digtron Fuel Storage",
|
||||||
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5, tubedevice = 1, tubedevice_receiver = 1},
|
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5, tubedevice = 1, tubedevice_receiver = 1},
|
||||||
drop = "digtron:fuelstore",
|
drop = "digtron:fuelstore",
|
||||||
sounds = digtron.metal_sounds,
|
sounds = digtron.metal_sounds,
|
||||||
paramtype2= "facedir",
|
paramtype2= "facedir",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
tiles = {"digtron_plate.png^digtron_fuelstore.png"},
|
tiles = {"digtron_plate.png^digtron_fuelstore.png"},
|
||||||
|
|
||||||
@ -145,6 +149,8 @@ minetest.register_node("digtron:combined_storage",
|
|||||||
drop = "digtron:combined_storage",
|
drop = "digtron:combined_storage",
|
||||||
sounds = digtron.metal_sounds,
|
sounds = digtron.metal_sounds,
|
||||||
paramtype2= "facedir",
|
paramtype2= "facedir",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
tiles = {"digtron_plate.png^digtron_combined_storage.png"},
|
tiles = {"digtron_plate.png^digtron_combined_storage.png"},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user