Change code so that no luacheck warnings are issued

This commit is contained in:
Joachim Stolberg 2024-08-16 17:41:42 +02:00
parent cff00b97fb
commit b6473faed3
21 changed files with 229 additions and 257 deletions

28
.luacheckrc Normal file
View File

@ -0,0 +1,28 @@
unused_args = false
ignore = {
"131", -- Unused global variable
"432", -- Shadowing an upvalue argument
}
read_globals = {
"core",
"minetest",
"default",
"worldedit",
"tubelib2",
"intllib",
"DIR_DELIM",
"techage",
string = {fields = {"split", "trim"}},
vector = {fields = {"add", "equals", "multiply"}},
table = {fields = {"copy", ""}},
}
globals = {
"hyperloop",
"ItemStack",
"screwdriver",
}

View File

@ -13,11 +13,11 @@
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
--local P = minetest.string_to_pos
--local M = minetest.get_meta
local S = hyperloop.S
local NS = hyperloop.NS
--local NS = hyperloop.NS
local tBlockingTime = {}
local tBookings = {} -- open bookings: tBookings[SP(departure_pos)] = arrival_pos
@ -33,7 +33,7 @@ function hyperloop.reserve(departure_pos, arrival_pos, player)
hyperloop.chat(player, S("Station data is corrupted. Please rebuild the station!"))
return false
end
if (tBlockingTime[SP(departure_pos)] or 0) > minetest.get_gametime() then
hyperloop.chat(player, S("Station is still blocked. Please try again in a few seconds!"))
return false
@ -41,7 +41,7 @@ function hyperloop.reserve(departure_pos, arrival_pos, player)
hyperloop.chat(player, S("Station is still blocked. Please try again in a few seconds!"))
return false
end
-- place a reservation for 20 seconds to start the trip
tBlockingTime[SP(departure_pos)] = minetest.get_gametime() + 20
tBlockingTime[SP(arrival_pos)] = minetest.get_gametime() + 20
@ -55,7 +55,7 @@ function hyperloop.block(departure_pos, arrival_pos, seconds)
elseif Stations:get(arrival_pos) == nil then
return false
end
tBlockingTime[SP(departure_pos)] = minetest.get_gametime() + seconds
tBlockingTime[SP(arrival_pos)] = minetest.get_gametime() + seconds
return true
@ -67,14 +67,14 @@ function hyperloop.is_blocked(pos)
if Stations:get(pos) == nil then
return false
end
return (tBlockingTime[SP(pos)] or 0) > minetest.get_gametime()
end
function hyperloop.set_arrival(departure_pos, arrival_pos)
tBookings[SP(departure_pos)] = arrival_pos
end
end
function hyperloop.get_arrival(departure_pos)
-- Return and delete the arrival pos

View File

@ -18,9 +18,8 @@ local M = minetest.get_meta
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
-- Used to store the Station list for each booking machine:
-- Used to store the Station list for each booking machine:
-- tStationList[SP(pos)] = {pos1, pos2, ...}
local tStationList = {}
@ -33,7 +32,7 @@ local function generate_string(sortedList)
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"item_image[0,0;1,1;hyperloop:booking]"..
"item_image[0,0;1,1;hyperloop:booking]"..
"label[4,0; "..S("Select your destination").."]"}
tRes[2] = "tablecolumns[text,width=20;text,width=6,align=right;text]"
@ -80,7 +79,7 @@ local function filter_subnet(sortedList, subnet)
if subnet == "" then
subnet = nil
end
local tbl = {}
for idx,item in ipairs(sortedList) do
if item.subnet == subnet then
@ -95,7 +94,6 @@ end
-- Used to update the station list for booking machine
-- and teleport list.
local function station_list_as_string(pos, subnet)
local meta = M(pos)
-- Generate a name sorted list of all connected stations
local sortedList = Stations:station_list(pos, pos, "name")
-- remove all junctions from the list
@ -108,7 +106,7 @@ local function station_list_as_string(pos, subnet)
return generate_string(sortedList)
end
local naming_formspec = nil
local naming_formspec
if hyperloop.subnet_enabled then
naming_formspec = function(pos)
@ -185,7 +183,7 @@ local function on_receive_fields(pos, formname, fields, player)
booking_info = string.trim(fields.info),
subnet = subnet,
})
local meta = M(pos)
meta:set_string("sStationPos", SP(stationPos))
meta:set_string("infotext", "Station: "..station_name)
@ -217,7 +215,7 @@ local function on_receive_fields(pos, formname, fields, player)
end
end
end
local function on_destruct(pos)
local sStationPos = M(pos):get_string("sStationPos")
if sStationPos ~= "" then
@ -229,7 +227,7 @@ local function on_destruct(pos)
end
end
-- wap from wall to ground
-- wap from wall to ground
local function swap_node(pos, placer)
pos.y = pos.y - 1
if minetest.get_node_or_nil(pos).name ~= "air" then
@ -255,7 +253,7 @@ minetest.register_node("hyperloop:booking", {
"hyperloop_booking.png",
"hyperloop_booking_front.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
@ -263,13 +261,13 @@ minetest.register_node("hyperloop:booking", {
{ -8/16, -8/16, 2/16, 8/16, 8/16, 8/16},
},
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
naming_formspec(pos)
swap_node(pos, placer)
end,
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
on_receive_fields = on_receive_fields,
on_destruct = on_destruct,
on_rightclick = on_rightclick,
@ -293,7 +291,7 @@ minetest.register_node("hyperloop:booking_ground", {
"hyperloop_booking.png",
"hyperloop_booking_front.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
@ -301,7 +299,7 @@ minetest.register_node("hyperloop:booking_ground", {
{ -8/16, -8/16, -3/16, 8/16, 8/16, 3/16},
},
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
naming_formspec(pos)
end,
@ -309,8 +307,8 @@ minetest.register_node("hyperloop:booking_ground", {
on_receive_fields = on_receive_fields,
on_destruct = on_destruct,
on_rightclick = on_rightclick,
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
drop = "hyperloop:booking",
light_source = 2,
paramtype = 'light',

View File

@ -12,30 +12,12 @@
]]--
-- 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
--local P = minetest.string_to_pos
--local M = minetest.get_meta
hyperloop.Stations = hyperloop.Network:new()
hyperloop.Elevators = hyperloop.Network:new()
-- Check all nodes on the map and delete useless data base entries
local function check_data_base()
-- used for VM get_node
local tube = tubelib2.Tube:new({})
hyperloop.Stations:filter(function(pos)
local _,node = tube:get_node(pos)
return node.name == "hyperloop:station" or node.name == "hyperloop:junction"
end)
hyperloop.Elevators:filter(function(pos)
local _,node = tube:get_node(pos)
return node.name == "hyperloop:elevator_bottom"
end)
end
local storage = minetest.get_mod_storage()
hyperloop.Stations:deserialize(storage:get_string("Stations"))
hyperloop.Elevators:deserialize(storage:get_string("Elevators"))

View File

@ -15,20 +15,19 @@
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
local tilesL = {"hyperloop_alpsL.png", "hyperloop_seaL.png", "hyperloop_agyptL.png"}
local tilesR = {"hyperloop_alpsR.png", "hyperloop_seaR.png", "hyperloop_agyptR.png"}
-- determine facedir and pos on the right hand side from the given pos
function right_hand_side(pos, placer)
local function right_hand_side(pos, placer)
local facedir = hyperloop.get_facedir(placer)
pos = hyperloop.new_pos(pos, facedir, "1R", 0)
return facedir,pos
end
for idx = 1,3 do
minetest.register_node("hyperloop:poster"..idx.."L", {
description = S("Hyperloop Promo Poster ")..idx,
tiles = {
@ -51,7 +50,7 @@ for idx = 1,3 do
type = "fixed",
fixed = { -8/16, -8/16, -6/16, 24/16, 8/16, 8/16},
},
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
local facedir
@ -69,8 +68,8 @@ for idx = 1,3 do
minetest.remove_node(pos)
end
end,
paramtype2 = "facedir",
light_source = 4,
is_ground_content = false,
@ -133,7 +132,7 @@ minetest.register_node("hyperloop:signR", {
{ -8/16, -5/16, 6/16, 8/16, 5/16, 8/16},
},
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
pos.y = pos.y - 1
if minetest.get_node_or_nil(pos).name ~= "air" then
@ -144,7 +143,7 @@ minetest.register_node("hyperloop:signR", {
minetest.swap_node(pos, node)
end
end,
paramtype2 = "facedir",
paramtype = 'light',
light_source = 4,
@ -170,7 +169,7 @@ minetest.register_node("hyperloop:signL", {
{ -8/16, -5/16, 6/16, 8/16, 5/16, 8/16},
},
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
pos.y = pos.y - 1
if minetest.get_node_or_nil(pos).name ~= "air" then
@ -181,7 +180,7 @@ minetest.register_node("hyperloop:signL", {
minetest.swap_node(pos, node)
end
end,
paramtype2 = "facedir",
paramtype = 'light',
light_source = 4,

View File

@ -11,13 +11,12 @@
]]--
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
--local SP = 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 S = hyperloop.S
local NS = hyperloop.NS
-- Open the door for an emergency
local function door_on_punch(pos, node, puncher, pointed_thing)
@ -40,7 +39,6 @@ local function door_command(door_pos1, facedir, cmnd)
local node1 = minetest.get_node(door_pos1)
local node2 = minetest.get_node(door_pos2)
local meta = minetest.get_meta(door_pos1)
if cmnd == "open" then
minetest.sound_play("door", {
pos = door_pos1,
@ -116,15 +114,15 @@ minetest.register_node("hyperloop:doorTopPassive", {
type = "fixed",
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
},
on_punch = door_on_punch,
auto_place_node = function(pos, facedir, sStationPos)
M(pos):set_int("facedir", facedir)
M(pos):set_string("sStationPos", sStationPos)
end,
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype = 'light',
light_source = 1,
paramtype2 = "facedir",
@ -158,8 +156,8 @@ minetest.register_node("hyperloop:doorTopActive", {
type = "fixed",
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype2 = "facedir",
drop = "",
light_source = 2,
@ -184,15 +182,15 @@ minetest.register_node("hyperloop:doorBottom", {
type = "fixed",
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
},
on_punch = door_on_punch,
auto_place_node = function(pos, facedir, sStationPos)
M(pos):set_int("facedir", facedir)
M(pos):set_string("sStationPos", sStationPos)
end,
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype = 'light',
light_source = 1,
paramtype2 = "facedir",

View File

@ -17,7 +17,6 @@ local M = minetest.get_meta
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
-- To store elevator floors and formspecs
local Cache = {}
@ -36,9 +35,9 @@ end
local Shaft = tubelib2.Tube:new({
dirs_to_check = dirs_to_check,
max_tube_length = 1000,
max_tube_length = 1000,
show_infotext = true,
primary_node_names = {"hyperloop:shaft", "hyperloop:shaft2", "hyperloop:shaftA", "hyperloop:shaftA2"},
primary_node_names = {"hyperloop:shaft", "hyperloop:shaft2", "hyperloop:shaftA", "hyperloop:shaftA2"},
secondary_node_names = {"hyperloop:elevator_bottom", "hyperloop:elevator_top"},
after_place_tube = function(pos, param2, tube_type, num_tubes)
if tube_type == "S" then
@ -65,8 +64,8 @@ Shaft:register_on_tube_update(function(node, pos, out_dir, peer_pos, peer_in_dir
-- switch to elevator_bottom node
pos = Shaft:get_pos(pos, 5)
elseif peer_pos then
local _,node = Shaft:get_node(peer_pos)
if node.name == "hyperloop:elevator_top" then
local _,node1 = Shaft:get_node(peer_pos)
if node1.name == "hyperloop:elevator_top" then
peer_pos = Shaft:get_pos(peer_pos, 5)
end
end
@ -108,11 +107,11 @@ minetest.register_node("hyperloop:shaft", {
end
return false
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
end,
climbable = true,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
@ -158,11 +157,11 @@ minetest.register_node("hyperloop:shaftA", {
end
return false
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
end,
climbable = true,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
@ -204,7 +203,7 @@ minetest.register_node("hyperloop:shaft2", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
end,
climbable = true,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
@ -251,7 +250,7 @@ minetest.register_node("hyperloop:shaftA2", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
end,
climbable = true,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
@ -332,13 +331,13 @@ local function door_command(floor_pos, facedir, cmnd, sound)
local door_pos1 = hyperloop.new_pos(floor_pos, facedir, "1B", 0)
local door_pos2 = hyperloop.new_pos(floor_pos, facedir, "1B", 1)
local meta = M(floor_pos)
local owner = meta:contains("owner") and meta:get_string("owner")
local owner = meta:contains("owner") and meta:get_string("owner")
if owner and (minetest.is_protected(door_pos1, owner) or minetest.is_protected(door_pos2, owner)) then
return
end
local node1 = minetest.get_node(door_pos1)
local node2 = minetest.get_node(door_pos2)
if sound then
minetest.sound_play("ele_door", {
pos = floor_pos,
@ -445,7 +444,7 @@ minetest.register_node("hyperloop:elevator_bottom", {
fixed = { -8/16, -8/16, -8/16, 8/16, 23/16, 8/16 },
},
inventory_image = "hyperloop_elevator_inventory.png",
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
drawtype = "nodebox",
paramtype = 'light',
light_source = 6,
@ -458,25 +457,25 @@ minetest.register_node("hyperloop:elevator_bottom", {
if node.name == "air" then
local facedir = hyperloop.get_facedir(placer)
Elevators:set(pos, "<unknown>", {facedir=facedir, busy=false})
Shaft:after_place_node(pos, {5})
-- formspec
local meta = minetest.get_meta(pos)
local formspec = "size[6,4]"..
local fs = "size[6,4]"..
"label[0,0;"..S("Please insert floor name").."]" ..
"field[0.5,1.5;5,1;floor;"..S("Floor name")..";"..S("Base").."]" ..
"button_exit[2,3;2,1;exit;"..S("Save").."]"
meta:set_string("formspec", formspec)
meta:set_string("formspec", fs)
meta:set_string("owner", placer:get_player_name())
-- add upper part of the car
pos = Shaft:get_pos(pos, 6)
minetest.add_node(pos, {name="hyperloop:elevator_top", param2=facedir})
Shaft:after_place_node(pos, {6})
else
minetest.remove_node(pos)
return true
return true
end
end,
@ -559,8 +558,8 @@ minetest.register_node("hyperloop:elevator_top", {
{ -7/16, -8/16, 7/16, 7/16, 8/16, 8/16},
},
},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
drawtype = "nodebox",
paramtype = 'light',
light_source = 6,
@ -584,8 +583,8 @@ minetest.register_node("hyperloop:elevator_door_top", {
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
},
},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
drop = "",
paramtype = 'light',
paramtype2 = "facedir",
@ -607,12 +606,12 @@ minetest.register_node("hyperloop:elevator_door", {
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
},
},
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, 6.5/16, 8/16, 24/16, 8/16 },
},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local floor_pos = P(M(pos):get_string("floor_pos"))
if floor_pos ~= nil then
@ -623,8 +622,8 @@ minetest.register_node("hyperloop:elevator_door", {
end
end
end,
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
drop = "",
paramtype = 'light',
paramtype2 = "facedir",
@ -646,8 +645,8 @@ minetest.register_node("hyperloop:elevator_door_dark_top", {
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
},
},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
drop = "",
paramtype = 'light',
paramtype2 = "facedir",
@ -668,13 +667,13 @@ minetest.register_node("hyperloop:elevator_door_dark", {
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
},
},
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, 7/16, 8/16, 24/16, 8/16 },
},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
drop = "",
paramtype = 'light',
paramtype2 = "facedir",

View File

@ -34,8 +34,8 @@
2020-01-03 v2.04 Elevator door bugfix (MT 5+)
2020-03-12 v2.05 minetest translator added (thanks to acmgit/Clyde)
2020-06-14 v2.06 The default value for `hyperloop_free_tube_placement_enabled` is now true
2021-02-07 v2.07 tube_crowbar: Add tube length check
2021-11-01 v2.08 Enable the use of hyperloop networks for other mods
2021-02-07 v2.07 tube_crowbar: Add tube length check
2021-11-01 v2.08 Enable the use of hyperloop networks for other mods
]]--

View File

@ -11,13 +11,12 @@
]]--
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
--local SP = 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 S = hyperloop.S
local NS = hyperloop.NS
local Tube = hyperloop.Tube
local Stations = hyperloop.Stations
@ -63,7 +62,7 @@ minetest.register_node("hyperloop:junction", {
Tube:after_dig_node(pos)
Stations:delete(pos)
end,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
paramtype = "light",

10
lcd.lua
View File

@ -1,8 +1,8 @@
--[[
LCD
LCD
===
Derived from the work of kaeza, sofar and others (digilines)
LGPLv2.1+
@ -12,8 +12,6 @@
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
-- load characters map
local chars_file = io.open(minetest.get_modpath("hyperloop").."/characters.data", "r")
@ -161,7 +159,7 @@ minetest.register_node("hyperloop:lcd", {
description = S("Hyperloop Display"),
tiles = {"hyperloop_lcd.png"},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "wallmounted",
@ -185,7 +183,7 @@ minetest.register_node("hyperloop:lcd", {
update = function(pos, text)
lcd_update(pos, text)
end,
light_source = 6,
})

13
map.lua
View File

@ -12,12 +12,11 @@
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
--local P = minetest.string_to_pos
--local M = minetest.get_meta
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
local Stations = hyperloop.Stations
@ -30,7 +29,7 @@ local function generate_string(sortedList)
local sKey = SP(item.pos)
lStationPositions[sKey] = idx
end
local tRes = {
"label[0,0;ID]"..
"label[0.7,0;"..S("Dist.").."]"..
@ -46,7 +45,7 @@ local function generate_string(sortedList)
local owner = dataSet.owner or "<unknown>"
local name = dataSet.name or "<unknown>"
local distance = dataSet.distance or 0
tRes[#tRes+1] = "label[0,"..ypos..";"..idx.."]"
tRes[#tRes+1] = "label[0.7,"..ypos..";"..distance.." m]"
tRes[#tRes+1] = "label[1.8,"..ypos..";"..string.sub(name,1,24).."]"
@ -87,7 +86,7 @@ local function map_on_use(itemstack, user)
local player_name = user:get_player_name()
local pos = user:get_pos()
local sStationList = station_list_as_string(pos)
local formspec = "size[12,10]" ..
local formspec = "size[12,10]" ..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
@ -102,7 +101,7 @@ local function map_on_secondary_use(itemstack, user)
local player_name = user:get_player_name()
local pos = user:get_pos()
local sStationList = network_list_as_string(pos)
local formspec = "size[12,10]" ..
local formspec = "size[12,10]" ..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..

View File

@ -12,7 +12,7 @@
see init.lua
Migrate from v1 to v2
]]--
-- for lazy programmers
@ -22,7 +22,6 @@ local M = minetest.get_meta
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
local Tube = hyperloop.Tube
local Shaft = hyperloop.Shaft
@ -37,12 +36,12 @@ local JunctionsToBePlacedAfter = {}
local function get_tube_data(pos, dir1, dir2, num_tubes)
local param2, tube_type = tubelib2.encode_param2(dir1, dir2, num_tubes)
return pos, param2, tube_type, num_tubes
end
end
-- Check if node has a connection on the given dir
local function connected(self, pos, dir)
local _,node = self:get_node(pos, dir)
return self.primary_node_names[node.name]
return self.primary_node_names[node.name]
or self.secondary_node_names[node.name]
end
@ -100,7 +99,7 @@ local function convert_legary_nodes(self, pos, dir)
if tLegacyNodeNames[node.name] then
local dir1, dir2, num = determine_dir1_dir2_and_num_conn(self, npos)
if dir1 then
self.clbk_after_place_tube(get_tube_data(npos, dir1,
self.clbk_after_place_tube(get_tube_data(npos, dir1,
dir2 or tubelib2.Turn180Deg[dir1], num))
if tubelib2.Turn180Deg[dir] == dir1 then
return npos, dir2
@ -110,9 +109,9 @@ local function convert_legary_nodes(self, pos, dir)
end
end
end
local cnt = 0
if not dir then return pos, dir, cnt end
if not dir then return pos, dir, cnt end
while cnt <= 64000 do
local new_pos, new_dir = convert_next_tube(self, pos, dir)
if cnt > 0 and (cnt % self.max_tube_length) == 0 then -- border reached?
@ -123,11 +122,11 @@ local function convert_legary_nodes(self, pos, dir)
cnt = cnt + 1
end
return pos, dir, cnt
end
end
local function convert_line(self, pos, dir)
local fpos,fdir = convert_legary_nodes(self, pos, dir)
self:tool_repair_tube(pos)
convert_legary_nodes(self, pos, dir)
self:tool_repair_tube(pos)
end
@ -135,12 +134,12 @@ local tWifiNodes = {} -- user for pairing
local lWifiNodes = {} -- used for post processing
local function set_pairing(pos, peer_pos)
M(pos):set_int("tube_dir", Tube:get_primary_dir(pos))
M(peer_pos):set_int("tube_dir", Tube:get_primary_dir(peer_pos))
local tube_dir1 = Tube:store_teleport_data(pos, peer_pos)
local tube_dir2 = Tube:store_teleport_data(peer_pos, pos)
Tube:store_teleport_data(pos, peer_pos)
Tube:store_teleport_data(peer_pos, pos)
end
@ -195,8 +194,8 @@ end
local function search_wifi_node(pos, dir)
local convert_next_tube = function(pos, dir)
local npos, node = Tube:get_node(pos, dir)
local dir1, dir2, num = next_node_on_the_way_to_a_wifi_node(npos)
local npos, _ = Tube:get_node(pos, dir)
local dir1, dir2, _ = next_node_on_the_way_to_a_wifi_node(npos)
if dir1 then
if tubelib2.Turn180Deg[dir] == dir1 then
return npos, dir2
@ -205,9 +204,9 @@ local function search_wifi_node(pos, dir)
end
end
end
local cnt = 0
if not dir then return pos, cnt end
if not dir then return pos, cnt end
while true do
local new_pos, new_dir = convert_next_tube(pos, dir)
if not new_dir then break end
@ -215,12 +214,12 @@ local function search_wifi_node(pos, dir)
cnt = cnt + 1
end
return pos, dir, cnt
end
end
local function search_wifi_node_in_all_dirs(pos)
-- check all positions
for dir = 1, 6 do
local npos, node = Tube:get_node(pos, dir)
local _, node = Tube:get_node(pos, dir)
if node and node.name == "hyperloop:tube1" then
search_wifi_node(pos, dir)
end
@ -230,7 +229,7 @@ end
local function convert_tube_line(pos)
-- check all positions
for dir = 1, 6 do
local npos, node = Tube:get_node(pos, dir)
local _, node = Tube:get_node(pos, dir)
if node and node.name == "hyperloop:tube1" then
convert_line(Tube, pos, dir)
end
@ -266,13 +265,13 @@ end
local function convert_station_data(tAllStations)
tLegacyNodeNames = {
["hyperloop:tube0"] = true,
["hyperloop:tube1"] = true,
["hyperloop:tube2"] = true,
["hyperloop:tube0"] = true,
["hyperloop:tube1"] = true,
["hyperloop:tube2"] = true,
}
local originNodeNames = add_to_table(Tube.primary_node_names, tLegacyNodeNames)
for key,item in pairs(tAllStations) do
if item.pos and Tube:is_secondary_node(item.pos) then
Stations:set(item.pos, station_name(item), {
@ -301,19 +300,19 @@ local function convert_station_data(tAllStations)
end
-- Repair the tube lines of wifi nodes
wifi_post_processing()
Tube.primary_node_names = originNodeNames
end
local function convert_elevator_data(tAllElevators)
tLegacyNodeNames = {
["hyperloop:shaft"] = true,
["hyperloop:shaft"] = true,
["hyperloop:shaft2"] = true,
}
local originNodeNames = add_to_table(Shaft.primary_node_names, tLegacyNodeNames)
local originDirsToCheck = table.copy(Shaft.dirs_to_check)
Shaft.dirs_to_check = {5,6} -- legacy elevators use up/down only
for pos,tElevator in pairs(tAllElevators) do
for _,floor in pairs(tElevator.floors) do
if floor.pos and Shaft:is_secondary_node(floor.pos) then
@ -326,7 +325,7 @@ local function convert_elevator_data(tAllElevators)
end
end
end
Shaft.primary_node_names = originNodeNames
Shaft.dirs_to_check = originDirsToCheck
end

View File

@ -14,26 +14,26 @@
-- 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
--local M = minetest.get_meta
-- Convert to list and add pos based on key string
local function table_to_list(table)
local lRes = {}
for key,item in pairs(table) do
for key,item in pairs(table) do
item.pos = P(key)
lRes[#lRes+1] = item
lRes[#lRes+1] = item
end
return lRes
end
local function distance(pos1, pos2)
return math.floor(math.abs(pos1.x - pos2.x) +
return math.floor(math.abs(pos1.x - pos2.x) +
math.abs(pos1.y - pos2.y) + math.abs(pos1.z - pos2.z))
end
-- Add the distance to pos to each list item
local function add_distance_to_list(lStations, pos)
for _,item in ipairs(lStations) do
for _,item in ipairs(lStations) do
item.distance = distance(item.pos, pos)
end
return lStations
@ -50,7 +50,7 @@ local function add_index_to_list(lStations)
end
end
end
local key = nil
for idx = 1,#lStations do
key = get_next(key, idx)
@ -61,8 +61,8 @@ end
-- Return a table with all stations, the given station (as 'sKey') is connected with
-- tRes is used for the resulting table (recursive call)
local function get_stations(tStations, sKey, tRes)
if not tStations[sKey] or not tStations[sKey].conn then
return {}
if not tStations[sKey] or not tStations[sKey].conn then
return {}
end
for dir,dest in pairs(tStations[sKey].conn) do
-- Not already visited?
@ -87,7 +87,7 @@ local function sort_based_on_level(tStations)
table.sort(lStations, function(a,b) return (a.idx or 9999) < (b.idx or 9999) end)
return lStations
end
-- Return a list with sorted stations
local function sort_based_on_distance(tStations, pos)
local lStations = table_to_list(table.copy(tStations))
@ -100,7 +100,7 @@ end
-- Return a list with sorted stations
local function sort_based_on_name(tStations, pos)
local lStations = table_to_list(table.copy(tStations))
-- Add distance
-- Add distance
lStations = add_distance_to_list(lStations, pos)
table.sort(lStations, function(a,b) return a.name < b.name end)
return lStations
@ -185,7 +185,7 @@ end
function Network:changed(counter)
return self.change_counter > counter, self.change_counter
end
-- Update the connection data base. The output dir information is needed
-- to be able to delete a connection, if necessary.
-- Returns true, if data base is changed.
@ -273,16 +273,16 @@ function Network:deserialize(data)
self.change_counter = data.change_counter
end
end
function Network:serialize()
return minetest.serialize(self)
end
-- Return a pos/item table with all network nodes, the node at pos is connected with
function Network:get_node_table(pos)
local tRes = {}
local key = S(pos)
get_stations(self.tStations, key, tRes)
get_stations(self.tStations, key, tRes)
tRes[key] = nil
return tRes
end

View File

@ -15,7 +15,6 @@
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
minetest.register_craftitem("hyperloop:hypersteel_ingot", {
description = S("Hypersteel Ingot"),

View File

@ -11,16 +11,14 @@
]]--
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
--local SP = 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 S = hyperloop.S
local NS = hyperloop.NS
local I, _ = dofile( minetest.get_modpath("hyperloop").."/intllib.lua")
local Stations = hyperloop.Stations
local PlayerNameTags = {}
local function enter_display(tStation, text)
@ -28,7 +26,7 @@ local function enter_display(tStation, text)
if tStation ~= nil then
local lcd_pos = hyperloop.new_pos(tStation.pos, tStation.facedir, "1F", 2)
-- update display
minetest.registered_nodes["hyperloop:lcd"].update(lcd_pos, text)
minetest.registered_nodes["hyperloop:lcd"].update(lcd_pos, text)
end
end
@ -149,13 +147,13 @@ local function on_start_travel(pos, node, clicker)
if tDeparture == nil or tArrival == nil then
return
end
minetest.sound_play("up2", {
pos = pos,
gain = 0.5,
max_hear_distance = 2
})
-- close the door at arrival station
hyperloop.close_pod_door(tArrival)
-- place player on the seat
@ -166,9 +164,9 @@ local function on_start_travel(pos, node, clicker)
-- hide player name
PlayerNameTags[player_name] = clicker:get_nametag_attributes()
clicker:set_nametag_attributes({text = " "})
-- activate display
local dist = hyperloop.distance(pos, tArrival.pos)
local dist = hyperloop.distance(pos, tArrival.pos)
local text = I("Destination:").." | "..string.sub(tArrival.name, 1, 13).." | "..I("Distance:").." | "..
meter_to_km(dist).." | "..I("Arrival in:").." | "
local atime
@ -182,7 +180,7 @@ local function on_start_travel(pos, node, clicker)
enter_display(tDeparture, text..atime.." sec")
-- block departure and arrival stations
hyperloop.block(departure_pos, arrival_pos, atime+10)
hyperloop.block(departure_pos, arrival_pos, atime+10)
-- store some data for on_timer()
meta:set_int("arrival_time", atime)
@ -207,7 +205,7 @@ minetest.register_node("hyperloop:seat", {
},
drawtype = "nodebox",
paramtype = 'light',
light_source = 1,
light_source = 1,
paramtype2 = "facedir",
is_ground_content = false,
walkable = false,
@ -229,8 +227,8 @@ minetest.register_node("hyperloop:seat", {
on_timer = display_timer,
on_rightclick = on_start_travel,
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
auto_place_node = function(pos, facedir, sStationPos)
M(pos):set_string("sStationPos", sStationPos)
end,

View File

@ -12,12 +12,11 @@
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
--local P = minetest.string_to_pos
local M = minetest.get_meta
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
local Tube = hyperloop.Tube
local Stations = hyperloop.Stations
@ -38,7 +37,7 @@ local AssemblyPlan = {
{ 0, "1F", 2, "hyperloop:seat"},
{ 0, "1F", 0, "hyperloop:pod_floor"},
{ 1, "", 0, "hyperloop:lcd"},
-- right slice
-- right slice
{-1, "1F1R", 0, "hyperloop:pod_wall_ni"},
{ 1, "", 0, "hyperloop:pod_wall_ni"},
{ 1, "", 0, "hyperloop:pod_wall_ni"},
@ -51,7 +50,7 @@ local AssemblyPlan = {
{ 0, "1F", 0, "hyperloop:pod_wall_ni"},
{ 1, "", 0, "hyperloop:pod_wall_ni"},
{ 0, "1B", 0, "hyperloop:pod_wall_ni"},
-- left slice
-- left slice
{-1, "2L2R", 0, "hyperloop:pod_wall_ni"},
{ 1, "", 0, "hyperloop:pod_wall_ni"},
{ 1, "", 0, "hyperloop:pod_wall_ni"},
@ -69,10 +68,10 @@ local AssemblyPlan = {
local function store_station(pos, placer)
local facedir = hyperloop.get_facedir(placer)
-- do a facedir correction
-- do a facedir correction
facedir = (facedir + 3) % 4 -- face to LCD
Stations:set(pos, "Station", {
owner = placer:get_player_name(),
owner = placer:get_player_name(),
facedir = facedir,
time_blocked = 0})
end
@ -88,7 +87,7 @@ end
local function place_node(pos, facedir, node_name, sKey)
if node_name == "hyperloop:lcd" then
-- wallmounted devices need a facedir correction
local tbl = {[0]=4, [1]=2, [2]=5, [3]=3}
local tbl = {[0]=4, [1]=2, [2]=5, [3]=3}
minetest.add_node(pos, {name=node_name, paramtype2="wallmounted", param2=tbl[facedir]})
else
minetest.add_node(pos, {name=node_name, param2=facedir})
@ -107,11 +106,11 @@ local function construct(idx, pos, facedir, player_name, sKey)
else
hyperloop.chat(player_name, S("Station completed. Now place the Booking Machine!"))
end
end
end
local function check_space(pos, facedir, placer)
for _,item in ipairs(AssemblyPlan) do
local y, path, node_name = item[1], item[2], item[4]
local y, path, _ = item[1], item[2], item[4]
pos = hyperloop.new_pos(pos, facedir, path, y)
if minetest.is_protected(pos, placer:get_player_name()) then
hyperloop.chat(placer, S("Area is protected!"))
@ -169,7 +168,7 @@ local function check_inventory(inv, player)
hyperloop.chat(player, S("Not enough inventory items to build the station!"))
return false
end
local function remove_inventory_items(inv, meta)
inv:remove_item("src", ItemStack("hyperloop:pod_wall 30"))
inv:remove_item("src", ItemStack("hyperloop:hypersteel_ingot 4"))
@ -189,18 +188,18 @@ local function build_station(pos, placer)
-- check protection
if minetest.is_protected(pos, placer:get_player_name()) then
return
end
end
local meta = M(pos)
local inv = meta:get_inventory()
local facedir = hyperloop.get_facedir(placer)
-- do a facedir correction
-- do a facedir correction
facedir = (facedir + 3) % 4 -- face to LCD
if check_inventory(inv, placer) then
Stations:update(pos, {facedir = facedir})
if check_space(table.copy(pos), facedir, placer) then
construct(1, table.copy(pos), facedir, placer:get_player_name(), SP(pos))
meta:set_string("formspec", station_formspec ..
meta:set_string("formspec", station_formspec ..
"button_exit[0,3.9;3,1;destroy;"..S("Destroy Station").."]")
meta:set_int("built", 1)
meta:set_int("busy", 1)
@ -222,21 +221,21 @@ local function destroy_station(pos, player_name)
-- check protection
if minetest.is_protected(pos, player_name) then
return
end
end
local station = Stations:get(pos)
if station then
-- remove nodes
local _pos = table.copy(pos)
for _,item in ipairs(AssemblyPlan) do
local y, path, node_name = item[1], item[2], item[4]
local y, path, _ = item[1], item[2], item[4]
_pos = hyperloop.new_pos(_pos, station.facedir, path, y)
minetest.remove_node(_pos)
end
on_destruct(pos)
-- maintain meta
local meta = M(pos)
meta:set_string("formspec", station_formspec ..
meta:set_string("formspec", station_formspec ..
"button_exit[0,3.9;3,1;build;"..S("Build Station").."]")
local inv = meta:get_inventory()
add_inventory_items(inv)
@ -257,12 +256,12 @@ minetest.register_node("hyperloop:station", {
on_construct = function(pos)
local meta = M(pos)
meta:set_string("formspec", station_formspec ..
meta:set_string("formspec", station_formspec ..
"button_exit[0,3.9;3,1;build;"..S("Build Station").."]")
local inv = meta:get_inventory()
inv:set_size('src', 4)
end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
hyperloop.check_network_level(pos, placer)
M(pos):set_string("infotext", S("Station"))
@ -280,7 +279,7 @@ minetest.register_node("hyperloop:station", {
build_station(pos, player)
end
end,
on_dig = function(pos, node, puncher, pointed_thing)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -288,13 +287,13 @@ minetest.register_node("hyperloop:station", {
minetest.node_dig(pos, node, puncher, pointed_thing)
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:after_dig_node(pos)
Stations:delete(pos)
end,
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype2 = "facedir",
groups = {cracky = 1},
is_ground_content = false,
@ -309,7 +308,7 @@ minetest.register_node("hyperloop:pod_wall", {
"hyperloop_skin2.png",
"hyperloop_skin.png",
},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype2 = "facedir",
groups = {cracky=2},
is_ground_content = false,
@ -324,7 +323,7 @@ minetest.register_node("hyperloop:pod_wall_ni", {
"hyperloop_skin2.png",
"hyperloop_skin.png",
},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype2 = "facedir",
groups = {cracky=2, not_in_creative_inventory=1},
is_ground_content = false,
@ -345,7 +344,7 @@ minetest.register_node("hyperloop:pod_floor", {
{-8/16, -8/16, -8/16, 8/16, -7.5/16, 8/16},
},
},
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype2 = "facedir",
groups = {cracky=2, not_in_creative_inventory=1},
is_ground_content = false,

View File

@ -11,27 +11,11 @@
]]--
-- 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
--local M = minetest.get_meta
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
local function station_name(pos)
local dataSet = hyperloop.get_station(pos)
if dataSet then
if dataSet.junction == true then
return S("Junction at ")..SP(pos)
elseif dataSet.name ~= nil then
return S("Station '")..dataSet.name.."' at "..SP(pos)
else
return S("Station at ")..SP(pos)
end
end
return S("Open end at ")..minetest.pos_to_string(pos)
end
function hyperloop.check_network_level(pos, player)
if hyperloop.free_tube_placement_enabled then
@ -54,9 +38,9 @@ end
local Tube = tubelib2.Tube:new({
dirs_to_check = dirs_to_check,
max_tube_length = 1000,
max_tube_length = 1000,
show_infotext = true,
primary_node_names = {"hyperloop:tubeS", "hyperloop:tubeS2", "hyperloop:tubeA", "hyperloop:tubeA2"},
primary_node_names = {"hyperloop:tubeS", "hyperloop:tubeS2", "hyperloop:tubeA", "hyperloop:tubeA2"},
secondary_node_names = {"hyperloop:junction", "hyperloop:station", "hyperloop:tube_wifi1"},
after_place_tube = function(pos, param2, tube_type, num_tubes)
if num_tubes == 2 then
@ -71,7 +55,7 @@ hyperloop.Tube = Tube
minetest.register_node("hyperloop:tubeS", {
description = S("Hyperloop Tube"),
inventory_image = minetest.inventorycube("hyperloop_tube_locked.png",
inventory_image = minetest.inventorycube("hyperloop_tube_locked.png",
'hyperloop_tube_open.png', "hyperloop_tube_locked.png"),
tiles = {
-- up, down, right, left, back, front
@ -113,11 +97,11 @@ minetest.register_node("hyperloop:tubeS", {
end
return false
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:after_dig_tube(pos, oldnode, oldmetadata)
end,
paramtype2 = "facedir", -- important!
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
@ -166,7 +150,7 @@ minetest.register_node("hyperloop:tubeS2", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:after_dig_tube(pos, oldnode, oldmetadata)
end,
paramtype2 = "facedir", -- important!
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
@ -184,7 +168,7 @@ minetest.register_node("hyperloop:tubeS2", {
minetest.register_node("hyperloop:tubeA", {
description = S("Hyperloop Tube"),
inventory_image = minetest.inventorycube("hyperloop_tube_locked.png",
inventory_image = minetest.inventorycube("hyperloop_tube_locked.png",
'hyperloop_tube_open.png', "hyperloop_tube_locked.png"),
tiles = {
-- up, down, right, left, back, front
@ -233,7 +217,7 @@ minetest.register_node("hyperloop:tubeA", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:after_dig_tube(pos, oldnode, oldmetadata)
end,
paramtype2 = "facedir", -- important!
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
@ -260,7 +244,7 @@ minetest.register_node("hyperloop:tubeA2", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:after_dig_tube(pos, oldnode, oldmetadata)
end,
paramtype2 = "facedir", -- important!
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",

View File

@ -12,12 +12,11 @@
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
--local P = minetest.string_to_pos
--local M = minetest.get_meta
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
local Shaft = hyperloop.Shaft
local Tube = hyperloop.Tube
@ -36,11 +35,11 @@ end
local function repair_tubes(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.under
local dir1, dir2, fpos1, fpos2, fdir1, fdir2, cnt1, cnt2 =
local dir1, dir2, fpos1, fpos2, fdir1, fdir2, cnt1, cnt2 =
Shaft:tool_repair_tube(pos, placer, pointed_thing)
if fpos1 and fpos2 then
if cnt1 + cnt2 >= Shaft.max_tube_length then
minetest.chat_send_player(placer:get_player_name(), string.char(0x1b) ..
minetest.chat_send_player(placer:get_player_name(), string.char(0x1b) ..
"(c@#ff0000)" .. S("[Hyperloop] Error: Tube is too long!"))
end
minetest.chat_send_player(placer:get_player_name(), chat_message(dir1, cnt1, fpos1, fdir1))
@ -52,11 +51,11 @@ local function repair_tubes(itemstack, placer, pointed_thing)
max_hear_distance=5,
loop=false})
else
local dir1, dir2, fpos1, fpos2, fdir1, fdir2, cnt1, cnt2 =
dir1, dir2, fpos1, fpos2, fdir1, fdir2, cnt1, cnt2 =
Tube:tool_repair_tube(pos, placer, pointed_thing)
if fpos1 and fpos2 then
if cnt1 + cnt2 >= Shaft.max_tube_length then
minetest.chat_send_player(placer:get_player_name(), string.char(0x1b) ..
minetest.chat_send_player(placer:get_player_name(), string.char(0x1b) ..
"(c@#ff0000)" .. S("[Hyperloop] Error: Tube is too long!"))
end
minetest.chat_send_player(placer:get_player_name(), chat_message(dir1, cnt1, fpos1, fdir1))
@ -70,7 +69,7 @@ local function repair_tubes(itemstack, placer, pointed_thing)
end
end
else
minetest.chat_send_player(placer:get_player_name(),
minetest.chat_send_player(placer:get_player_name(),
S("[Crowbar Help]\n")..
S(" left: remove node\n")..
S(" right: repair tube/shaft line\n"))
@ -83,7 +82,7 @@ local function add_to_inventory(placer, item_name)
if inv and item and inv:room_for_item("main", item) then
inv:add_item("main", item)
end
end
end
local function remove_tube(itemstack, placer, pointed_thing)
if minetest.check_player_privs(placer:get_player_name(), "hyperloop") then
@ -100,10 +99,6 @@ local function remove_tube(itemstack, placer, pointed_thing)
end
end
local function dump_data_base(pos)
print(dump(hyperloop.tDatabase))
end
-- Tool for tube workers to crack a protected tube line
minetest.register_node("hyperloop:tube_crowbar", {
description = S("Hyperloop Tube Crowbar"),
@ -118,8 +113,8 @@ minetest.register_node("hyperloop:tube_crowbar", {
stack_max = 1,
})
minetest.register_privilege("hyperloop",
{description = S("Rights to remove tube nodes by means of the crowbar"),
minetest.register_privilege("hyperloop",
{description = S("Rights to remove tube nodes by means of the crowbar"),
give_to_singleplayer = false})

View File

@ -14,7 +14,7 @@
local PI = 3.1415926
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
--local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
@ -40,7 +40,7 @@ end
-- Distance between two points in (tube) blocks
function hyperloop.distance(pos1, pos2)
return math.floor(math.abs(pos1.x - pos2.x) +
return math.floor(math.abs(pos1.x - pos2.x) +
math.abs(pos1.y - pos2.y) + math.abs(pos1.z - pos2.z))
end
@ -67,7 +67,7 @@ function hyperloop.new_pos(pos, facedir, path, y_offs)
_pos = vector.add(_pos, vector.multiply(dir, num))
end
return _pos
end
end
function hyperloop.is_player_around(pos)
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 2)) do

View File

@ -17,7 +17,6 @@ local Waypoints = {}
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
minetest.register_node("hyperloop:waypoint", {
description = S("Hyperloop Waypoint"),
@ -33,7 +32,7 @@ minetest.register_node("hyperloop:waypoint", {
{ -4/16, -8/16, -4/16, 4/16, -7/16, 4/16},
},
},
after_place_node = function(pos, placer)
local name = placer:get_player_name()
if Waypoints[name] then
@ -46,7 +45,7 @@ minetest.register_node("hyperloop:waypoint", {
name = "Hyperloop",
text = "m",
world_pos = pos
})
})
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
@ -57,9 +56,9 @@ minetest.register_node("hyperloop:waypoint", {
end
end,
on_rotate = screwdriver.disallow,
on_rotate = screwdriver.disallow,
paramtype = "light",
light_source = minetest.LIGHT_MAX,
light_source = minetest.LIGHT_MAX,
sunlight_propagates = true,
groups = {cracky=2, crumbly=2, choppy=2},
is_ground_content = false,

View File

@ -12,7 +12,6 @@
-- Load support for intllib.
local S = hyperloop.S
local NS = hyperloop.NS
local Tube = hyperloop.Tube
@ -39,13 +38,13 @@ minetest.register_node("hyperloop:tube_wifi1", {
tubelib2_on_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
Tube:prepare_pairing(pos, out_dir, sFormspec)
end,
on_receive_fields = function(pos, formname, fields, player)
if fields.channel ~= nil then
Tube:pairing(pos, fields.channel)
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:stop_pairing(pos, oldmetadata, sFormspec)
local tube_dir = tonumber(oldmetadata.fields.tube_dir or 0)