2019-04-28 22:34:21 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
|
|
|
Copyright (C) 2019 Joachim Stolberg
|
|
|
|
|
|
|
|
LGPLv2.1+
|
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
Helper functions
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- for lazy programmers
|
|
|
|
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
|
|
|
local P = minetest.string_to_pos
|
|
|
|
local M = minetest.get_meta
|
|
|
|
|
|
|
|
-- Load support for intllib.
|
|
|
|
local MP = minetest.get_modpath("techage")
|
|
|
|
local I,_ = dofile(MP.."/intllib.lua")
|
|
|
|
|
2019-04-27 18:42:50 +03:00
|
|
|
function techage.range(val, min, max)
|
|
|
|
val = tonumber(val)
|
|
|
|
if val < min then return min end
|
|
|
|
if val > max then return max end
|
|
|
|
return val
|
|
|
|
end
|
|
|
|
|
|
|
|
function techage.one_of(val, selection)
|
|
|
|
for _,v in ipairs(selection) do
|
|
|
|
if val == v then return val end
|
|
|
|
end
|
|
|
|
return selection[1]
|
|
|
|
end
|
|
|
|
|
2019-04-28 22:34:21 +03:00
|
|
|
--
|
|
|
|
-- Functions used to hide electric cable and biogas pipes
|
|
|
|
--
|
|
|
|
-- Overridden method of tubelib2!
|
|
|
|
function techage.get_primary_node_param2(pos, dir)
|
|
|
|
local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0])
|
|
|
|
local param2 = M(npos):get_int("tl2_param2")
|
|
|
|
if param2 ~= 0 then
|
|
|
|
return param2, npos
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Overridden method of tubelib2!
|
|
|
|
function techage.is_primary_node(pos, dir)
|
|
|
|
local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0])
|
|
|
|
local param2 = M(npos):get_int("tl2_param2")
|
|
|
|
return param2 ~= 0
|
|
|
|
end
|