fix a bug with building into freshly-dug spots

This commit is contained in:
FaceDeer 2019-09-08 13:02:10 -06:00
parent 926f72286e
commit 8f70b982fd
2 changed files with 9 additions and 4 deletions

@ -557,6 +557,7 @@ end
-- This allows us to know which digtron the player has a formspec open for without
-- sending the digtron_id over the network
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 context = player_interacting_with_digtron_id[player_name] or {}
context.digtron_id = digtron_id
@ -629,9 +630,11 @@ local get_controller_assembled_formspec = function(digtron_id, player_name)
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)
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,
"digtron:controller_assembled",
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 = ""
obj:remove()
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))
end
end
@ -992,6 +994,7 @@ local predict_build = function(digtron_id, root_pos, player_name, ignore_nodes,
local periodicity_permitted = nil
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 test_hash = minetest.hash_node_position(target_pos)
if periodicity_permitted == nil then
-- test periodicity and offset once
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 targetdef = minetest.registered_nodes[target_name]
if
ignore_hashes[target_hash] or
ignore_hashes[test_hash] or
(targetdef ~= nil
and targetdef.buildable_to
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
return missing_items, built_nodes, cost
end