mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-08-18 20:04:04 +02:00
give builder items a little love
This commit is contained in:
parent
f83f5cba11
commit
61be57ed45
23
entities.lua
23
entities.lua
@ -158,6 +158,7 @@ digtron.remove_builder_item = function(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Used by unassembled builders
|
||||||
digtron.update_builder_item = function(pos)
|
digtron.update_builder_item = function(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if minetest.get_node_group(node.name, "digtron") ~= 4 then
|
if minetest.get_node_group(node.name, "digtron") ~= 4 then
|
||||||
@ -169,7 +170,27 @@ digtron.update_builder_item = function(pos)
|
|||||||
local item = meta:get_string("item")
|
local item = meta:get_string("item")
|
||||||
if item ~= "" then
|
if item ~= "" then
|
||||||
digtron.create_builder_item = item
|
digtron.create_builder_item = item
|
||||||
minetest.add_entity(target_pos,"digtron:builder_item")
|
safe_add_entity(target_pos,"digtron:builder_item")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Updates entire Digtron
|
||||||
|
digtron.update_builder_items = function(digtron_id)
|
||||||
|
local layout = digtron.get_layout(digtron_id)
|
||||||
|
local root_pos = digtron.get_pos(digtron_id)
|
||||||
|
|
||||||
|
for hash, data in pairs(layout) do
|
||||||
|
local node = data.node
|
||||||
|
if minetest.get_node_group(node.name, "digtron") == 4 then
|
||||||
|
local item = data.meta.fields.item
|
||||||
|
local pos = vector.add(minetest.get_position_from_hash(hash), root_pos)
|
||||||
|
local target_pos = vector.add(pos, minetest.facedir_to_dir(node.param2))
|
||||||
|
digtron.remove_builder_item(target_pos)
|
||||||
|
if item ~= "" then
|
||||||
|
digtron.create_builder_item = item
|
||||||
|
safe_add_entity(target_pos,"digtron:builder_item")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -191,7 +191,6 @@ end
|
|||||||
local persist_layout, retrieve_layout = get_table_functions("layout")
|
local persist_layout, retrieve_layout = get_table_functions("layout")
|
||||||
local persist_pos, retrieve_pos, dispose_pos = get_table_functions("pos")
|
local persist_pos, retrieve_pos, dispose_pos = get_table_functions("pos")
|
||||||
local persist_sequence, retrieve_sequence = get_table_functions("sequence")
|
local persist_sequence, retrieve_sequence = get_table_functions("sequence")
|
||||||
local persist_step, retrieve_step = get_table_functions("step") -- actually just an integer, but table_functions works for that too
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------
|
||||||
-- Layout creation helpers
|
-- Layout creation helpers
|
||||||
@ -1383,8 +1382,6 @@ digtron.get_bounding_box = retrieve_bounding_box
|
|||||||
digtron.get_inventory = retrieve_inventory
|
digtron.get_inventory = retrieve_inventory
|
||||||
digtron.set_sequence = persist_sequence
|
digtron.set_sequence = persist_sequence
|
||||||
digtron.get_sequence = retrieve_sequence
|
digtron.get_sequence = retrieve_sequence
|
||||||
digtron.set_step = persist_step
|
|
||||||
digtron.get_step = retrieve_step
|
|
||||||
|
|
||||||
-- Used by duplicator
|
-- Used by duplicator
|
||||||
digtron.get_layout = retrieve_layout
|
digtron.get_layout = retrieve_layout
|
||||||
|
@ -128,6 +128,7 @@ local builder_on_rightclick = function(pos, node, clicker, itemstack, pointed_th
|
|||||||
if digtron_id ~= "" then
|
if digtron_id ~= "" then
|
||||||
minetest.sound_play({name = "digtron_error", gain = 0.1}, {to_player=player_name})
|
minetest.sound_play({name = "digtron_error", gain = 0.1}, {to_player=player_name})
|
||||||
minetest.chat_send_player(player_name, S("This Digtron is active, interact with it via the controller node."))
|
minetest.chat_send_player(player_name, S("This Digtron is active, interact with it via the controller node."))
|
||||||
|
digtron.update_builder_items(digtron_id)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user