Change code so that no luacheck warnings are issued
This commit is contained in:
parent
cff00b97fb
commit
b6473faed3
28
.luacheckrc
Normal file
28
.luacheckrc
Normal 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",
|
||||||
|
}
|
||||||
|
|
16
booking.lua
16
booking.lua
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
--local M = minetest.get_meta
|
||||||
|
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
--local NS = hyperloop.NS
|
||||||
|
|
||||||
local tBlockingTime = {}
|
local tBlockingTime = {}
|
||||||
local tBookings = {} -- open bookings: tBookings[SP(departure_pos)] = arrival_pos
|
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!"))
|
hyperloop.chat(player, S("Station data is corrupted. Please rebuild the station!"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if (tBlockingTime[SP(departure_pos)] or 0) > minetest.get_gametime() then
|
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!"))
|
hyperloop.chat(player, S("Station is still blocked. Please try again in a few seconds!"))
|
||||||
return false
|
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!"))
|
hyperloop.chat(player, S("Station is still blocked. Please try again in a few seconds!"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- place a reservation for 20 seconds to start the trip
|
-- place a reservation for 20 seconds to start the trip
|
||||||
tBlockingTime[SP(departure_pos)] = minetest.get_gametime() + 20
|
tBlockingTime[SP(departure_pos)] = minetest.get_gametime() + 20
|
||||||
tBlockingTime[SP(arrival_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
|
elseif Stations:get(arrival_pos) == nil then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
tBlockingTime[SP(departure_pos)] = minetest.get_gametime() + seconds
|
tBlockingTime[SP(departure_pos)] = minetest.get_gametime() + seconds
|
||||||
tBlockingTime[SP(arrival_pos)] = minetest.get_gametime() + seconds
|
tBlockingTime[SP(arrival_pos)] = minetest.get_gametime() + seconds
|
||||||
return true
|
return true
|
||||||
@ -67,14 +67,14 @@ function hyperloop.is_blocked(pos)
|
|||||||
if Stations:get(pos) == nil then
|
if Stations:get(pos) == nil then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return (tBlockingTime[SP(pos)] or 0) > minetest.get_gametime()
|
return (tBlockingTime[SP(pos)] or 0) > minetest.get_gametime()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function hyperloop.set_arrival(departure_pos, arrival_pos)
|
function hyperloop.set_arrival(departure_pos, arrival_pos)
|
||||||
tBookings[SP(departure_pos)] = arrival_pos
|
tBookings[SP(departure_pos)] = arrival_pos
|
||||||
end
|
end
|
||||||
|
|
||||||
function hyperloop.get_arrival(departure_pos)
|
function hyperloop.get_arrival(departure_pos)
|
||||||
-- Return and delete the arrival pos
|
-- Return and delete the arrival pos
|
||||||
|
@ -18,9 +18,8 @@ local M = minetest.get_meta
|
|||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
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, ...}
|
-- tStationList[SP(pos)] = {pos1, pos2, ...}
|
||||||
local tStationList = {}
|
local tStationList = {}
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ local function generate_string(sortedList)
|
|||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
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").."]"}
|
"label[4,0; "..S("Select your destination").."]"}
|
||||||
tRes[2] = "tablecolumns[text,width=20;text,width=6,align=right;text]"
|
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
|
if subnet == "" then
|
||||||
subnet = nil
|
subnet = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local tbl = {}
|
local tbl = {}
|
||||||
for idx,item in ipairs(sortedList) do
|
for idx,item in ipairs(sortedList) do
|
||||||
if item.subnet == subnet then
|
if item.subnet == subnet then
|
||||||
@ -95,7 +94,6 @@ end
|
|||||||
-- Used to update the station list for booking machine
|
-- Used to update the station list for booking machine
|
||||||
-- and teleport list.
|
-- and teleport list.
|
||||||
local function station_list_as_string(pos, subnet)
|
local function station_list_as_string(pos, subnet)
|
||||||
local meta = M(pos)
|
|
||||||
-- Generate a name sorted list of all connected stations
|
-- Generate a name sorted list of all connected stations
|
||||||
local sortedList = Stations:station_list(pos, pos, "name")
|
local sortedList = Stations:station_list(pos, pos, "name")
|
||||||
-- remove all junctions from the list
|
-- remove all junctions from the list
|
||||||
@ -108,7 +106,7 @@ local function station_list_as_string(pos, subnet)
|
|||||||
return generate_string(sortedList)
|
return generate_string(sortedList)
|
||||||
end
|
end
|
||||||
|
|
||||||
local naming_formspec = nil
|
local naming_formspec
|
||||||
|
|
||||||
if hyperloop.subnet_enabled then
|
if hyperloop.subnet_enabled then
|
||||||
naming_formspec = function(pos)
|
naming_formspec = function(pos)
|
||||||
@ -185,7 +183,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
booking_info = string.trim(fields.info),
|
booking_info = string.trim(fields.info),
|
||||||
subnet = subnet,
|
subnet = subnet,
|
||||||
})
|
})
|
||||||
|
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
meta:set_string("sStationPos", SP(stationPos))
|
meta:set_string("sStationPos", SP(stationPos))
|
||||||
meta:set_string("infotext", "Station: "..station_name)
|
meta:set_string("infotext", "Station: "..station_name)
|
||||||
@ -217,7 +215,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_destruct(pos)
|
local function on_destruct(pos)
|
||||||
local sStationPos = M(pos):get_string("sStationPos")
|
local sStationPos = M(pos):get_string("sStationPos")
|
||||||
if sStationPos ~= "" then
|
if sStationPos ~= "" then
|
||||||
@ -229,7 +227,7 @@ local function on_destruct(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- wap from wall to ground
|
-- wap from wall to ground
|
||||||
local function swap_node(pos, placer)
|
local function swap_node(pos, placer)
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
if minetest.get_node_or_nil(pos).name ~= "air" then
|
if minetest.get_node_or_nil(pos).name ~= "air" then
|
||||||
@ -255,7 +253,7 @@ minetest.register_node("hyperloop:booking", {
|
|||||||
"hyperloop_booking.png",
|
"hyperloop_booking.png",
|
||||||
"hyperloop_booking_front.png",
|
"hyperloop_booking_front.png",
|
||||||
},
|
},
|
||||||
|
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
@ -263,13 +261,13 @@ minetest.register_node("hyperloop:booking", {
|
|||||||
{ -8/16, -8/16, 2/16, 8/16, 8/16, 8/16},
|
{ -8/16, -8/16, 2/16, 8/16, 8/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
naming_formspec(pos)
|
naming_formspec(pos)
|
||||||
swap_node(pos, placer)
|
swap_node(pos, placer)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_destruct = on_destruct,
|
on_destruct = on_destruct,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
@ -293,7 +291,7 @@ minetest.register_node("hyperloop:booking_ground", {
|
|||||||
"hyperloop_booking.png",
|
"hyperloop_booking.png",
|
||||||
"hyperloop_booking_front.png",
|
"hyperloop_booking_front.png",
|
||||||
},
|
},
|
||||||
|
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
@ -301,7 +299,7 @@ minetest.register_node("hyperloop:booking_ground", {
|
|||||||
{ -8/16, -8/16, -3/16, 8/16, 8/16, 3/16},
|
{ -8/16, -8/16, -3/16, 8/16, 8/16, 3/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
naming_formspec(pos)
|
naming_formspec(pos)
|
||||||
end,
|
end,
|
||||||
@ -309,8 +307,8 @@ minetest.register_node("hyperloop:booking_ground", {
|
|||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_destruct = on_destruct,
|
on_destruct = on_destruct,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
drop = "hyperloop:booking",
|
drop = "hyperloop:booking",
|
||||||
light_source = 2,
|
light_source = 2,
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
|
@ -12,30 +12,12 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
--local M = minetest.get_meta
|
||||||
local M = minetest.get_meta
|
|
||||||
|
|
||||||
hyperloop.Stations = hyperloop.Network:new()
|
hyperloop.Stations = hyperloop.Network:new()
|
||||||
hyperloop.Elevators = 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()
|
local storage = minetest.get_mod_storage()
|
||||||
hyperloop.Stations:deserialize(storage:get_string("Stations"))
|
hyperloop.Stations:deserialize(storage:get_string("Stations"))
|
||||||
hyperloop.Elevators:deserialize(storage:get_string("Elevators"))
|
hyperloop.Elevators:deserialize(storage:get_string("Elevators"))
|
||||||
|
19
deco.lua
19
deco.lua
@ -15,20 +15,19 @@
|
|||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
local tilesL = {"hyperloop_alpsL.png", "hyperloop_seaL.png", "hyperloop_agyptL.png"}
|
local tilesL = {"hyperloop_alpsL.png", "hyperloop_seaL.png", "hyperloop_agyptL.png"}
|
||||||
local tilesR = {"hyperloop_alpsR.png", "hyperloop_seaR.png", "hyperloop_agyptR.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
|
-- 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)
|
local facedir = hyperloop.get_facedir(placer)
|
||||||
pos = hyperloop.new_pos(pos, facedir, "1R", 0)
|
pos = hyperloop.new_pos(pos, facedir, "1R", 0)
|
||||||
return facedir,pos
|
return facedir,pos
|
||||||
end
|
end
|
||||||
|
|
||||||
for idx = 1,3 do
|
for idx = 1,3 do
|
||||||
|
|
||||||
minetest.register_node("hyperloop:poster"..idx.."L", {
|
minetest.register_node("hyperloop:poster"..idx.."L", {
|
||||||
description = S("Hyperloop Promo Poster ")..idx,
|
description = S("Hyperloop Promo Poster ")..idx,
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -51,7 +50,7 @@ for idx = 1,3 do
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -8/16, -8/16, -6/16, 24/16, 8/16, 8/16},
|
fixed = { -8/16, -8/16, -6/16, 24/16, 8/16, 8/16},
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local facedir
|
local facedir
|
||||||
@ -69,8 +68,8 @@ for idx = 1,3 do
|
|||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
light_source = 4,
|
light_source = 4,
|
||||||
is_ground_content = false,
|
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},
|
{ -8/16, -5/16, 6/16, 8/16, 5/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
if minetest.get_node_or_nil(pos).name ~= "air" then
|
if minetest.get_node_or_nil(pos).name ~= "air" then
|
||||||
@ -144,7 +143,7 @@ minetest.register_node("hyperloop:signR", {
|
|||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
light_source = 4,
|
light_source = 4,
|
||||||
@ -170,7 +169,7 @@ minetest.register_node("hyperloop:signL", {
|
|||||||
{ -8/16, -5/16, 6/16, 8/16, 5/16, 8/16},
|
{ -8/16, -5/16, 6/16, 8/16, 5/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
if minetest.get_node_or_nil(pos).name ~= "air" then
|
if minetest.get_node_or_nil(pos).name ~= "air" then
|
||||||
@ -181,7 +180,7 @@ minetest.register_node("hyperloop:signL", {
|
|||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
light_source = 4,
|
light_source = 4,
|
||||||
|
26
door.lua
26
door.lua
@ -11,13 +11,12 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
|
|
||||||
--- Load support for intllib.
|
--- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
-- Open the door for an emergency
|
-- Open the door for an emergency
|
||||||
local function door_on_punch(pos, node, puncher, pointed_thing)
|
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 node1 = minetest.get_node(door_pos1)
|
||||||
local node2 = minetest.get_node(door_pos2)
|
local node2 = minetest.get_node(door_pos2)
|
||||||
local meta = minetest.get_meta(door_pos1)
|
|
||||||
if cmnd == "open" then
|
if cmnd == "open" then
|
||||||
minetest.sound_play("door", {
|
minetest.sound_play("door", {
|
||||||
pos = door_pos1,
|
pos = door_pos1,
|
||||||
@ -116,15 +114,15 @@ minetest.register_node("hyperloop:doorTopPassive", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
|
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
|
||||||
},
|
},
|
||||||
|
|
||||||
on_punch = door_on_punch,
|
on_punch = door_on_punch,
|
||||||
|
|
||||||
auto_place_node = function(pos, facedir, sStationPos)
|
auto_place_node = function(pos, facedir, sStationPos)
|
||||||
M(pos):set_int("facedir", facedir)
|
M(pos):set_int("facedir", facedir)
|
||||||
M(pos):set_string("sStationPos", sStationPos)
|
M(pos):set_string("sStationPos", sStationPos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
light_source = 1,
|
light_source = 1,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@ -158,8 +156,8 @@ minetest.register_node("hyperloop:doorTopActive", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
|
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
|
||||||
},
|
},
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
drop = "",
|
drop = "",
|
||||||
light_source = 2,
|
light_source = 2,
|
||||||
@ -184,15 +182,15 @@ minetest.register_node("hyperloop:doorBottom", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
|
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
|
||||||
},
|
},
|
||||||
|
|
||||||
on_punch = door_on_punch,
|
on_punch = door_on_punch,
|
||||||
|
|
||||||
auto_place_node = function(pos, facedir, sStationPos)
|
auto_place_node = function(pos, facedir, sStationPos)
|
||||||
M(pos):set_int("facedir", facedir)
|
M(pos):set_int("facedir", facedir)
|
||||||
M(pos):set_string("sStationPos", sStationPos)
|
M(pos):set_string("sStationPos", sStationPos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
light_source = 1,
|
light_source = 1,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
65
elevator.lua
65
elevator.lua
@ -17,7 +17,6 @@ local M = minetest.get_meta
|
|||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
-- To store elevator floors and formspecs
|
-- To store elevator floors and formspecs
|
||||||
local Cache = {}
|
local Cache = {}
|
||||||
@ -36,9 +35,9 @@ end
|
|||||||
|
|
||||||
local Shaft = tubelib2.Tube:new({
|
local Shaft = tubelib2.Tube:new({
|
||||||
dirs_to_check = dirs_to_check,
|
dirs_to_check = dirs_to_check,
|
||||||
max_tube_length = 1000,
|
max_tube_length = 1000,
|
||||||
show_infotext = true,
|
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"},
|
secondary_node_names = {"hyperloop:elevator_bottom", "hyperloop:elevator_top"},
|
||||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||||
if tube_type == "S" then
|
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
|
-- switch to elevator_bottom node
|
||||||
pos = Shaft:get_pos(pos, 5)
|
pos = Shaft:get_pos(pos, 5)
|
||||||
elseif peer_pos then
|
elseif peer_pos then
|
||||||
local _,node = Shaft:get_node(peer_pos)
|
local _,node1 = Shaft:get_node(peer_pos)
|
||||||
if node.name == "hyperloop:elevator_top" then
|
if node1.name == "hyperloop:elevator_top" then
|
||||||
peer_pos = Shaft:get_pos(peer_pos, 5)
|
peer_pos = Shaft:get_pos(peer_pos, 5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -108,11 +107,11 @@ minetest.register_node("hyperloop:shaft", {
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
|
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
climbable = true,
|
climbable = true,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
@ -158,11 +157,11 @@ minetest.register_node("hyperloop:shaftA", {
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
|
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
climbable = true,
|
climbable = true,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
@ -204,7 +203,7 @@ minetest.register_node("hyperloop:shaft2", {
|
|||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
|
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
climbable = true,
|
climbable = true,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
@ -251,7 +250,7 @@ minetest.register_node("hyperloop:shaftA2", {
|
|||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
|
Shaft:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
climbable = true,
|
climbable = true,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
on_rotate = screwdriver.disallow,
|
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_pos1 = hyperloop.new_pos(floor_pos, facedir, "1B", 0)
|
||||||
local door_pos2 = hyperloop.new_pos(floor_pos, facedir, "1B", 1)
|
local door_pos2 = hyperloop.new_pos(floor_pos, facedir, "1B", 1)
|
||||||
local meta = M(floor_pos)
|
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
|
if owner and (minetest.is_protected(door_pos1, owner) or minetest.is_protected(door_pos2, owner)) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local node1 = minetest.get_node(door_pos1)
|
local node1 = minetest.get_node(door_pos1)
|
||||||
local node2 = minetest.get_node(door_pos2)
|
local node2 = minetest.get_node(door_pos2)
|
||||||
|
|
||||||
if sound then
|
if sound then
|
||||||
minetest.sound_play("ele_door", {
|
minetest.sound_play("ele_door", {
|
||||||
pos = floor_pos,
|
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 },
|
fixed = { -8/16, -8/16, -8/16, 8/16, 23/16, 8/16 },
|
||||||
},
|
},
|
||||||
inventory_image = "hyperloop_elevator_inventory.png",
|
inventory_image = "hyperloop_elevator_inventory.png",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
light_source = 6,
|
light_source = 6,
|
||||||
@ -458,25 +457,25 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
|||||||
if node.name == "air" then
|
if node.name == "air" then
|
||||||
local facedir = hyperloop.get_facedir(placer)
|
local facedir = hyperloop.get_facedir(placer)
|
||||||
Elevators:set(pos, "<unknown>", {facedir=facedir, busy=false})
|
Elevators:set(pos, "<unknown>", {facedir=facedir, busy=false})
|
||||||
|
|
||||||
Shaft:after_place_node(pos, {5})
|
Shaft:after_place_node(pos, {5})
|
||||||
|
|
||||||
-- formspec
|
-- formspec
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local formspec = "size[6,4]"..
|
local fs = "size[6,4]"..
|
||||||
"label[0,0;"..S("Please insert floor name").."]" ..
|
"label[0,0;"..S("Please insert floor name").."]" ..
|
||||||
"field[0.5,1.5;5,1;floor;"..S("Floor name")..";"..S("Base").."]" ..
|
"field[0.5,1.5;5,1;floor;"..S("Floor name")..";"..S("Base").."]" ..
|
||||||
"button_exit[2,3;2,1;exit;"..S("Save").."]"
|
"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())
|
meta:set_string("owner", placer:get_player_name())
|
||||||
|
|
||||||
-- add upper part of the car
|
-- add upper part of the car
|
||||||
pos = Shaft:get_pos(pos, 6)
|
pos = Shaft:get_pos(pos, 6)
|
||||||
minetest.add_node(pos, {name="hyperloop:elevator_top", param2=facedir})
|
minetest.add_node(pos, {name="hyperloop:elevator_top", param2=facedir})
|
||||||
Shaft:after_place_node(pos, {6})
|
Shaft:after_place_node(pos, {6})
|
||||||
else
|
else
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -559,8 +558,8 @@ minetest.register_node("hyperloop:elevator_top", {
|
|||||||
{ -7/16, -8/16, 7/16, 7/16, 8/16, 8/16},
|
{ -7/16, -8/16, 7/16, 7/16, 8/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
light_source = 6,
|
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},
|
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
drop = "",
|
drop = "",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@ -607,12 +606,12 @@ minetest.register_node("hyperloop:elevator_door", {
|
|||||||
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
|
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -8/16, -8/16, 6.5/16, 8/16, 24/16, 8/16 },
|
fixed = { -8/16, -8/16, 6.5/16, 8/16, 24/16, 8/16 },
|
||||||
},
|
},
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
local floor_pos = P(M(pos):get_string("floor_pos"))
|
local floor_pos = P(M(pos):get_string("floor_pos"))
|
||||||
if floor_pos ~= nil then
|
if floor_pos ~= nil then
|
||||||
@ -623,8 +622,8 @@ minetest.register_node("hyperloop:elevator_door", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
drop = "",
|
drop = "",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
paramtype2 = "facedir",
|
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},
|
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
drop = "",
|
drop = "",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
paramtype2 = "facedir",
|
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},
|
{ -8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -8/16, -8/16, 7/16, 8/16, 24/16, 8/16 },
|
fixed = { -8/16, -8/16, 7/16, 8/16, 24/16, 8/16 },
|
||||||
},
|
},
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
drop = "",
|
drop = "",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
4
init.lua
4
init.lua
@ -34,8 +34,8 @@
|
|||||||
2020-01-03 v2.04 Elevator door bugfix (MT 5+)
|
2020-01-03 v2.04 Elevator door bugfix (MT 5+)
|
||||||
2020-03-12 v2.05 minetest translator added (thanks to acmgit/Clyde)
|
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
|
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-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-11-01 v2.08 Enable the use of hyperloop networks for other mods
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
@ -11,13 +11,12 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
local Tube = hyperloop.Tube
|
local Tube = hyperloop.Tube
|
||||||
local Stations = hyperloop.Stations
|
local Stations = hyperloop.Stations
|
||||||
@ -63,7 +62,7 @@ minetest.register_node("hyperloop:junction", {
|
|||||||
Tube:after_dig_node(pos)
|
Tube:after_dig_node(pos)
|
||||||
Stations:delete(pos)
|
Stations:delete(pos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
10
lcd.lua
10
lcd.lua
@ -1,8 +1,8 @@
|
|||||||
--[[
|
--[[
|
||||||
|
|
||||||
LCD
|
LCD
|
||||||
===
|
===
|
||||||
|
|
||||||
Derived from the work of kaeza, sofar and others (digilines)
|
Derived from the work of kaeza, sofar and others (digilines)
|
||||||
|
|
||||||
LGPLv2.1+
|
LGPLv2.1+
|
||||||
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
|
|
||||||
-- load characters map
|
-- load characters map
|
||||||
local chars_file = io.open(minetest.get_modpath("hyperloop").."/characters.data", "r")
|
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"),
|
description = S("Hyperloop Display"),
|
||||||
tiles = {"hyperloop_lcd.png"},
|
tiles = {"hyperloop_lcd.png"},
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
@ -185,7 +183,7 @@ minetest.register_node("hyperloop:lcd", {
|
|||||||
update = function(pos, text)
|
update = function(pos, text)
|
||||||
lcd_update(pos, text)
|
lcd_update(pos, text)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
light_source = 6,
|
light_source = 6,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
13
map.lua
13
map.lua
@ -12,12 +12,11 @@
|
|||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
--local M = minetest.get_meta
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
local Stations = hyperloop.Stations
|
local Stations = hyperloop.Stations
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ local function generate_string(sortedList)
|
|||||||
local sKey = SP(item.pos)
|
local sKey = SP(item.pos)
|
||||||
lStationPositions[sKey] = idx
|
lStationPositions[sKey] = idx
|
||||||
end
|
end
|
||||||
|
|
||||||
local tRes = {
|
local tRes = {
|
||||||
"label[0,0;ID]"..
|
"label[0,0;ID]"..
|
||||||
"label[0.7,0;"..S("Dist.").."]"..
|
"label[0.7,0;"..S("Dist.").."]"..
|
||||||
@ -46,7 +45,7 @@ local function generate_string(sortedList)
|
|||||||
local owner = dataSet.owner or "<unknown>"
|
local owner = dataSet.owner or "<unknown>"
|
||||||
local name = dataSet.name or "<unknown>"
|
local name = dataSet.name or "<unknown>"
|
||||||
local distance = dataSet.distance or 0
|
local distance = dataSet.distance or 0
|
||||||
|
|
||||||
tRes[#tRes+1] = "label[0,"..ypos..";"..idx.."]"
|
tRes[#tRes+1] = "label[0,"..ypos..";"..idx.."]"
|
||||||
tRes[#tRes+1] = "label[0.7,"..ypos..";"..distance.." m]"
|
tRes[#tRes+1] = "label[0.7,"..ypos..";"..distance.." m]"
|
||||||
tRes[#tRes+1] = "label[1.8,"..ypos..";"..string.sub(name,1,24).."]"
|
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 player_name = user:get_player_name()
|
||||||
local pos = user:get_pos()
|
local pos = user:get_pos()
|
||||||
local sStationList = station_list_as_string(pos)
|
local sStationList = station_list_as_string(pos)
|
||||||
local formspec = "size[12,10]" ..
|
local formspec = "size[12,10]" ..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
@ -102,7 +101,7 @@ local function map_on_secondary_use(itemstack, user)
|
|||||||
local player_name = user:get_player_name()
|
local player_name = user:get_player_name()
|
||||||
local pos = user:get_pos()
|
local pos = user:get_pos()
|
||||||
local sStationList = network_list_as_string(pos)
|
local sStationList = network_list_as_string(pos)
|
||||||
local formspec = "size[12,10]" ..
|
local formspec = "size[12,10]" ..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
|
59
migrate.lua
59
migrate.lua
@ -12,7 +12,7 @@
|
|||||||
see init.lua
|
see init.lua
|
||||||
|
|
||||||
Migrate from v1 to v2
|
Migrate from v1 to v2
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- for lazy programmers
|
-- for lazy programmers
|
||||||
@ -22,7 +22,6 @@ local M = minetest.get_meta
|
|||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
local Tube = hyperloop.Tube
|
local Tube = hyperloop.Tube
|
||||||
local Shaft = hyperloop.Shaft
|
local Shaft = hyperloop.Shaft
|
||||||
@ -37,12 +36,12 @@ local JunctionsToBePlacedAfter = {}
|
|||||||
local function get_tube_data(pos, dir1, dir2, num_tubes)
|
local function get_tube_data(pos, dir1, dir2, num_tubes)
|
||||||
local param2, tube_type = tubelib2.encode_param2(dir1, dir2, num_tubes)
|
local param2, tube_type = tubelib2.encode_param2(dir1, dir2, num_tubes)
|
||||||
return pos, param2, tube_type, num_tubes
|
return pos, param2, tube_type, num_tubes
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if node has a connection on the given dir
|
-- Check if node has a connection on the given dir
|
||||||
local function connected(self, pos, dir)
|
local function connected(self, pos, dir)
|
||||||
local _,node = self:get_node(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]
|
or self.secondary_node_names[node.name]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ local function convert_legary_nodes(self, pos, dir)
|
|||||||
if tLegacyNodeNames[node.name] then
|
if tLegacyNodeNames[node.name] then
|
||||||
local dir1, dir2, num = determine_dir1_dir2_and_num_conn(self, npos)
|
local dir1, dir2, num = determine_dir1_dir2_and_num_conn(self, npos)
|
||||||
if dir1 then
|
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))
|
dir2 or tubelib2.Turn180Deg[dir1], num))
|
||||||
if tubelib2.Turn180Deg[dir] == dir1 then
|
if tubelib2.Turn180Deg[dir] == dir1 then
|
||||||
return npos, dir2
|
return npos, dir2
|
||||||
@ -110,9 +109,9 @@ local function convert_legary_nodes(self, pos, dir)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cnt = 0
|
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
|
while cnt <= 64000 do
|
||||||
local new_pos, new_dir = convert_next_tube(self, pos, dir)
|
local new_pos, new_dir = convert_next_tube(self, pos, dir)
|
||||||
if cnt > 0 and (cnt % self.max_tube_length) == 0 then -- border reached?
|
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
|
cnt = cnt + 1
|
||||||
end
|
end
|
||||||
return pos, dir, cnt
|
return pos, dir, cnt
|
||||||
end
|
end
|
||||||
|
|
||||||
local function convert_line(self, pos, dir)
|
local function convert_line(self, pos, dir)
|
||||||
local fpos,fdir = convert_legary_nodes(self, pos, dir)
|
convert_legary_nodes(self, pos, dir)
|
||||||
self:tool_repair_tube(pos)
|
self:tool_repair_tube(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -135,12 +134,12 @@ local tWifiNodes = {} -- user for pairing
|
|||||||
local lWifiNodes = {} -- used for post processing
|
local lWifiNodes = {} -- used for post processing
|
||||||
|
|
||||||
local function set_pairing(pos, peer_pos)
|
local function set_pairing(pos, peer_pos)
|
||||||
|
|
||||||
M(pos):set_int("tube_dir", Tube:get_primary_dir(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))
|
M(peer_pos):set_int("tube_dir", Tube:get_primary_dir(peer_pos))
|
||||||
|
|
||||||
local tube_dir1 = Tube:store_teleport_data(pos, peer_pos)
|
Tube:store_teleport_data(pos, peer_pos)
|
||||||
local tube_dir2 = Tube:store_teleport_data(peer_pos, pos)
|
Tube:store_teleport_data(peer_pos, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -195,8 +194,8 @@ end
|
|||||||
|
|
||||||
local function search_wifi_node(pos, dir)
|
local function search_wifi_node(pos, dir)
|
||||||
local convert_next_tube = function(pos, dir)
|
local convert_next_tube = function(pos, dir)
|
||||||
local npos, node = Tube:get_node(pos, dir)
|
local npos, _ = Tube:get_node(pos, dir)
|
||||||
local dir1, dir2, num = next_node_on_the_way_to_a_wifi_node(npos)
|
local dir1, dir2, _ = next_node_on_the_way_to_a_wifi_node(npos)
|
||||||
if dir1 then
|
if dir1 then
|
||||||
if tubelib2.Turn180Deg[dir] == dir1 then
|
if tubelib2.Turn180Deg[dir] == dir1 then
|
||||||
return npos, dir2
|
return npos, dir2
|
||||||
@ -205,9 +204,9 @@ local function search_wifi_node(pos, dir)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cnt = 0
|
local cnt = 0
|
||||||
if not dir then return pos, cnt end
|
if not dir then return pos, cnt end
|
||||||
while true do
|
while true do
|
||||||
local new_pos, new_dir = convert_next_tube(pos, dir)
|
local new_pos, new_dir = convert_next_tube(pos, dir)
|
||||||
if not new_dir then break end
|
if not new_dir then break end
|
||||||
@ -215,12 +214,12 @@ local function search_wifi_node(pos, dir)
|
|||||||
cnt = cnt + 1
|
cnt = cnt + 1
|
||||||
end
|
end
|
||||||
return pos, dir, cnt
|
return pos, dir, cnt
|
||||||
end
|
end
|
||||||
|
|
||||||
local function search_wifi_node_in_all_dirs(pos)
|
local function search_wifi_node_in_all_dirs(pos)
|
||||||
-- check all positions
|
-- check all positions
|
||||||
for dir = 1, 6 do
|
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
|
if node and node.name == "hyperloop:tube1" then
|
||||||
search_wifi_node(pos, dir)
|
search_wifi_node(pos, dir)
|
||||||
end
|
end
|
||||||
@ -230,7 +229,7 @@ end
|
|||||||
local function convert_tube_line(pos)
|
local function convert_tube_line(pos)
|
||||||
-- check all positions
|
-- check all positions
|
||||||
for dir = 1, 6 do
|
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
|
if node and node.name == "hyperloop:tube1" then
|
||||||
convert_line(Tube, pos, dir)
|
convert_line(Tube, pos, dir)
|
||||||
end
|
end
|
||||||
@ -266,13 +265,13 @@ end
|
|||||||
|
|
||||||
local function convert_station_data(tAllStations)
|
local function convert_station_data(tAllStations)
|
||||||
tLegacyNodeNames = {
|
tLegacyNodeNames = {
|
||||||
["hyperloop:tube0"] = true,
|
["hyperloop:tube0"] = true,
|
||||||
["hyperloop:tube1"] = true,
|
["hyperloop:tube1"] = true,
|
||||||
["hyperloop:tube2"] = true,
|
["hyperloop:tube2"] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
local originNodeNames = add_to_table(Tube.primary_node_names, tLegacyNodeNames)
|
local originNodeNames = add_to_table(Tube.primary_node_names, tLegacyNodeNames)
|
||||||
|
|
||||||
for key,item in pairs(tAllStations) do
|
for key,item in pairs(tAllStations) do
|
||||||
if item.pos and Tube:is_secondary_node(item.pos) then
|
if item.pos and Tube:is_secondary_node(item.pos) then
|
||||||
Stations:set(item.pos, station_name(item), {
|
Stations:set(item.pos, station_name(item), {
|
||||||
@ -301,19 +300,19 @@ local function convert_station_data(tAllStations)
|
|||||||
end
|
end
|
||||||
-- Repair the tube lines of wifi nodes
|
-- Repair the tube lines of wifi nodes
|
||||||
wifi_post_processing()
|
wifi_post_processing()
|
||||||
|
|
||||||
Tube.primary_node_names = originNodeNames
|
Tube.primary_node_names = originNodeNames
|
||||||
end
|
end
|
||||||
|
|
||||||
local function convert_elevator_data(tAllElevators)
|
local function convert_elevator_data(tAllElevators)
|
||||||
tLegacyNodeNames = {
|
tLegacyNodeNames = {
|
||||||
["hyperloop:shaft"] = true,
|
["hyperloop:shaft"] = true,
|
||||||
["hyperloop:shaft2"] = true,
|
["hyperloop:shaft2"] = true,
|
||||||
}
|
}
|
||||||
local originNodeNames = add_to_table(Shaft.primary_node_names, tLegacyNodeNames)
|
local originNodeNames = add_to_table(Shaft.primary_node_names, tLegacyNodeNames)
|
||||||
local originDirsToCheck = table.copy(Shaft.dirs_to_check)
|
local originDirsToCheck = table.copy(Shaft.dirs_to_check)
|
||||||
Shaft.dirs_to_check = {5,6} -- legacy elevators use up/down only
|
Shaft.dirs_to_check = {5,6} -- legacy elevators use up/down only
|
||||||
|
|
||||||
for pos,tElevator in pairs(tAllElevators) do
|
for pos,tElevator in pairs(tAllElevators) do
|
||||||
for _,floor in pairs(tElevator.floors) do
|
for _,floor in pairs(tElevator.floors) do
|
||||||
if floor.pos and Shaft:is_secondary_node(floor.pos) then
|
if floor.pos and Shaft:is_secondary_node(floor.pos) then
|
||||||
@ -326,7 +325,7 @@ local function convert_elevator_data(tAllElevators)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Shaft.primary_node_names = originNodeNames
|
Shaft.primary_node_names = originNodeNames
|
||||||
Shaft.dirs_to_check = originDirsToCheck
|
Shaft.dirs_to_check = originDirsToCheck
|
||||||
end
|
end
|
||||||
|
28
network.lua
28
network.lua
@ -14,26 +14,26 @@
|
|||||||
-- for lazy programmers
|
-- for lazy programmers
|
||||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
local S = 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
|
--local M = minetest.get_meta
|
||||||
|
|
||||||
-- Convert to list and add pos based on key string
|
-- Convert to list and add pos based on key string
|
||||||
local function table_to_list(table)
|
local function table_to_list(table)
|
||||||
local lRes = {}
|
local lRes = {}
|
||||||
for key,item in pairs(table) do
|
for key,item in pairs(table) do
|
||||||
item.pos = P(key)
|
item.pos = P(key)
|
||||||
lRes[#lRes+1] = item
|
lRes[#lRes+1] = item
|
||||||
end
|
end
|
||||||
return lRes
|
return lRes
|
||||||
end
|
end
|
||||||
|
|
||||||
local function distance(pos1, pos2)
|
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))
|
math.abs(pos1.y - pos2.y) + math.abs(pos1.z - pos2.z))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add the distance to pos to each list item
|
-- Add the distance to pos to each list item
|
||||||
local function add_distance_to_list(lStations, pos)
|
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)
|
item.distance = distance(item.pos, pos)
|
||||||
end
|
end
|
||||||
return lStations
|
return lStations
|
||||||
@ -50,7 +50,7 @@ local function add_index_to_list(lStations)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local key = nil
|
local key = nil
|
||||||
for idx = 1,#lStations do
|
for idx = 1,#lStations do
|
||||||
key = get_next(key, idx)
|
key = get_next(key, idx)
|
||||||
@ -61,8 +61,8 @@ end
|
|||||||
-- Return a table with all stations, the given station (as 'sKey') is connected with
|
-- Return a table with all stations, the given station (as 'sKey') is connected with
|
||||||
-- tRes is used for the resulting table (recursive call)
|
-- tRes is used for the resulting table (recursive call)
|
||||||
local function get_stations(tStations, sKey, tRes)
|
local function get_stations(tStations, sKey, tRes)
|
||||||
if not tStations[sKey] or not tStations[sKey].conn then
|
if not tStations[sKey] or not tStations[sKey].conn then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
for dir,dest in pairs(tStations[sKey].conn) do
|
for dir,dest in pairs(tStations[sKey].conn) do
|
||||||
-- Not already visited?
|
-- 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)
|
table.sort(lStations, function(a,b) return (a.idx or 9999) < (b.idx or 9999) end)
|
||||||
return lStations
|
return lStations
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Return a list with sorted stations
|
-- Return a list with sorted stations
|
||||||
local function sort_based_on_distance(tStations, pos)
|
local function sort_based_on_distance(tStations, pos)
|
||||||
local lStations = table_to_list(table.copy(tStations))
|
local lStations = table_to_list(table.copy(tStations))
|
||||||
@ -100,7 +100,7 @@ end
|
|||||||
-- Return a list with sorted stations
|
-- Return a list with sorted stations
|
||||||
local function sort_based_on_name(tStations, pos)
|
local function sort_based_on_name(tStations, pos)
|
||||||
local lStations = table_to_list(table.copy(tStations))
|
local lStations = table_to_list(table.copy(tStations))
|
||||||
-- Add distance
|
-- Add distance
|
||||||
lStations = add_distance_to_list(lStations, pos)
|
lStations = add_distance_to_list(lStations, pos)
|
||||||
table.sort(lStations, function(a,b) return a.name < b.name end)
|
table.sort(lStations, function(a,b) return a.name < b.name end)
|
||||||
return lStations
|
return lStations
|
||||||
@ -185,7 +185,7 @@ end
|
|||||||
function Network:changed(counter)
|
function Network:changed(counter)
|
||||||
return self.change_counter > counter, self.change_counter
|
return self.change_counter > counter, self.change_counter
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update the connection data base. The output dir information is needed
|
-- Update the connection data base. The output dir information is needed
|
||||||
-- to be able to delete a connection, if necessary.
|
-- to be able to delete a connection, if necessary.
|
||||||
-- Returns true, if data base is changed.
|
-- Returns true, if data base is changed.
|
||||||
@ -273,16 +273,16 @@ function Network:deserialize(data)
|
|||||||
self.change_counter = data.change_counter
|
self.change_counter = data.change_counter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Network:serialize()
|
function Network:serialize()
|
||||||
return minetest.serialize(self)
|
return minetest.serialize(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Return a pos/item table with all network nodes, the node at pos is connected with
|
-- Return a pos/item table with all network nodes, the node at pos is connected with
|
||||||
function Network:get_node_table(pos)
|
function Network:get_node_table(pos)
|
||||||
local tRes = {}
|
local tRes = {}
|
||||||
local key = S(pos)
|
local key = S(pos)
|
||||||
get_stations(self.tStations, key, tRes)
|
get_stations(self.tStations, key, tRes)
|
||||||
tRes[key] = nil
|
tRes[key] = nil
|
||||||
return tRes
|
return tRes
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
minetest.register_craftitem("hyperloop:hypersteel_ingot", {
|
minetest.register_craftitem("hyperloop:hypersteel_ingot", {
|
||||||
description = S("Hypersteel Ingot"),
|
description = S("Hypersteel Ingot"),
|
||||||
|
24
seat.lua
24
seat.lua
@ -11,16 +11,14 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
local I, _ = dofile( minetest.get_modpath("hyperloop").."/intllib.lua")
|
local I, _ = dofile( minetest.get_modpath("hyperloop").."/intllib.lua")
|
||||||
|
|
||||||
local Stations = hyperloop.Stations
|
|
||||||
local PlayerNameTags = {}
|
local PlayerNameTags = {}
|
||||||
|
|
||||||
local function enter_display(tStation, text)
|
local function enter_display(tStation, text)
|
||||||
@ -28,7 +26,7 @@ local function enter_display(tStation, text)
|
|||||||
if tStation ~= nil then
|
if tStation ~= nil then
|
||||||
local lcd_pos = hyperloop.new_pos(tStation.pos, tStation.facedir, "1F", 2)
|
local lcd_pos = hyperloop.new_pos(tStation.pos, tStation.facedir, "1F", 2)
|
||||||
-- update display
|
-- update display
|
||||||
minetest.registered_nodes["hyperloop:lcd"].update(lcd_pos, text)
|
minetest.registered_nodes["hyperloop:lcd"].update(lcd_pos, text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -149,13 +147,13 @@ local function on_start_travel(pos, node, clicker)
|
|||||||
if tDeparture == nil or tArrival == nil then
|
if tDeparture == nil or tArrival == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.sound_play("up2", {
|
minetest.sound_play("up2", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = 0.5,
|
gain = 0.5,
|
||||||
max_hear_distance = 2
|
max_hear_distance = 2
|
||||||
})
|
})
|
||||||
|
|
||||||
-- close the door at arrival station
|
-- close the door at arrival station
|
||||||
hyperloop.close_pod_door(tArrival)
|
hyperloop.close_pod_door(tArrival)
|
||||||
-- place player on the seat
|
-- place player on the seat
|
||||||
@ -166,9 +164,9 @@ local function on_start_travel(pos, node, clicker)
|
|||||||
-- hide player name
|
-- hide player name
|
||||||
PlayerNameTags[player_name] = clicker:get_nametag_attributes()
|
PlayerNameTags[player_name] = clicker:get_nametag_attributes()
|
||||||
clicker:set_nametag_attributes({text = " "})
|
clicker:set_nametag_attributes({text = " "})
|
||||||
|
|
||||||
-- activate display
|
-- 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:").." | "..
|
local text = I("Destination:").." | "..string.sub(tArrival.name, 1, 13).." | "..I("Distance:").." | "..
|
||||||
meter_to_km(dist).." | "..I("Arrival in:").." | "
|
meter_to_km(dist).." | "..I("Arrival in:").." | "
|
||||||
local atime
|
local atime
|
||||||
@ -182,7 +180,7 @@ local function on_start_travel(pos, node, clicker)
|
|||||||
enter_display(tDeparture, text..atime.." sec")
|
enter_display(tDeparture, text..atime.." sec")
|
||||||
|
|
||||||
-- block departure and arrival stations
|
-- 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()
|
-- store some data for on_timer()
|
||||||
meta:set_int("arrival_time", atime)
|
meta:set_int("arrival_time", atime)
|
||||||
@ -207,7 +205,7 @@ minetest.register_node("hyperloop:seat", {
|
|||||||
},
|
},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = 'light',
|
paramtype = 'light',
|
||||||
light_source = 1,
|
light_source = 1,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
@ -229,8 +227,8 @@ minetest.register_node("hyperloop:seat", {
|
|||||||
|
|
||||||
on_timer = display_timer,
|
on_timer = display_timer,
|
||||||
on_rightclick = on_start_travel,
|
on_rightclick = on_start_travel,
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
|
|
||||||
auto_place_node = function(pos, facedir, sStationPos)
|
auto_place_node = function(pos, facedir, sStationPos)
|
||||||
M(pos):set_string("sStationPos", sStationPos)
|
M(pos):set_string("sStationPos", sStationPos)
|
||||||
end,
|
end,
|
||||||
|
53
station.lua
53
station.lua
@ -12,12 +12,11 @@
|
|||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
local Tube = hyperloop.Tube
|
local Tube = hyperloop.Tube
|
||||||
local Stations = hyperloop.Stations
|
local Stations = hyperloop.Stations
|
||||||
@ -38,7 +37,7 @@ local AssemblyPlan = {
|
|||||||
{ 0, "1F", 2, "hyperloop:seat"},
|
{ 0, "1F", 2, "hyperloop:seat"},
|
||||||
{ 0, "1F", 0, "hyperloop:pod_floor"},
|
{ 0, "1F", 0, "hyperloop:pod_floor"},
|
||||||
{ 1, "", 0, "hyperloop:lcd"},
|
{ 1, "", 0, "hyperloop:lcd"},
|
||||||
-- right slice
|
-- right slice
|
||||||
{-1, "1F1R", 0, "hyperloop:pod_wall_ni"},
|
{-1, "1F1R", 0, "hyperloop:pod_wall_ni"},
|
||||||
{ 1, "", 0, "hyperloop:pod_wall_ni"},
|
{ 1, "", 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"},
|
{ 0, "1F", 0, "hyperloop:pod_wall_ni"},
|
||||||
{ 1, "", 0, "hyperloop:pod_wall_ni"},
|
{ 1, "", 0, "hyperloop:pod_wall_ni"},
|
||||||
{ 0, "1B", 0, "hyperloop:pod_wall_ni"},
|
{ 0, "1B", 0, "hyperloop:pod_wall_ni"},
|
||||||
-- left slice
|
-- left slice
|
||||||
{-1, "2L2R", 0, "hyperloop:pod_wall_ni"},
|
{-1, "2L2R", 0, "hyperloop:pod_wall_ni"},
|
||||||
{ 1, "", 0, "hyperloop:pod_wall_ni"},
|
{ 1, "", 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 function store_station(pos, placer)
|
||||||
local facedir = hyperloop.get_facedir(placer)
|
local facedir = hyperloop.get_facedir(placer)
|
||||||
-- do a facedir correction
|
-- do a facedir correction
|
||||||
facedir = (facedir + 3) % 4 -- face to LCD
|
facedir = (facedir + 3) % 4 -- face to LCD
|
||||||
Stations:set(pos, "Station", {
|
Stations:set(pos, "Station", {
|
||||||
owner = placer:get_player_name(),
|
owner = placer:get_player_name(),
|
||||||
facedir = facedir,
|
facedir = facedir,
|
||||||
time_blocked = 0})
|
time_blocked = 0})
|
||||||
end
|
end
|
||||||
@ -88,7 +87,7 @@ end
|
|||||||
local function place_node(pos, facedir, node_name, sKey)
|
local function place_node(pos, facedir, node_name, sKey)
|
||||||
if node_name == "hyperloop:lcd" then
|
if node_name == "hyperloop:lcd" then
|
||||||
-- wallmounted devices need a facedir correction
|
-- 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]})
|
minetest.add_node(pos, {name=node_name, paramtype2="wallmounted", param2=tbl[facedir]})
|
||||||
else
|
else
|
||||||
minetest.add_node(pos, {name=node_name, param2=facedir})
|
minetest.add_node(pos, {name=node_name, param2=facedir})
|
||||||
@ -107,11 +106,11 @@ local function construct(idx, pos, facedir, player_name, sKey)
|
|||||||
else
|
else
|
||||||
hyperloop.chat(player_name, S("Station completed. Now place the Booking Machine!"))
|
hyperloop.chat(player_name, S("Station completed. Now place the Booking Machine!"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function check_space(pos, facedir, placer)
|
local function check_space(pos, facedir, placer)
|
||||||
for _,item in ipairs(AssemblyPlan) do
|
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)
|
pos = hyperloop.new_pos(pos, facedir, path, y)
|
||||||
if minetest.is_protected(pos, placer:get_player_name()) then
|
if minetest.is_protected(pos, placer:get_player_name()) then
|
||||||
hyperloop.chat(placer, S("Area is protected!"))
|
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!"))
|
hyperloop.chat(player, S("Not enough inventory items to build the station!"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function remove_inventory_items(inv, meta)
|
local function remove_inventory_items(inv, meta)
|
||||||
inv:remove_item("src", ItemStack("hyperloop:pod_wall 30"))
|
inv:remove_item("src", ItemStack("hyperloop:pod_wall 30"))
|
||||||
inv:remove_item("src", ItemStack("hyperloop:hypersteel_ingot 4"))
|
inv:remove_item("src", ItemStack("hyperloop:hypersteel_ingot 4"))
|
||||||
@ -189,18 +188,18 @@ local function build_station(pos, placer)
|
|||||||
-- check protection
|
-- check protection
|
||||||
if minetest.is_protected(pos, placer:get_player_name()) then
|
if minetest.is_protected(pos, placer:get_player_name()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local facedir = hyperloop.get_facedir(placer)
|
local facedir = hyperloop.get_facedir(placer)
|
||||||
-- do a facedir correction
|
-- do a facedir correction
|
||||||
facedir = (facedir + 3) % 4 -- face to LCD
|
facedir = (facedir + 3) % 4 -- face to LCD
|
||||||
if check_inventory(inv, placer) then
|
if check_inventory(inv, placer) then
|
||||||
Stations:update(pos, {facedir = facedir})
|
Stations:update(pos, {facedir = facedir})
|
||||||
|
|
||||||
if check_space(table.copy(pos), facedir, placer) then
|
if check_space(table.copy(pos), facedir, placer) then
|
||||||
construct(1, table.copy(pos), facedir, placer:get_player_name(), SP(pos))
|
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").."]")
|
"button_exit[0,3.9;3,1;destroy;"..S("Destroy Station").."]")
|
||||||
meta:set_int("built", 1)
|
meta:set_int("built", 1)
|
||||||
meta:set_int("busy", 1)
|
meta:set_int("busy", 1)
|
||||||
@ -222,21 +221,21 @@ local function destroy_station(pos, player_name)
|
|||||||
-- check protection
|
-- check protection
|
||||||
if minetest.is_protected(pos, player_name) then
|
if minetest.is_protected(pos, player_name) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local station = Stations:get(pos)
|
local station = Stations:get(pos)
|
||||||
if station then
|
if station then
|
||||||
-- remove nodes
|
-- remove nodes
|
||||||
local _pos = table.copy(pos)
|
local _pos = table.copy(pos)
|
||||||
for _,item in ipairs(AssemblyPlan) do
|
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)
|
_pos = hyperloop.new_pos(_pos, station.facedir, path, y)
|
||||||
minetest.remove_node(_pos)
|
minetest.remove_node(_pos)
|
||||||
end
|
end
|
||||||
on_destruct(pos)
|
on_destruct(pos)
|
||||||
-- maintain meta
|
-- maintain meta
|
||||||
local meta = M(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").."]")
|
"button_exit[0,3.9;3,1;build;"..S("Build Station").."]")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
add_inventory_items(inv)
|
add_inventory_items(inv)
|
||||||
@ -257,12 +256,12 @@ minetest.register_node("hyperloop:station", {
|
|||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = M(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").."]")
|
"button_exit[0,3.9;3,1;build;"..S("Build Station").."]")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size('src', 4)
|
inv:set_size('src', 4)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
hyperloop.check_network_level(pos, placer)
|
hyperloop.check_network_level(pos, placer)
|
||||||
M(pos):set_string("infotext", S("Station"))
|
M(pos):set_string("infotext", S("Station"))
|
||||||
@ -280,7 +279,7 @@ minetest.register_node("hyperloop:station", {
|
|||||||
build_station(pos, player)
|
build_station(pos, player)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_dig = function(pos, node, puncher, pointed_thing)
|
on_dig = function(pos, node, puncher, pointed_thing)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -288,13 +287,13 @@ minetest.register_node("hyperloop:station", {
|
|||||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Tube:after_dig_node(pos)
|
Tube:after_dig_node(pos)
|
||||||
Stations:delete(pos)
|
Stations:delete(pos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky = 1},
|
groups = {cracky = 1},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
@ -309,7 +308,7 @@ minetest.register_node("hyperloop:pod_wall", {
|
|||||||
"hyperloop_skin2.png",
|
"hyperloop_skin2.png",
|
||||||
"hyperloop_skin.png",
|
"hyperloop_skin.png",
|
||||||
},
|
},
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
@ -324,7 +323,7 @@ minetest.register_node("hyperloop:pod_wall_ni", {
|
|||||||
"hyperloop_skin2.png",
|
"hyperloop_skin2.png",
|
||||||
"hyperloop_skin.png",
|
"hyperloop_skin.png",
|
||||||
},
|
},
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=2, not_in_creative_inventory=1},
|
groups = {cracky=2, not_in_creative_inventory=1},
|
||||||
is_ground_content = false,
|
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},
|
{-8/16, -8/16, -8/16, 8/16, -7.5/16, 8/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=2, not_in_creative_inventory=1},
|
groups = {cracky=2, not_in_creative_inventory=1},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
36
tube.lua
36
tube.lua
@ -11,27 +11,11 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
--local M = minetest.get_meta
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
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)
|
function hyperloop.check_network_level(pos, player)
|
||||||
if hyperloop.free_tube_placement_enabled then
|
if hyperloop.free_tube_placement_enabled then
|
||||||
@ -54,9 +38,9 @@ end
|
|||||||
|
|
||||||
local Tube = tubelib2.Tube:new({
|
local Tube = tubelib2.Tube:new({
|
||||||
dirs_to_check = dirs_to_check,
|
dirs_to_check = dirs_to_check,
|
||||||
max_tube_length = 1000,
|
max_tube_length = 1000,
|
||||||
show_infotext = true,
|
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"},
|
secondary_node_names = {"hyperloop:junction", "hyperloop:station", "hyperloop:tube_wifi1"},
|
||||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||||
if num_tubes == 2 then
|
if num_tubes == 2 then
|
||||||
@ -71,7 +55,7 @@ hyperloop.Tube = Tube
|
|||||||
|
|
||||||
minetest.register_node("hyperloop:tubeS", {
|
minetest.register_node("hyperloop:tubeS", {
|
||||||
description = S("Hyperloop Tube"),
|
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"),
|
'hyperloop_tube_open.png', "hyperloop_tube_locked.png"),
|
||||||
tiles = {
|
tiles = {
|
||||||
-- up, down, right, left, back, front
|
-- up, down, right, left, back, front
|
||||||
@ -113,11 +97,11 @@ minetest.register_node("hyperloop:tubeS", {
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir", -- important!
|
paramtype2 = "facedir", -- important!
|
||||||
on_rotate = screwdriver.disallow, -- important!
|
on_rotate = screwdriver.disallow, -- important!
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -166,7 +150,7 @@ minetest.register_node("hyperloop:tubeS2", {
|
|||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir", -- important!
|
paramtype2 = "facedir", -- important!
|
||||||
on_rotate = screwdriver.disallow, -- important!
|
on_rotate = screwdriver.disallow, -- important!
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -184,7 +168,7 @@ minetest.register_node("hyperloop:tubeS2", {
|
|||||||
|
|
||||||
minetest.register_node("hyperloop:tubeA", {
|
minetest.register_node("hyperloop:tubeA", {
|
||||||
description = S("Hyperloop Tube"),
|
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"),
|
'hyperloop_tube_open.png', "hyperloop_tube_locked.png"),
|
||||||
tiles = {
|
tiles = {
|
||||||
-- up, down, right, left, back, front
|
-- up, down, right, left, back, front
|
||||||
@ -233,7 +217,7 @@ minetest.register_node("hyperloop:tubeA", {
|
|||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir", -- important!
|
paramtype2 = "facedir", -- important!
|
||||||
on_rotate = screwdriver.disallow, -- important!
|
on_rotate = screwdriver.disallow, -- important!
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -260,7 +244,7 @@ minetest.register_node("hyperloop:tubeA2", {
|
|||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir", -- important!
|
paramtype2 = "facedir", -- important!
|
||||||
on_rotate = screwdriver.disallow, -- important!
|
on_rotate = screwdriver.disallow, -- important!
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -12,12 +12,11 @@
|
|||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
--local M = minetest.get_meta
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
local Shaft = hyperloop.Shaft
|
local Shaft = hyperloop.Shaft
|
||||||
local Tube = hyperloop.Tube
|
local Tube = hyperloop.Tube
|
||||||
@ -36,11 +35,11 @@ end
|
|||||||
local function repair_tubes(itemstack, placer, pointed_thing)
|
local function repair_tubes(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
local pos = pointed_thing.under
|
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)
|
Shaft:tool_repair_tube(pos, placer, pointed_thing)
|
||||||
if fpos1 and fpos2 then
|
if fpos1 and fpos2 then
|
||||||
if cnt1 + cnt2 >= Shaft.max_tube_length 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!"))
|
"(c@#ff0000)" .. S("[Hyperloop] Error: Tube is too long!"))
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(placer:get_player_name(), chat_message(dir1, cnt1, fpos1, fdir1))
|
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,
|
max_hear_distance=5,
|
||||||
loop=false})
|
loop=false})
|
||||||
else
|
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)
|
Tube:tool_repair_tube(pos, placer, pointed_thing)
|
||||||
if fpos1 and fpos2 then
|
if fpos1 and fpos2 then
|
||||||
if cnt1 + cnt2 >= Shaft.max_tube_length 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!"))
|
"(c@#ff0000)" .. S("[Hyperloop] Error: Tube is too long!"))
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(placer:get_player_name(), chat_message(dir1, cnt1, fpos1, fdir1))
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(placer:get_player_name(),
|
minetest.chat_send_player(placer:get_player_name(),
|
||||||
S("[Crowbar Help]\n")..
|
S("[Crowbar Help]\n")..
|
||||||
S(" left: remove node\n")..
|
S(" left: remove node\n")..
|
||||||
S(" right: repair tube/shaft line\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
|
if inv and item and inv:room_for_item("main", item) then
|
||||||
inv:add_item("main", item)
|
inv:add_item("main", item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function remove_tube(itemstack, placer, pointed_thing)
|
local function remove_tube(itemstack, placer, pointed_thing)
|
||||||
if minetest.check_player_privs(placer:get_player_name(), "hyperloop") then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
local function dump_data_base(pos)
|
|
||||||
print(dump(hyperloop.tDatabase))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Tool for tube workers to crack a protected tube line
|
-- Tool for tube workers to crack a protected tube line
|
||||||
minetest.register_node("hyperloop:tube_crowbar", {
|
minetest.register_node("hyperloop:tube_crowbar", {
|
||||||
description = S("Hyperloop Tube Crowbar"),
|
description = S("Hyperloop Tube Crowbar"),
|
||||||
@ -118,8 +113,8 @@ minetest.register_node("hyperloop:tube_crowbar", {
|
|||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_privilege("hyperloop",
|
minetest.register_privilege("hyperloop",
|
||||||
{description = S("Rights to remove tube nodes by means of the crowbar"),
|
{description = S("Rights to remove tube nodes by means of the crowbar"),
|
||||||
give_to_singleplayer = false})
|
give_to_singleplayer = false})
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
local PI = 3.1415926
|
local PI = 3.1415926
|
||||||
|
|
||||||
-- for lazy programmers
|
-- 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 P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ end
|
|||||||
|
|
||||||
-- Distance between two points in (tube) blocks
|
-- Distance between two points in (tube) blocks
|
||||||
function hyperloop.distance(pos1, pos2)
|
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))
|
math.abs(pos1.y - pos2.y) + math.abs(pos1.z - pos2.z))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ function hyperloop.new_pos(pos, facedir, path, y_offs)
|
|||||||
_pos = vector.add(_pos, vector.multiply(dir, num))
|
_pos = vector.add(_pos, vector.multiply(dir, num))
|
||||||
end
|
end
|
||||||
return _pos
|
return _pos
|
||||||
end
|
end
|
||||||
|
|
||||||
function hyperloop.is_player_around(pos)
|
function hyperloop.is_player_around(pos)
|
||||||
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 2)) do
|
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 2)) do
|
||||||
|
@ -17,7 +17,6 @@ local Waypoints = {}
|
|||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
minetest.register_node("hyperloop:waypoint", {
|
minetest.register_node("hyperloop:waypoint", {
|
||||||
description = S("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},
|
{ -4/16, -8/16, -4/16, 4/16, -7/16, 4/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local name = placer:get_player_name()
|
local name = placer:get_player_name()
|
||||||
if Waypoints[name] then
|
if Waypoints[name] then
|
||||||
@ -46,7 +45,7 @@ minetest.register_node("hyperloop:waypoint", {
|
|||||||
name = "Hyperloop",
|
name = "Hyperloop",
|
||||||
text = "m",
|
text = "m",
|
||||||
world_pos = pos
|
world_pos = pos
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
@ -57,9 +56,9 @@ minetest.register_node("hyperloop:waypoint", {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = minetest.LIGHT_MAX,
|
light_source = minetest.LIGHT_MAX,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
groups = {cracky=2, crumbly=2, choppy=2},
|
groups = {cracky=2, crumbly=2, choppy=2},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
5
wifi.lua
5
wifi.lua
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local S = hyperloop.S
|
local S = hyperloop.S
|
||||||
local NS = hyperloop.NS
|
|
||||||
|
|
||||||
local Tube = hyperloop.Tube
|
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)
|
tubelib2_on_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
Tube:prepare_pairing(pos, out_dir, sFormspec)
|
Tube:prepare_pairing(pos, out_dir, sFormspec)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_receive_fields = function(pos, formname, fields, player)
|
on_receive_fields = function(pos, formname, fields, player)
|
||||||
if fields.channel ~= nil then
|
if fields.channel ~= nil then
|
||||||
Tube:pairing(pos, fields.channel)
|
Tube:pairing(pos, fields.channel)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Tube:stop_pairing(pos, oldmetadata, sFormspec)
|
Tube:stop_pairing(pos, oldmetadata, sFormspec)
|
||||||
local tube_dir = tonumber(oldmetadata.fields.tube_dir or 0)
|
local tube_dir = tonumber(oldmetadata.fields.tube_dir or 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user