Skip to content

Commit

Permalink
cleanup Sokomine#40 changes (Sokomine#41)
Browse files Browse the repository at this point in the history
* cleanup Sokomine#40 changes

Co-authored-by: SX <[email protected]>

Co-authored-by: SX <[email protected]>
  • Loading branch information
wsor4035 and S-S-X authored Feb 2, 2022
1 parent 2f09593 commit 79277d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
7 changes: 3 additions & 4 deletions formspecs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ function travelnet.form_input_handler(player, formname, fields)
if formname ~= travelnet_form_name then return end
if fields and fields.pos2str then
local pos = minetest.string_to_pos(fields.pos2str)
if not pos then
return
end
if not travelnet.is_travelnet_or_elevator(pos) then
if not pos then return end
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "travelnet") == 0 and minetest.get_item_group(node.name, "elevator") == 0 then
return
end

Expand Down
6 changes: 0 additions & 6 deletions functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ function travelnet.is_elevator(node_name)
return node_name == "travelnet:elevator"
end

function travelnet.is_travelnet_or_elevator(pos)
local node = minetest.get_node(pos)
local node_def = minetest.registered_nodes[node.name]
return node_def and node_def.groups and (node_def.groups.travelnet or node_def.groups.elevator)
end

function travelnet.door_is_open(node, opposite_direction)
return string.sub(node.name, -5) == "_open"
-- handle doors that change their facedir
Expand Down
5 changes: 2 additions & 3 deletions on_receive_fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ local function on_receive_fields_internal(pos, _, fields, player)
local player_model_bottom = tonumber(minetest.settings:get("player_model_bottom")) or -.5
local player_model_vec = vector.new(0, player_model_bottom, 0)
local target_pos = target_station.pos
local tnode = minetest.get_node(target_pos)

local top_pos = vector.add(pos, { x=0, y=1, z=0 })
local top_node = minetest.get_node(top_pos)
Expand All @@ -225,9 +226,7 @@ local function on_receive_fields_internal(pos, _, fields, player)
minetest.load_area(target_pos)

-- check if the box has at the other end has been removed.
local has_travelnet_group = travelnet.is_travelnet_or_elevator(target_pos)

if not has_travelnet_group then
if minetest.get_item_group(tnode.name, "travelnet") == 0 and minetest.get_item_group(tnode.name, "elevator") == 0 then
-- provide information necessary to identify the removed box
local oldmetadata = {
fields = {
Expand Down

0 comments on commit 79277d2

Please sign in to comment.