mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-08-20 12:54:05 +02:00
fix name preservation, add stop button
This commit is contained in:
parent
1e776defd5
commit
6745446fcd
@ -65,7 +65,7 @@ digtron.default_sequence = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------
|
||||||
--- Maniupulating sequences
|
--- Manipulating sequences
|
||||||
|
|
||||||
-- searches down through the sequence tree to find the next command that can be executed
|
-- searches down through the sequence tree to find the next command that can be executed
|
||||||
local find_next_item_to_execute = function(sequence)
|
local find_next_item_to_execute = function(sequence)
|
||||||
@ -360,9 +360,14 @@ local sequence_tab = function(digtron_id)
|
|||||||
if sequence.cur == 0 then
|
if sequence.cur == 0 then
|
||||||
table.insert(list_out, "box[0.75,0.1;0.7,0.5;#FF000088]")
|
table.insert(list_out, "box[0.75,0.1;0.7,0.5;#FF000088]")
|
||||||
end
|
end
|
||||||
|
if is_cycling(digtron_id) then
|
||||||
|
table.insert(list_out, "button[1.5,0.1;1,0.5;stop;"..S("Stop").."]")
|
||||||
|
else
|
||||||
|
table.insert(list_out, "button[1.5,0.1;1,0.5;execute;"..S("Execute").."]")
|
||||||
|
end
|
||||||
|
|
||||||
table.insert(list_out,
|
table.insert(list_out,
|
||||||
"label[0.8,0.35;" .. S("@1 left", sequence.cur) .."]"
|
"label[0.8,0.35;" .. S("@1 left", sequence.cur) .."]"
|
||||||
.. "button[1.5,0.1;1,0.5;execute;"..S("Execute").."]" -- TODO pause
|
|
||||||
.. "button[2.5,0.1;1,0.5;reset;"..S("Reset").."]"
|
.. "button[2.5,0.1;1,0.5;reset;"..S("Reset").."]"
|
||||||
.. "container_end[]"
|
.. "container_end[]"
|
||||||
.. "container[0.2,1]"
|
.. "container[0.2,1]"
|
||||||
@ -444,6 +449,10 @@ local update_sequence = function(digtron_id, fields, player_name)
|
|||||||
start_command(digtron_id, "seq", 1, player_name)
|
start_command(digtron_id, "seq", 1, player_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if fields.stop and is_cycling(digtron_id) then
|
||||||
|
cancel_command(digtron_id)
|
||||||
|
end
|
||||||
|
|
||||||
if fields.reset then
|
if fields.reset then
|
||||||
cancel_command(digtron_id)
|
cancel_command(digtron_id)
|
||||||
reset_sequence(sequence)
|
reset_sequence(sequence)
|
||||||
@ -828,7 +837,7 @@ minetest.register_node("digtron:controller", combine_defs(base_def, {
|
|||||||
local stack = ItemStack({name=node.name, count=1, wear=0})
|
local stack = ItemStack({name=node.name, count=1, wear=0})
|
||||||
local stack_meta = stack:get_meta()
|
local stack_meta = stack:get_meta()
|
||||||
stack_meta:set_string("digtron_id", digtron_id)
|
stack_meta:set_string("digtron_id", digtron_id)
|
||||||
stack_meta:set_string("description", meta:get_string("infotext"))
|
stack_meta:set_string("description", digtron.get_name(digtron_id))
|
||||||
local inv = digger:get_inventory()
|
local inv = digger:get_inventory()
|
||||||
local stack = inv:add_item("main", stack)
|
local stack = inv:add_item("main", stack)
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
@ -893,6 +902,9 @@ minetest.register_node("digtron:controller", combine_defs(base_def, {
|
|||||||
minetest.check_for_falling(built_pos)
|
minetest.check_for_falling(built_pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(target_pos)
|
||||||
|
meta:set_string("infotext", digtron.get_name(digtron_id))
|
||||||
|
|
||||||
minetest.sound_play("digtron_machine_assemble", {gain = 0.5, pos=target_pos})
|
minetest.sound_play("digtron_machine_assemble", {gain = 0.5, pos=target_pos})
|
||||||
-- Note: DO NOT RESPECT CREATIVE MODE here.
|
-- Note: DO NOT RESPECT CREATIVE MODE here.
|
||||||
-- If we allow multiple copies of a Digtron running around with the same digtron_id,
|
-- If we allow multiple copies of a Digtron running around with the same digtron_id,
|
||||||
@ -918,18 +930,6 @@ minetest.register_node("digtron:controller", combine_defs(base_def, {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
||||||
local stack_meta = itemstack:get_meta()
|
|
||||||
local title = stack_meta:get_string("description")
|
|
||||||
local digtron_id = stack_meta:get_string("digtron_id")
|
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
|
|
||||||
meta:set_string("infotext", title)
|
|
||||||
meta:set_string("digtron_id", digtron_id)
|
|
||||||
meta:mark_as_private("digtron_id")
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
local returnstack, success = digtron.on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
local returnstack, success = digtron.on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||||
if returnstack then
|
if returnstack then
|
||||||
|
@ -16,7 +16,7 @@ local damage_hp = digtron.config.damage_hp
|
|||||||
-- see predict_dig for how punch_data gets calculated
|
-- see predict_dig for how punch_data gets calculated
|
||||||
local damage_creatures = function(root_pos, punch_data, items_dropped)
|
local damage_creatures = function(root_pos, punch_data, items_dropped)
|
||||||
local target_pos = punch_data[2]
|
local target_pos = punch_data[2]
|
||||||
local objects = minetest.env:get_objects_inside_radius(target_pos, 1.0)
|
local objects = minetest.get_objects_inside_radius(target_pos, 1.0)
|
||||||
if objects ~= nil then
|
if objects ~= nil then
|
||||||
local source_pos = vector.add(minetest.get_position_from_hash(punch_data[1]), root_pos)
|
local source_pos = vector.add(minetest.get_position_from_hash(punch_data[1]), root_pos)
|
||||||
for _, obj in ipairs(objects) do
|
for _, obj in ipairs(objects) do
|
||||||
@ -52,7 +52,7 @@ local damage_creatures = function(root_pos, punch_data, items_dropped)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- If we killed any mobs they might have dropped some stuff, vacuum that up now too.
|
-- If we killed any mobs they might have dropped some stuff, vacuum that up now too.
|
||||||
objects = minetest.env:get_objects_inside_radius(target_pos, 1.0)
|
objects = minetest.get_objects_inside_radius(target_pos, 1.0)
|
||||||
if objects ~= nil then
|
if objects ~= nil then
|
||||||
for _, obj in ipairs(objects) do
|
for _, obj in ipairs(objects) do
|
||||||
if not obj:is_player() then
|
if not obj:is_player() then
|
||||||
@ -422,7 +422,8 @@ local assemble = function(root_pos, player_name)
|
|||||||
local layout = {}
|
local layout = {}
|
||||||
|
|
||||||
for hash, node in pairs(digtron_nodes) do
|
for hash, node in pairs(digtron_nodes) do
|
||||||
local relative_hash = minetest.hash_node_position(vector.subtract(minetest.get_position_from_hash(hash), root_pos))
|
local pos = minetest.get_position_from_hash(hash)
|
||||||
|
local relative_hash = minetest.hash_node_position(vector.subtract(pos, root_pos))
|
||||||
|
|
||||||
local current_meta
|
local current_meta
|
||||||
if hash == root_hash then
|
if hash == root_hash then
|
||||||
@ -462,6 +463,9 @@ local assemble = function(root_pos, player_name)
|
|||||||
|
|
||||||
node.param1 = nil -- we don't care about param1, wipe it to save space
|
node.param1 = nil -- we don't care about param1, wipe it to save space
|
||||||
layout[relative_hash] = {meta = current_meta_table, node = node}
|
layout[relative_hash] = {meta = current_meta_table, node = node}
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
-- track this so that we can interact with individual node settings in the assembled digtron
|
||||||
|
meta:set_string("digtron_relative_hash", relative_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
persist_inventory(digtron_id)
|
persist_inventory(digtron_id)
|
||||||
|
@ -40,6 +40,7 @@ Roll@nClockwise=
|
|||||||
Roll@nWiddershins=
|
Roll@nWiddershins=
|
||||||
Rotate=
|
Rotate=
|
||||||
Sequence=
|
Sequence=
|
||||||
|
Stop=
|
||||||
Up=
|
Up=
|
||||||
Yaw Left=
|
Yaw Left=
|
||||||
Yaw Right=
|
Yaw Right=
|
||||||
|
Loading…
Reference in New Issue
Block a user