revision on the way to v2 tubes/shafts
This commit is contained in:
parent
de4f3d166f
commit
f91dc4982e
@ -33,9 +33,9 @@ local function generate_string(sortedList)
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"label[3,0; "..I("Select your destination").."]"}
|
||||
tRes[2] = "label[1,0.6;"..I("Destination").."]label[5.4,0.6;"..
|
||||
I("Distance").."]label[7,0.6;"..I("Local Info").."]"
|
||||
"label[4,0; "..I("Select your destination").."]"}
|
||||
tRes[2] = "label[1,0.6;"..I("Destination").."]label[5,0.6;"..
|
||||
I("Distance").."]label[6.6,0.6;"..I("Local Info").."]"
|
||||
for idx,tDest in ipairs(sortedList) do
|
||||
if idx >= 12 then
|
||||
break
|
||||
@ -44,12 +44,12 @@ local function generate_string(sortedList)
|
||||
local ypos2 = ypos - 0.2
|
||||
local name = tDest.name or "<unknown>"
|
||||
local distance = tDest.distance or 0
|
||||
local info = tDest.info or ""
|
||||
local info = tDest.booking_info or ""
|
||||
|
||||
tRes[#tRes+1] = "button_exit[0,"..ypos2..";1,1;button;"..idx.."]"
|
||||
tRes[#tRes+1] = "label[1,"..ypos..";"..string.sub(name,1,28).."]"
|
||||
tRes[#tRes+1] = "label[5.4,"..ypos..";"..distance.." m]"
|
||||
tRes[#tRes+1] = "label[7,"..ypos..";"..info.."]"
|
||||
tRes[#tRes+1] = "label[5,"..ypos..";"..distance.." m]"
|
||||
tRes[#tRes+1] = "label[6.6,"..ypos..";"..info.."]"
|
||||
end
|
||||
return table.concat(tRes)
|
||||
end
|
||||
@ -103,13 +103,14 @@ end
|
||||
|
||||
local function booking_machine_update(pos)
|
||||
local meta = M(pos)
|
||||
print("booking_machine_update")
|
||||
local sStationPos = meta:get_string("sStationPos")
|
||||
if sStationPos ~= "" then
|
||||
local station_pos = P(sStationPos)
|
||||
local counter = meta:get_int("change_counter") or 0
|
||||
local changed, newcounter = Stations:changed(counter)
|
||||
if changed then
|
||||
print("booking_machine_update")
|
||||
print("booking_machine_update changed")
|
||||
meta:set_string("formspec", station_list_as_string(station_pos))
|
||||
meta:set_int("change_counter", newcounter)
|
||||
end
|
||||
|
47
elevator.lua
47
elevator.lua
@ -53,6 +53,7 @@ local Shaft = tubelib2.Tube:new({
|
||||
})
|
||||
|
||||
hyperloop.Shaft = Shaft
|
||||
local Elevators = hyperloop.Elevators
|
||||
|
||||
minetest.register_node("hyperloop:shaft", {
|
||||
description = I("Hyperloop Elevator Shaft"),
|
||||
@ -94,8 +95,8 @@ minetest.register_node("hyperloop:shaft", {
|
||||
end,
|
||||
|
||||
climbable = true,
|
||||
paramtype2 = "facedir", -- important!
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
paramtype = "light",
|
||||
light_source = 2,
|
||||
sunlight_propagates = true,
|
||||
@ -144,8 +145,8 @@ minetest.register_node("hyperloop:shaftA", {
|
||||
end,
|
||||
|
||||
climbable = true,
|
||||
paramtype2 = "facedir", -- important!
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
paramtype = "light",
|
||||
light_source = 2,
|
||||
sunlight_propagates = true,
|
||||
@ -186,8 +187,8 @@ minetest.register_node("hyperloop:shaft2", {
|
||||
end,
|
||||
|
||||
climbable = true,
|
||||
paramtype2 = "facedir", -- important!
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
paramtype = "light",
|
||||
light_source = 2,
|
||||
sunlight_propagates = true,
|
||||
@ -229,8 +230,8 @@ minetest.register_node("hyperloop:shaftA2", {
|
||||
end,
|
||||
|
||||
climbable = true,
|
||||
paramtype2 = "facedir", -- important!
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
paramtype = "light",
|
||||
light_source = 2,
|
||||
sunlight_propagates = true,
|
||||
@ -265,14 +266,16 @@ local function formspec(pos, lFloors)
|
||||
end
|
||||
|
||||
local function update_formspec(pos)
|
||||
local meta = M(pos)
|
||||
local counter = meta:get_int("change_counter") or 0
|
||||
local changed, newcounter = Elevators:changed(counter)
|
||||
local sKey = S(pos)
|
||||
if not Cache[sKey] or hyperloop.tDatabase.elevator_chng_cnt ~= Cache[sKey].change_counter then
|
||||
local tFloors = hyperloop.get_elevator_table(pos)
|
||||
local lFloors = hyperloop.sort_based_on_level(tFloors)
|
||||
if changed or not Cache[sKey] then
|
||||
local lFloors = Elevators:station_list(pos, pos, "level")
|
||||
Cache[sKey] = {}
|
||||
Cache[sKey].lFloors = lFloors
|
||||
Cache[sKey].formspec = formspec(pos, lFloors)
|
||||
Cache[sKey].change_counter = hyperloop.tDatabase.elevator_chng_cnt
|
||||
meta:set_int("change_counter", newcounter)
|
||||
end
|
||||
M(pos):set_string("formspec", Cache[sKey].formspec)
|
||||
end
|
||||
@ -288,7 +291,7 @@ local function update_elevator(pos, out_dir, peer_pos, peer_in_dir)
|
||||
end
|
||||
end
|
||||
print("update_elevatorB", S(pos), out_dir, S(peer_pos), peer_in_dir)
|
||||
hyperloop.update_elevator_conn_table(pos, out_dir, peer_pos)
|
||||
Elevators:update_connections(pos, out_dir, peer_pos)
|
||||
end
|
||||
|
||||
|
||||
@ -408,7 +411,7 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local facedir = hyperloop.get_facedir(placer)
|
||||
hyperloop.update_elevator(pos, "<unknown>", {facedir=facedir, busy=false})
|
||||
Elevators:set(pos, "<unknown>", {facedir=facedir, busy=false})
|
||||
|
||||
Shaft:after_place_node(pos, {5})
|
||||
|
||||
@ -417,7 +420,7 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
||||
local formspec = "size[6,4]"..
|
||||
"label[0,0;"..I("Please insert floor name").."]" ..
|
||||
"field[0.5,1.5;5,1;floor;"..I("Floor name")..";"..I("Base").."]" ..
|
||||
"button_exit[2,3.6;2,1;exit;"..I("Save").."]"
|
||||
"button_exit[2,3;2,1;exit;"..I("Save").."]"
|
||||
meta:set_string("formspec", formspec)
|
||||
|
||||
-- add upper part of the car
|
||||
@ -433,12 +436,14 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
||||
if floor == "" then
|
||||
return
|
||||
end
|
||||
hyperloop.update_elevator(pos, floor, {})
|
||||
Elevators:update(pos, {name=floor})
|
||||
update_formspec(pos)
|
||||
elseif fields.button ~= nil then -- destination selected?
|
||||
update_formspec(pos)
|
||||
local floor = hyperloop.get_elevator(pos)
|
||||
local floor = Elevators:get(pos)
|
||||
if floor then
|
||||
floor = table.copy(floor)
|
||||
floor.pos = pos
|
||||
local sKey = S(pos)
|
||||
local idx = tonumber(fields.button)
|
||||
local lFloors = Cache[sKey].lFloors
|
||||
@ -465,7 +470,7 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
||||
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
update_formspec(pos)
|
||||
local floor = hyperloop.get_elevator(pos)
|
||||
local floor = Elevators:get(pos)
|
||||
--dbg()
|
||||
if floor and floor.busy ~= true then
|
||||
door_command(pos, floor.facedir, "open", true)
|
||||
@ -476,7 +481,7 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Shaft:after_dig_node(pos, {5})
|
||||
hyperloop.delete_elevator(pos)
|
||||
Elevators:delete(pos)
|
||||
-- remove the bottom also
|
||||
pos = Shaft:get_pos(pos, 6)
|
||||
minetest.remove_node(pos)
|
||||
@ -560,9 +565,9 @@ minetest.register_node("hyperloop:elevator_door", {
|
||||
local floor_pos = P(M(pos):get_string("floor_pos"))
|
||||
if floor_pos ~= nil then
|
||||
update_formspec(floor_pos)
|
||||
local floor = hyperloop.get_elevator(floor_pos)
|
||||
local floor = Elevators:get(floor_pos)
|
||||
if floor and floor.busy ~= true then
|
||||
door_command(floor.pos, floor.facedir, "open", true)
|
||||
door_command(floor_pos, floor.facedir, "open", true)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
13
junction.lua
13
junction.lua
@ -36,20 +36,17 @@ minetest.register_node("hyperloop:junction", {
|
||||
M(pos):set_string("infotext", I("Junction"))
|
||||
Stations:set(pos, "Junction", {
|
||||
owner = placer:get_player_name(), junction = true})
|
||||
Tube:after_place_node(pos, {1,2,3,4})
|
||||
Tube:after_place_node(pos)
|
||||
end,
|
||||
|
||||
tubelib2_on_update = function(pos, out_dir, peer_pos, peer_in_dir)
|
||||
print("tubelib2_on_update", S(pos), S(peer_pos))
|
||||
if out_dir <= 4 then
|
||||
Stations:update_connections(pos, out_dir, peer_pos)
|
||||
local s = hyperloop.get_connection_string(pos)
|
||||
M(pos):set_string("infotext", I("Junction connected with ")..s)
|
||||
end
|
||||
Stations:update_connections(pos, out_dir, peer_pos)
|
||||
local s = hyperloop.get_connection_string(pos)
|
||||
M(pos):set_string("infotext", I("Junction connected with ")..s)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Tube:after_dig_node(pos, {1,2,3,4})
|
||||
Tube:after_dig_node(pos)
|
||||
Stations:delete(pos)
|
||||
end,
|
||||
|
||||
|
1
map.lua
1
map.lua
@ -117,6 +117,7 @@ minetest.register_node("hyperloop:station_map", {
|
||||
wield_image = "hyperloop_stations_book.png",
|
||||
groups = {cracky=1, book=1},
|
||||
on_use = map_on_use,
|
||||
on_place = map_on_secondary_use,
|
||||
on_secondary_use = map_on_secondary_use,
|
||||
stack_max = 1,
|
||||
})
|
||||
|
206
migrate.lua
206
migrate.lua
@ -23,47 +23,51 @@ local M = minetest.get_meta
|
||||
local Tube = hyperloop.Tube
|
||||
local Shaft = hyperloop.Shaft
|
||||
|
||||
local Elevators = hyperloop.Elevators
|
||||
local Stations = hyperloop.Stations
|
||||
|
||||
local tLegacyNodeNames = {}
|
||||
|
||||
-- convert legacy tubes to current tubes
|
||||
minetest.register_node("hyperloop:tube0", {
|
||||
description = "Hyperloop Legacy Tube",
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"hyperloop_tube_locked.png^[transformR90]",
|
||||
"hyperloop_tube_locked.png^[transformR90]",
|
||||
'hyperloop_tube_closed.png',
|
||||
'hyperloop_tube_closed.png',
|
||||
'hyperloop_tube_open.png',
|
||||
'hyperloop_tube_open.png',
|
||||
},
|
||||
for idx = 0,2 do
|
||||
minetest.register_node("hyperloop:tube"..idx, {
|
||||
description = "Hyperloop Legacy Tube",
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"hyperloop_tube_locked.png^[transformR90]",
|
||||
"hyperloop_tube_locked.png^[transformR90]",
|
||||
'hyperloop_tube_closed.png',
|
||||
'hyperloop_tube_closed.png',
|
||||
'hyperloop_tube_open.png',
|
||||
'hyperloop_tube_open.png',
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = "hyperloop:tube"
|
||||
minetest.swap_node(pos, node)
|
||||
if not Tube:after_place_tube(pos, placer, pointed_thing) then
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
node_placement_prediction = "hyperloop:tube",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = "hyperloop:tubeS"
|
||||
minetest.swap_node(pos, node)
|
||||
if not Tube:after_place_tube(pos, placer, pointed_thing) then
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
node_placement_prediction = "hyperloop:tubeS",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
end
|
||||
|
||||
local function convert_legary_nodes(self, pos, dir)
|
||||
local convert_next_tube = function(self, pos, dir)
|
||||
local npos, node = self:get_node(pos, dir)
|
||||
--print("convert_legary_nodes", S(npos), node.name)
|
||||
print("convert_legary_nodes", S(npos), node.name)
|
||||
if tLegacyNodeNames[node.name] then
|
||||
local dir1, dir2, num = self:determine_dir1_dir2_and_num_conn(npos)
|
||||
--print("convert_legary_nodes", dir1, dir2, num)
|
||||
print("convert_legary_nodes", dir1, dir2, num)
|
||||
if dir1 then
|
||||
self.clbk_after_place_tube(self:tube_data_to_table(npos, dir1,
|
||||
dir2 or tubelib2.Turn180Deg[dir1], num))
|
||||
@ -100,10 +104,27 @@ local function convert_line(self, pos, dir)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Wifi nodes
|
||||
--
|
||||
local tWifiNodes = {}
|
||||
local tWifiNodes = {} -- user for pairing
|
||||
local lWifiNodes = {} -- used for post processing
|
||||
|
||||
local function set_pairing(pos, peer_pos)
|
||||
print("set_pairing", S(pos), S(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)
|
||||
end
|
||||
|
||||
|
||||
local function wifi_post_processing()
|
||||
for _,pos in ipairs(lWifiNodes) do
|
||||
local dir = Tube:get_primary_dir(pos)
|
||||
local npos = Tube:get_pos(pos, dir)
|
||||
Tube:tool_repair_tube(npos)
|
||||
end
|
||||
end
|
||||
|
||||
-- Wifi nodes don't know their counterpart.
|
||||
-- But by means of the tube head nodes, two
|
||||
@ -120,7 +141,7 @@ local function determine_wifi_pairs(pos)
|
||||
if item[1] == pos2 and item[2] == pos1 then
|
||||
tWifiNodes[k] = nil
|
||||
-- start paring
|
||||
Tube:set_pairing(P(k), pos)
|
||||
set_pairing(P(k), pos)
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -131,10 +152,11 @@ end
|
||||
local function next_node_on_the_way_to_a_wifi_node(pos)
|
||||
local dirs = {}
|
||||
for dir = 1, 6 do
|
||||
local npos, node = Tube:get_next_node(pos, dir)
|
||||
if node.name == "hyperloop:tube" or node.name == "hyperloop:tube1" or node.name == "hyperloop:tube2" then
|
||||
local npos, node = Tube:get_node(pos, dir)
|
||||
if tLegacyNodeNames[node.name] then
|
||||
dirs[#dirs+1] = dir
|
||||
elseif node and node.name == "hyperloop:tube_wifi1" then
|
||||
elseif node.name == "hyperloop:tube_wifi1" then
|
||||
lWifiNodes[#lWifiNodes+1] = npos
|
||||
determine_wifi_pairs(npos)
|
||||
end
|
||||
end
|
||||
@ -149,7 +171,7 @@ end
|
||||
|
||||
local function search_wifi_node(pos, dir)
|
||||
local convert_next_tube = function(pos, dir)
|
||||
local npos, node = Tube:get_next_node(pos, dir)
|
||||
local npos, node = Tube:get_node(pos, dir)
|
||||
local dir1, dir2, num = next_node_on_the_way_to_a_wifi_node(npos)
|
||||
if dir1 then
|
||||
if tubelib2.Turn180Deg[dir] == dir1 then
|
||||
@ -174,34 +196,25 @@ end
|
||||
local function search_wifi_node_in_all_dirs(pos)
|
||||
-- check all positions
|
||||
for dir = 1, 6 do
|
||||
local npos, node = Tube:get_next_node(pos, dir)
|
||||
local npos, node = Tube:get_node(pos, dir)
|
||||
if node and node.name == "hyperloop:tube1" then
|
||||
search_wifi_node(pos, dir)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Stations/Junctions
|
||||
--
|
||||
|
||||
local function convert_tube_line(pos)
|
||||
-- check all positions
|
||||
for dir = 1, 6 do
|
||||
local npos, node = Tube:get_next_node(pos, dir)
|
||||
local npos, node = Tube:get_node(pos, dir)
|
||||
if node and node.name == "hyperloop:tube1" then
|
||||
local peer = Tube:convert_tube_line(pos, dir)
|
||||
convert_line(Tube, pos, dir)
|
||||
--local peer = Tube:repair_tube_line(pos, dir)
|
||||
--print("npos", FoundWifiNodes[S(npos)])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Elevator shafts
|
||||
--
|
||||
|
||||
local function convert_shaft_line(pos)
|
||||
-- check lower position
|
||||
convert_line(Shaft, pos, 5)
|
||||
@ -211,11 +224,42 @@ local function convert_shaft_line(pos)
|
||||
pos.y = pos.y - 1
|
||||
end
|
||||
|
||||
local function station_name(item)
|
||||
if item.junction == true then
|
||||
return "Junction"
|
||||
elseif item.station_name then
|
||||
return item.station_name
|
||||
else
|
||||
return "Station"
|
||||
end
|
||||
end
|
||||
|
||||
local function add_to_table(tbl, tValues)
|
||||
local res = table.copy(tbl)
|
||||
for k,v in pairs(tValues) do
|
||||
tbl[k] = v
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
local function convert_station_data(tAllStations)
|
||||
tLegacyNodeNames = {
|
||||
["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:secondary_node(item.pos) then
|
||||
hyperloop.data.tAllStations[key] = item
|
||||
Stations:set(item.pos, station_name(item), {
|
||||
owner = item.owner or "<unknown>",
|
||||
junction = item.junction,
|
||||
facedir = item.facedir,
|
||||
booking_info = item.booking_info,
|
||||
booking_pos = item.booking_pos,
|
||||
})
|
||||
end
|
||||
end
|
||||
-- First perform the Wifi node pairing
|
||||
@ -231,9 +275,13 @@ local function convert_station_data(tAllStations)
|
||||
if item.pos and Tube:secondary_node(item.pos) then
|
||||
convert_tube_line(item.pos)
|
||||
Tube:after_place_node(item.pos)
|
||||
hyperloop.update_routes(item.pos)
|
||||
--hyperloop.update_routes(item.pos)
|
||||
end
|
||||
end
|
||||
-- Repair the tube lines of wifi nodes
|
||||
wifi_post_processing()
|
||||
|
||||
Tube.primary_node_names = originNodeNames
|
||||
end
|
||||
|
||||
local function convert_elevator_data(tAllElevators)
|
||||
@ -241,21 +289,21 @@ local function convert_elevator_data(tAllElevators)
|
||||
["hyperloop:shaft"] = true,
|
||||
["hyperloop:shaft2"] = true,
|
||||
}
|
||||
hyperloop.tDatabase.tElevators = {}
|
||||
local originNodeNames = add_to_table(Shaft.primary_node_names, tLegacyNodeNames)
|
||||
|
||||
for pos,tElevator in pairs(tAllElevators) do
|
||||
for _,floor in pairs(tElevator.floors) do
|
||||
if floor.pos and Shaft:secondary_node(floor.pos) then
|
||||
local new_floor = {
|
||||
conn = {},
|
||||
name = floor.name,
|
||||
Elevators:set(floor.pos, floor.name, {
|
||||
facedir = floor.facedir,
|
||||
}
|
||||
local sKey = S(floor.pos)
|
||||
hyperloop.tDatabase.tElevators[sKey] = new_floor
|
||||
})
|
||||
convert_shaft_line(floor.pos)
|
||||
M(floor.pos):set_int("change_counter", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Shaft.primary_node_names = originNodeNames
|
||||
end
|
||||
|
||||
|
||||
@ -273,26 +321,32 @@ local function migrate()
|
||||
local data = hyperloop.file2table("mod_hyperloop.data")
|
||||
if data then
|
||||
hyperloop.convert = true
|
||||
--convert_station_data(data.tAllStations)
|
||||
convert_station_data(data.tAllStations)
|
||||
convert_elevator_data(data.tAllElevators)
|
||||
os.remove(wpath..DIR_DELIM.."mod_hyperloop.data")
|
||||
hyperloop.convert = nil
|
||||
end
|
||||
print(dump(hyperloop.tDatabase))
|
||||
end
|
||||
|
||||
minetest.after(5, migrate)
|
||||
|
||||
|
||||
|
||||
--function Tube:set_pairing(pos, peer_pos)
|
||||
|
||||
-- M(pos):set_int("tube_dir", self:get_primary_dir(pos))
|
||||
-- M(peer_pos):set_int("tube_dir", self:get_primary_dir(peer_pos))
|
||||
|
||||
-- local tube_dir1 = self:store_teleport_data(pos, peer_pos)
|
||||
-- local tube_dir2 = self:store_teleport_data(peer_pos, pos)
|
||||
|
||||
-- self:delete_tube_meta_data(pos, tube_dir1)
|
||||
-- self:delete_tube_meta_data(peer_pos, tube_dir2)
|
||||
--end
|
||||
minetest.register_lbm({
|
||||
label = "[Hyperloop] booking/seat/door migration",
|
||||
name = "hyperloop:migrate",
|
||||
nodenames = {
|
||||
"hyperloop:booking", "hyperloop:booking_ground",
|
||||
"hyperloop:doorTopPassive", "hyperloop:doorBottom",
|
||||
"hyperloop:seat",
|
||||
},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
local meta = M(pos)
|
||||
if meta:get_string("key_str") ~= "" then
|
||||
local s = meta:get_string("key_str")
|
||||
meta:set_string("sStationPos", "("..string.sub(s, 2, -2)..")")
|
||||
if node.name == "hyperloop:booking" or node.name == "hyperloop:booking_ground" then
|
||||
meta:set_int("change_counter", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -91,6 +91,7 @@ end
|
||||
local function sort_based_on_distance(tStations, pos)
|
||||
local lStations = table_to_list(table.copy(tStations))
|
||||
-- to be able to sort the list, the distance to pos has to be added
|
||||
print("sort_based_on_distance", S(pos), dump(lStations))
|
||||
lStations = add_distance_to_list(lStations, pos)
|
||||
table.sort(lStations, function(a,b) return a.distance < b.distance end)
|
||||
return lStations
|
||||
@ -173,6 +174,7 @@ function Network:delete(pos)
|
||||
end
|
||||
|
||||
function Network:changed(counter)
|
||||
print ("changed", self.change_counter, counter)
|
||||
return self.change_counter > counter, self.change_counter
|
||||
end
|
||||
|
||||
|
@ -263,12 +263,12 @@ minetest.register_node("hyperloop:station", {
|
||||
hyperloop.check_network_level(pos, placer)
|
||||
M(pos):set_string("infotext", I("Station"))
|
||||
store_station(pos, placer)
|
||||
Tube:after_place_node(pos, {1,2,3,4})
|
||||
Tube:after_place_node(pos)
|
||||
end,
|
||||
|
||||
tubelib2_on_update = function(pos, out_dir, peer_pos, peer_in_dir)
|
||||
print("tubelib2_on_update", S(pos), S(peer_pos))
|
||||
if out_dir <= 4 then
|
||||
if out_dir <= 5 then
|
||||
Stations:update_connections(pos, out_dir, peer_pos)
|
||||
local s = hyperloop.get_connection_string(pos)
|
||||
M(pos):set_string("infotext", I("Station connected with ")..s)
|
||||
@ -295,7 +295,7 @@ minetest.register_node("hyperloop:station", {
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Tube:after_dig_node(pos, {1,2,3,4})
|
||||
Tube:after_dig_node(pos)
|
||||
Stations:delete(pos)
|
||||
end,
|
||||
|
||||
|
336
station_data.lua
336
station_data.lua
@ -1,35 +1,313 @@
|
||||
{
|
||||
-- Junction
|
||||
["\"426,2,549\""] = {
|
||||
owner = "JoSto",
|
||||
pos = {y = 2,x = 426,z = 549},
|
||||
junction = true,
|
||||
routes = {
|
||||
{"(426,2,550)","(426,6,551)"},
|
||||
{"(426,2,548)","(426,2,542)"}
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 2,
|
||||
x = 426,
|
||||
z = 549
|
||||
},
|
||||
junction = true,
|
||||
routes = {
|
||||
{
|
||||
"(426,2,550)",
|
||||
"(426,6,551)"
|
||||
},
|
||||
{
|
||||
"(426,2,548)",
|
||||
"(426,2,542)"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 2,
|
||||
x = 426,
|
||||
z = 541
|
||||
},
|
||||
junction = true,
|
||||
routes = {
|
||||
{
|
||||
"(426,2,542)",
|
||||
"(426,2,548)"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 5,
|
||||
x = 500,
|
||||
z = 400
|
||||
},
|
||||
routes = {
|
||||
{
|
||||
"(501,5,400)",
|
||||
"(502,5,400)"
|
||||
},
|
||||
{
|
||||
"(499,5,400)",
|
||||
"(401,5,400)"
|
||||
},
|
||||
{
|
||||
"(500,5,401)",
|
||||
"(500,5,499)"
|
||||
},
|
||||
{
|
||||
"(500,5,399)",
|
||||
"(400,5,501)"
|
||||
}
|
||||
},
|
||||
-- Unfinished station
|
||||
["\"505,0,400\""] = {
|
||||
owner = "JoSto",
|
||||
pos = {y = 0,x = 505,z = 400},
|
||||
facedir = 2,
|
||||
routes = {
|
||||
{"(504,0,400)","(503,4,400)"}
|
||||
},
|
||||
time_blocked = 0
|
||||
junction = true
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 5,
|
||||
x = 400,
|
||||
z = 400
|
||||
},
|
||||
-- Station
|
||||
["\"432,2,545\""] = {
|
||||
owner = "JoSto",
|
||||
pos = {y = 2,x = 432,z = 545},
|
||||
facedir = 0,
|
||||
booking_info = "",
|
||||
routes = {
|
||||
{"(432,2,544)","(432,2,534)"}
|
||||
routes = {
|
||||
{
|
||||
"(401,5,400)",
|
||||
"(499,5,400)"
|
||||
},
|
||||
booking_pos = {y = 4,x = 430,z = 545},
|
||||
time_blocked = 64894,
|
||||
station_name = "x"
|
||||
{
|
||||
"(400,5,401)",
|
||||
"(400,5,499)"
|
||||
},
|
||||
{
|
||||
"(400,5,399)",
|
||||
"(400,5,398)"
|
||||
}
|
||||
},
|
||||
}
|
||||
junction = true
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 0,
|
||||
x = 505,
|
||||
z = 400
|
||||
},
|
||||
facedir = 2,
|
||||
routes = {
|
||||
{
|
||||
"(504,0,400)",
|
||||
"(503,4,400)"
|
||||
}
|
||||
},
|
||||
time_blocked = 0
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 2,
|
||||
x = 432,
|
||||
z = 545
|
||||
},
|
||||
facedir = 0,
|
||||
booking_info = "",
|
||||
routes = {
|
||||
{
|
||||
"(432,2,544)",
|
||||
"(432,2,534)"
|
||||
}
|
||||
},
|
||||
booking_pos = {
|
||||
y = 4,
|
||||
x = 430,
|
||||
z = 545
|
||||
},
|
||||
time_blocked = 64894,
|
||||
station_name = "x"
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 5,
|
||||
x = 503,
|
||||
z = 400
|
||||
},
|
||||
facedir = 1,
|
||||
station_name = "BBB",
|
||||
routes = {
|
||||
{
|
||||
"(503,4,400)",
|
||||
"(504,0,400)"
|
||||
},
|
||||
{
|
||||
"(502,5,400)",
|
||||
"(501,5,400)"
|
||||
}
|
||||
},
|
||||
booking_info = "",
|
||||
time_blocked = 64716,
|
||||
booking_pos = {
|
||||
y = 7,
|
||||
x = 503,
|
||||
z = 402
|
||||
}
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 5,
|
||||
x = 400,
|
||||
z = 500
|
||||
},
|
||||
routes = {
|
||||
{
|
||||
"(401,5,500)",
|
||||
"(499,5,500)"
|
||||
},
|
||||
{
|
||||
"(399,5,500)",
|
||||
"(398,5,500)"
|
||||
},
|
||||
{
|
||||
"(400,5,501)",
|
||||
"(500,5,399)"
|
||||
},
|
||||
{
|
||||
"(400,5,499)",
|
||||
"(400,5,401)"
|
||||
}
|
||||
},
|
||||
junction = true
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 5,
|
||||
x = 500,
|
||||
z = 503
|
||||
},
|
||||
facedir = 1,
|
||||
routes = {
|
||||
{
|
||||
"(500,5,502)",
|
||||
"(500,5,501)"
|
||||
}
|
||||
},
|
||||
time_blocked = 0
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 2,
|
||||
x = 432,
|
||||
z = 533
|
||||
},
|
||||
facedir = 2,
|
||||
booking_info = "",
|
||||
routes = {
|
||||
{
|
||||
"(432,2,534)",
|
||||
"(432,2,544)"
|
||||
}
|
||||
},
|
||||
booking_pos = {
|
||||
y = 4,
|
||||
x = 434,
|
||||
z = 533
|
||||
},
|
||||
time_blocked = 64894,
|
||||
station_name = "y"
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 5,
|
||||
x = 397,
|
||||
z = 500
|
||||
},
|
||||
facedir = 0,
|
||||
routes = {
|
||||
{
|
||||
"(398,5,500)",
|
||||
"(399,5,500)"
|
||||
},
|
||||
{
|
||||
"(396,5,500)",
|
||||
"(395,8,500)"
|
||||
}
|
||||
},
|
||||
time_blocked = 0
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 8,
|
||||
x = 394,
|
||||
z = 500
|
||||
},
|
||||
facedir = 1,
|
||||
station_name = "AAA",
|
||||
routes = {
|
||||
{
|
||||
"(395,8,500)",
|
||||
"(396,5,500)"
|
||||
}
|
||||
},
|
||||
booking_info = "",
|
||||
time_blocked = 64716,
|
||||
booking_pos = {
|
||||
y = 10,
|
||||
x = 394,
|
||||
z = 502
|
||||
}
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 5,
|
||||
x = 500,
|
||||
z = 500
|
||||
},
|
||||
routes = {
|
||||
{
|
||||
"(499,5,500)",
|
||||
"(401,5,500)"
|
||||
},
|
||||
{
|
||||
"(500,5,501)",
|
||||
"(500,5,502)"
|
||||
},
|
||||
{
|
||||
"(500,5,499)",
|
||||
"(500,5,401)"
|
||||
}
|
||||
},
|
||||
junction = true
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 5,
|
||||
x = 400,
|
||||
z = 397
|
||||
},
|
||||
facedir = 3,
|
||||
routes = {
|
||||
{
|
||||
"(400,5,398)",
|
||||
"(400,5,399)"
|
||||
}
|
||||
},
|
||||
time_blocked = 0
|
||||
}
|
||||
{
|
||||
owner = "JoSto",
|
||||
pos = {
|
||||
y = 6,
|
||||
x = 426,
|
||||
z = 552
|
||||
},
|
||||
routes = {
|
||||
{
|
||||
"(426,6,551)",
|
||||
"(426,2,550)"
|
||||
}
|
||||
},
|
||||
junction = true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user