diff options
Diffstat (limited to 'advtrains/helpers.lua')
-rw-r--r-- | advtrains/helpers.lua | 66 |
1 files changed, 9 insertions, 57 deletions
diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua index 6f5d1eb..e58625f 100644 --- a/advtrains/helpers.lua +++ b/advtrains/helpers.lua @@ -236,11 +236,10 @@ function advtrains.is_damage_enabled(name) if not name then error("advtrains.is_damage_enabled() called without name parameter!") end - return not minetest.check_player_privs(name, "train_ghost") - --[[ if minetest.check_player_privs(name, "train_admin") then + if minetest.check_player_privs(name, "train_admin") then return false end - return minetest.settings:get_bool("enable_damage") ]] + return minetest.settings:get_bool("enable_damage") end function advtrains.ms_to_kmh(speed) @@ -472,11 +471,16 @@ function advtrains.position_in_range(pos, range) return false end ---[[ local active_node_range = tonumber(minetest.settings:get("active_block_range"))*16 + 16 -- Function to check whether node at position(pos) is "loaded"/"active" -- That is, whether it is within the active_block_range to a player -if minetest.is_block_active then -- define function differently whether minetest.is_block_active is available or not +if core.compare_block_status then + -- latest API + function advtrains.is_node_loaded(pos) + return core.compare_block_status(pos, "active") + end +elseif minetest.is_block_active then -- define function differently whether minetest.is_block_active is available or not + -- API added by my PR but later superseded by the above and now removed advtrains.is_node_loaded = minetest.is_block_active else function advtrains.is_node_loaded(pos) @@ -485,58 +489,6 @@ else end end end -]] -function advtrains.is_node_loaded(pos) - return minetest.compare_block_status(pos, "loaded") -- loaded, or active? -end - -local variants = { - {"0", 0}, - {"30", 0}, - {"45", 0}, - {"60", 0}, - {"0", 1}, - {"30", 1}, - {"45", 1}, - {"60", 1}, - {"0", 2}, - {"30", 2}, - {"45", 2}, - {"60", 2}, - {"0", 3}, - {"30", 3}, - {"45", 3}, - {"60", 3}, - {"0", 0}, - {"30", 0}, - {"45", 0}, - {"60", 0}, -} - -function advtrains.after_place_signal(pos, placer, itemstack, pointed_thing) - if not minetest.is_player(placer) then return end - local name = itemstack:get_name() - if not name:match("_0$") then return end - local rn = minetest.registered_nodes - local prefix = name:sub(1, -2) - if not (rn[prefix.."30"] and rn[prefix.."45"] and rn[prefix.."60"]) then return end - local variant = math.floor(placer:get_look_horizontal() * -8 / math.pi + 16.25) % 16 - local n = variants[variant + 1] - if n == nil then return end - local node = advtrains.ndb.get_node(pos) - if node.name ~= name then return end - node.name = prefix..n[1] - node.param2 = n[2] - advtrains.ndb.swap_node(pos, node) -end - -function advtrains.yaw_equals(yaw1, yaw2) - if yaw1 ~= nil and yaw2 ~= nil then - return math.abs(yaw2 - yaw1) < 1.0e-9 - else - return yaw1 == yaw2 - end -end -- TrackIterator interface -- |