Multiple press-craft fixes

- Fix door place-craft discovery not triggering due
  to wrong label name
- Fix many door witnesses not working because the door
  itself obstructs view of the action; "spread" the witness
  event to multiple positions and give the player credit
  if they can observe any part of the interacting nodes.
This commit is contained in:
Aaron Suen 2022-03-29 09:06:15 -04:00
parent e3aef49a11
commit d872119fd7
6 changed files with 23 additions and 15 deletions

View File

@ -10,11 +10,6 @@ ISSUES-GAME: Gameplay-affecting issues
#### # #### # ###### ###### # # ####
- Door crafting issues:
- Don't get hint from tool construction (e.g. should get "complete
craft with door" hint from making an adze)
- Witnesses emitted by doors or propelled tools should
probably originate from ALL nodes involved, e.g. door,
tool used, node acted upon by tool.
- Should tickling mechanic work with doors?
- Pumwater is too hard to find

View File

@ -134,7 +134,14 @@ local function craftcheck(recipe, pos, node, data, xx, xz, zx, zz)
if data.after then data.after(pos, data) end
local discover = {recipe.action, recipe.label, data.discover, recipe.discover}
nodecore.player_discover(data.crafter, discover, "craft:")
if data.witness or recipe.witness then nodecore.witness(pos, discover) end
if data.witness or recipe.witness then
nodecore.witness(pos, discover)
for _, v in pairs(recipe.nodes) do
if v.x ~= 0 or v.y ~= 0 or v.z ~= 0 then
nodecore.witness(rel(v.x, v.y, v.z), discover)
end
end
end
local pname = data.crafter and data.crafter:get_player_name()
nodecore.log(pname and "action" or "info", (pname or "unknown")
.. " crafts \"" .. recipe.label .. "\" at " ..

View File

@ -84,6 +84,12 @@ local function witnesslater(player, pos, disc)
end
function nodecore.witness(pos, disc, maxdist)
if (not pos.x) and pos[1] and pos[1].x then
for i = 1, #pos do
nodecore.witness(pos[i], disc, maxdist)
end
return
end
maxdist = maxdist or 16
for _, player in pairs(minetest.get_connected_players()) do
local ppos = player:get_pos()

View File

@ -48,7 +48,7 @@ local function ablation(pos, node)
minexptime = 0.25,
maxexptime = 0.5
})
nodecore.witness(pos, "door ablation")
nodecore.witness({pos, out}, "door ablation")
return nodecore.dnt_set(pos, dntname)
end
end

View File

@ -127,13 +127,13 @@ local function doitemeject(pos, data)
toolfx(pos, data.presstarget)
nodecore.machine_digging = data.pressdig
minetest.dig_node(data.pressdig.pos)
nodecore.witness(pos, "door dig")
nodecore.witness({pos, data.pointed.above, data.presstarget}, "door dig")
return
end
if data.presscommit then
toolfx(pos, data.presstarget)
data.presscommit()
nodecore.witness(pos, "door pummel")
nodecore.witness({pos, data.pointed.above, data.presstarget}, "door pummel")
return
end
@ -143,7 +143,7 @@ local function doitemeject(pos, data)
one:set_count(1)
if data.intostorebox then
nodecore.witness(pos, "door store")
nodecore.witness({pos, data.pointed.above, data.intostorebox}, "door store")
one = nodecore.stack_add(data.intostorebox, one)
nodecore.stack_sounds(data.intostorebox, "place")
if not one:is_empty() then return end
@ -170,7 +170,7 @@ local function doitemeject(pos, data)
return minetest.remove_node(pos)
end
nodecore.stack_set(pos, stack)
return nodecore.witness(pos, "door catapult")
return nodecore.witness({pos, data.pointed.above}, "door catapult")
end
nodecore.register_craft({

View File

@ -79,7 +79,7 @@ nodecore.register_craft({
action = "place",
pointed = data.pointed,
witness = 16,
label = "door place-craft"
discover = "door place-craft"
})
end
})
@ -112,7 +112,7 @@ nodecore.register_craft({
action = "place",
pointed = data.pointed,
witness = 16,
label = "door place-craft"
discover = "door place-craft"
})
return data[recipefound]
end,
@ -127,7 +127,7 @@ nodecore.register_craft({
for k, v in pairs(data.pointed) do pt[k] = v end
pt.craftdata = {
witness = 16,
label = "door place-craft"
discover = "door place-craft"
}
local def = stack:get_definition()
if def and def.on_place_node then
@ -136,7 +136,7 @@ nodecore.register_craft({
stack = minetest.item_place_node(stack, nil, pt)
end
nodecore.node_sound(pos, "place")
nodecore.witness(pos, "door placement")
nodecore.witness({pos, data.pointed.above}, "door placement")
if not stack:is_empty() then
nodecore.item_eject(pos, stack)
end