mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-08-18 20:04:04 +02:00
fix a bug with building into freshly-dug spots
This commit is contained in:
parent
926f72286e
commit
8f70b982fd
@ -557,6 +557,7 @@ end
|
|||||||
-- This allows us to know which digtron the player has a formspec open for without
|
-- This allows us to know which digtron the player has a formspec open for without
|
||||||
-- sending the digtron_id over the network
|
-- sending the digtron_id over the network
|
||||||
local player_interacting_with_digtron_id = {}
|
local player_interacting_with_digtron_id = {}
|
||||||
|
-- Call this when the player opens a formspec to initialize these values
|
||||||
local player_opening_formspec = function(digtron_id, player_name)
|
local player_opening_formspec = function(digtron_id, player_name)
|
||||||
local context = player_interacting_with_digtron_id[player_name] or {}
|
local context = player_interacting_with_digtron_id[player_name] or {}
|
||||||
context.digtron_id = digtron_id
|
context.digtron_id = digtron_id
|
||||||
@ -629,9 +630,11 @@ local get_controller_assembled_formspec = function(digtron_id, player_name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- For now, only refresh the UI if it's open to tab 2 (the sequencer). Other tabs
|
||||||
|
-- don't have things that are changed "on the fly" by Digtron operation.
|
||||||
refresh_open_formspec = function(digtron_id)
|
refresh_open_formspec = function(digtron_id)
|
||||||
for player_name, context in pairs(player_interacting_with_digtron_id) do
|
for player_name, context in pairs(player_interacting_with_digtron_id) do
|
||||||
if context.open and context.digtron_id == digtron_id then
|
if context.open and context.digtron_id == digtron_id and context.current_tab == 2 then
|
||||||
minetest.show_formspec(player_name,
|
minetest.show_formspec(player_name,
|
||||||
"digtron:controller_assembled",
|
"digtron:controller_assembled",
|
||||||
get_controller_assembled_formspec(digtron_id, player_name))
|
get_controller_assembled_formspec(digtron_id, player_name))
|
||||||
|
@ -44,7 +44,9 @@ local damage_creatures = function(root_pos, punch_data, items_dropped)
|
|||||||
lua_entity.itemstring = ""
|
lua_entity.itemstring = ""
|
||||||
obj:remove()
|
obj:remove()
|
||||||
else
|
else
|
||||||
lua_entity:add_velocity(dir)
|
if lua_entity.add_velocity then
|
||||||
|
lua_entity:add_velocity(dir)
|
||||||
|
end
|
||||||
obj:set_hp(math.max(obj:get_hp() - damage_hp*armour_multiplier, 0))
|
obj:set_hp(math.max(obj:get_hp() - damage_hp*armour_multiplier, 0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -992,6 +994,7 @@ local predict_build = function(digtron_id, root_pos, player_name, ignore_nodes,
|
|||||||
local periodicity_permitted = nil
|
local periodicity_permitted = nil
|
||||||
for i = 1, builder_data.extrusion do
|
for i = 1, builder_data.extrusion do
|
||||||
local target_pos = vector.add(minetest.get_position_from_hash(target_hash + i * dir_hash), root_pos)
|
local target_pos = vector.add(minetest.get_position_from_hash(target_hash + i * dir_hash), root_pos)
|
||||||
|
local test_hash = minetest.hash_node_position(target_pos)
|
||||||
if periodicity_permitted == nil then
|
if periodicity_permitted == nil then
|
||||||
-- test periodicity and offset once
|
-- test periodicity and offset once
|
||||||
periodicity_permitted = (target_pos[controlling_coordinate] + builder_data.offset) % builder_data.period == 0
|
periodicity_permitted = (target_pos[controlling_coordinate] + builder_data.offset) % builder_data.period == 0
|
||||||
@ -1003,7 +1006,7 @@ local predict_build = function(digtron_id, root_pos, player_name, ignore_nodes,
|
|||||||
local target_name = target_node.name
|
local target_name = target_node.name
|
||||||
local targetdef = minetest.registered_nodes[target_name]
|
local targetdef = minetest.registered_nodes[target_name]
|
||||||
if
|
if
|
||||||
ignore_hashes[target_hash] or
|
ignore_hashes[test_hash] or
|
||||||
(targetdef ~= nil
|
(targetdef ~= nil
|
||||||
and targetdef.buildable_to
|
and targetdef.buildable_to
|
||||||
and not protection_check(target_pos, player_name)
|
and not protection_check(target_pos, player_name)
|
||||||
@ -1031,7 +1034,6 @@ local predict_build = function(digtron_id, root_pos, player_name, ignore_nodes,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return missing_items, built_nodes, cost
|
return missing_items, built_nodes, cost
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user