bugfixes on the way to convert v1 to v2 tubes/shafts
This commit is contained in:
parent
42544af399
commit
51659ea508
16
booking.lua
16
booking.lua
@ -32,9 +32,6 @@ local function get_station_list(key_str)
|
|||||||
distance = hyperloop.distance(local_pos, dest_pos),
|
distance = hyperloop.distance(local_pos, dest_pos),
|
||||||
pos_str = minetest.pos_to_string(dest_pos)
|
pos_str = minetest.pos_to_string(dest_pos)
|
||||||
}
|
}
|
||||||
if #tRes >= 12 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
table.sort(tRes, function(x,y)
|
table.sort(tRes, function(x,y)
|
||||||
return x.distance < y.distance
|
return x.distance < y.distance
|
||||||
@ -79,8 +76,12 @@ end
|
|||||||
-- Form spec for the station list
|
-- Form spec for the station list
|
||||||
-- param key_str: local station key
|
-- param key_str: local station key
|
||||||
local function formspec(key_str)
|
local function formspec(key_str)
|
||||||
local tRes = {"size[12,10]label[3,0; Wähle dein Ziel :: Select your destination]"}
|
local tRes = {"size[12,10]"..
|
||||||
tRes[2] = "label[1,0.6;Destination]label[3.5,0.6;Distance]label[5,0.6;Position]label[7,0.6;Local Info]"
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
"label[3,0; Wähle dein Ziel :: Select your destination]"}
|
||||||
|
tRes[2] = "label[1,0.6;Destination]label[5.4,0.6;Distance]label[7,0.6;Local Info]"
|
||||||
for idx,tDest in ipairs(get_station_list(key_str)) do
|
for idx,tDest in ipairs(get_station_list(key_str)) do
|
||||||
if idx >= 12 then
|
if idx >= 12 then
|
||||||
break
|
break
|
||||||
@ -88,9 +89,8 @@ local function formspec(key_str)
|
|||||||
local ypos = 0.5 + idx*0.8
|
local ypos = 0.5 + idx*0.8
|
||||||
local ypos2 = ypos - 0.2
|
local ypos2 = ypos - 0.2
|
||||||
tRes[#tRes+1] = "button_exit[0,"..ypos2..";1,1;button;"..idx.."]"
|
tRes[#tRes+1] = "button_exit[0,"..ypos2..";1,1;button;"..idx.."]"
|
||||||
tRes[#tRes+1] = "label[1,"..ypos..";"..tDest.name.."]"
|
tRes[#tRes+1] = "label[1,"..ypos..";"..string.sub(tDest.name,1,28).."]"
|
||||||
tRes[#tRes+1] = "label[3.5,"..ypos..";"..tDest.distance.." m]"
|
tRes[#tRes+1] = "label[5.4,"..ypos..";"..tDest.distance.." m]"
|
||||||
tRes[#tRes+1] = "label[4.7,"..ypos..";"..tDest.pos_str.."]"
|
|
||||||
tRes[#tRes+1] = "label[7,"..ypos..";"..tDest.info.."]"
|
tRes[#tRes+1] = "label[7,"..ypos..";"..tDest.info.."]"
|
||||||
end
|
end
|
||||||
return table.concat(tRes)
|
return table.concat(tRes)
|
||||||
|
19
elevator.lua
19
elevator.lua
@ -41,13 +41,6 @@ local Shaft = tubelib2.Tube:new({
|
|||||||
else
|
else
|
||||||
minetest.set_node(pos, {name = "hyperloop:shaft", param2 = param2})
|
minetest.set_node(pos, {name = "hyperloop:shaft", param2 = param2})
|
||||||
end
|
end
|
||||||
if not hyperloop.convert then
|
|
||||||
minetest.sound_play({
|
|
||||||
name="default_place_node_metal"},{
|
|
||||||
gain=1,
|
|
||||||
max_hear_distance=5,
|
|
||||||
loop=false})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -55,7 +48,8 @@ hyperloop.Shaft = Shaft
|
|||||||
|
|
||||||
minetest.register_node("hyperloop:shaft", {
|
minetest.register_node("hyperloop:shaft", {
|
||||||
description = "Hyperloop Elevator Shaft",
|
description = "Hyperloop Elevator Shaft",
|
||||||
inventory_image = minetest.inventorycube('hyperloop_tube_open.png', "hyperloop_tube_locked.png", "hyperloop_tube_locked.png"),
|
inventory_image = minetest.inventorycube('hyperloop_tube_open.png',
|
||||||
|
"hyperloop_tube_locked.png", "hyperloop_tube_locked.png"),
|
||||||
tiles = {
|
tiles = {
|
||||||
-- up, down, right, left, back, front
|
-- up, down, right, left, back, front
|
||||||
"hyperloop_tube_locked.png^[transformR90]",
|
"hyperloop_tube_locked.png^[transformR90]",
|
||||||
@ -131,7 +125,8 @@ end
|
|||||||
local function remove_artifacts(floors)
|
local function remove_artifacts(floors)
|
||||||
local tbl = {}
|
local tbl = {}
|
||||||
for idx,floor in ipairs(floors) do
|
for idx,floor in ipairs(floors) do
|
||||||
if floor.pos ~= nil and floor.name ~= nil and floor.up ~= nil and floor.down ~= nil then
|
if floor.pos ~= nil and floor.name ~= nil
|
||||||
|
and floor.up ~= nil and floor.down ~= nil then
|
||||||
table.insert(tbl, floor)
|
table.insert(tbl, floor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -151,7 +146,8 @@ local function get_elevator_list(pos)
|
|||||||
hyperloop.data.tAllElevators[spos].floors = {}
|
hyperloop.data.tAllElevators[spos].floors = {}
|
||||||
end
|
end
|
||||||
-- remove invalid entries
|
-- remove invalid entries
|
||||||
hyperloop.data.tAllElevators[spos].floors = remove_artifacts(hyperloop.data.tAllElevators[spos].floors)
|
hyperloop.data.tAllElevators[spos].floors =
|
||||||
|
remove_artifacts(hyperloop.data.tAllElevators[spos].floors)
|
||||||
return hyperloop.data.tAllElevators[spos].floors
|
return hyperloop.data.tAllElevators[spos].floors
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -426,7 +422,8 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
|||||||
-- store floor_pos (lower car block) as meta data
|
-- store floor_pos (lower car block) as meta data
|
||||||
set_floor_pos(pos, pos)
|
set_floor_pos(pos, pos)
|
||||||
local facedir = hyperloop.get_facedir(placer)
|
local facedir = hyperloop.get_facedir(placer)
|
||||||
add_to_elevator_list(pos, {name="<unknown>", up=false, down=false, facedir=facedir, pos=pos})
|
add_to_elevator_list(pos, {name="<unknown>", up=false, down=false,
|
||||||
|
facedir=facedir, pos=pos})
|
||||||
update_elevator(pos)
|
update_elevator(pos)
|
||||||
-- formspec
|
-- formspec
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
29
map.lua
29
map.lua
@ -36,22 +36,18 @@ local function station_list_as_string(pos)
|
|||||||
lStationPositions[spos] = idx
|
lStationPositions[spos] = idx
|
||||||
end
|
end
|
||||||
|
|
||||||
local tRes = {"label[0,0;ID]label[0.7,0;Dist.]label[1.8,0;Station/Junction]label[4.2,0;Position]"..
|
local tRes = {"label[0,0;ID]label[0.7,0;Dist.]label[1.8,0;Station/Junction]label[5.4,0;Position]"..
|
||||||
"label[5.9,0;State]label[7.9,0;Owner]label[10,0;Conn. with]"}
|
"label[7.9,0;Owner]label[10,0;Conn. with]"}
|
||||||
local state, owner
|
local owner
|
||||||
for idx,dataSet in ipairs(sortedList) do
|
for idx,dataSet in ipairs(sortedList) do
|
||||||
if idx == 18 then
|
if idx == 23 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local ypos = 0.2 + idx * 0.4
|
local ypos = 0.2 + idx * 0.4
|
||||||
if dataSet.station_name ~= nil then
|
if dataSet.junction == true then
|
||||||
state = "Station"
|
|
||||||
elseif dataSet.junction == true then
|
|
||||||
dataSet.station_name = "Junction"
|
dataSet.station_name = "Junction"
|
||||||
state = "Junction"
|
elseif dataSet.station_name == nil then
|
||||||
else
|
|
||||||
dataSet.station_name = "<no name>"
|
dataSet.station_name = "<no name>"
|
||||||
state = "unfinished"
|
|
||||||
end
|
end
|
||||||
if dataSet.owner ~= nil then
|
if dataSet.owner ~= nil then
|
||||||
owner = dataSet.owner
|
owner = dataSet.owner
|
||||||
@ -60,10 +56,9 @@ local function station_list_as_string(pos)
|
|||||||
end
|
end
|
||||||
tRes[#tRes+1] = "label[0,"..ypos..";"..idx.."]"
|
tRes[#tRes+1] = "label[0,"..ypos..";"..idx.."]"
|
||||||
tRes[#tRes+1] = "label[0.7,"..ypos..";"..dataSet.distance.." m]"
|
tRes[#tRes+1] = "label[0.7,"..ypos..";"..dataSet.distance.." m]"
|
||||||
tRes[#tRes+1] = "label[1.8,"..ypos..";"..dataSet.station_name.."]"
|
tRes[#tRes+1] = "label[1.8,"..ypos..";"..string.sub(dataSet.station_name,1,24).."]"
|
||||||
tRes[#tRes+1] = "label[4.2,"..ypos..";"..minetest.pos_to_string(dataSet.pos).."]"
|
tRes[#tRes+1] = "label[5.4,"..ypos..";"..minetest.pos_to_string(dataSet.pos).."]"
|
||||||
tRes[#tRes+1] = "label[5.9,"..ypos..";"..state.."]"
|
tRes[#tRes+1] = "label[7.9,"..ypos..";"..string.sub(owner,1,14).."]"
|
||||||
tRes[#tRes+1] = "label[7.9,"..ypos..";"..owner.."]"
|
|
||||||
tRes[#tRes+1] = "label[10,"..ypos..";"
|
tRes[#tRes+1] = "label[10,"..ypos..";"
|
||||||
--print(idx, #dataSet.routes)
|
--print(idx, #dataSet.routes)
|
||||||
for _,route in ipairs(dataSet.routes) do
|
for _,route in ipairs(dataSet.routes) do
|
||||||
@ -86,8 +81,10 @@ 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]" .. default.gui_bg ..
|
local formspec = "size[12,10]" ..
|
||||||
default.gui_bg_img ..
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
sStationList ..
|
sStationList ..
|
||||||
"button_exit[5,9.5;2,1;close;Close]"
|
"button_exit[5,9.5;2,1;close;Close]"
|
||||||
|
|
||||||
|
56
migrate.lua
56
migrate.lua
@ -141,24 +141,6 @@ end
|
|||||||
-- Stations/Junctions
|
-- Stations/Junctions
|
||||||
--
|
--
|
||||||
|
|
||||||
Tube:on_convert_tube(function(pos, name, param2)
|
|
||||||
local dirs = {}
|
|
||||||
for dir = 1, 6 do
|
|
||||||
--local npos = Tube:primary_node(pos, dir)
|
|
||||||
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
|
|
||||||
dirs[#dirs+1] = dir
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if #dirs == 1 then
|
|
||||||
return dirs[1], nil, 1
|
|
||||||
elseif #dirs == 2 then
|
|
||||||
return dirs[1], dirs[2], 2
|
|
||||||
else
|
|
||||||
print("on_convert_tube", dump(dirs))
|
|
||||||
end
|
|
||||||
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
|
||||||
@ -174,16 +156,6 @@ end
|
|||||||
--
|
--
|
||||||
-- Elevator shafts
|
-- Elevator shafts
|
||||||
--
|
--
|
||||||
Shaft:on_convert_tube(function(pos, name, param2)
|
|
||||||
if param2 < 30 then
|
|
||||||
print("param2", param2)
|
|
||||||
if name == "hyperloop:shaft2" then
|
|
||||||
return 5, 6, 2
|
|
||||||
elseif name == "hyperloop:shaft" then
|
|
||||||
return 5, 6, 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
local function convert_shaft_line(pos)
|
local function convert_shaft_line(pos)
|
||||||
-- check lower position
|
-- check lower position
|
||||||
@ -224,14 +196,21 @@ local function convert_station_data(tAllStations)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function convert_elevator_data(tAllElevators)
|
local function convert_elevator_data(tAllElevators)
|
||||||
for key,item in pairs(tAllElevators) do
|
hyperloop.data.tAllElevators = {}
|
||||||
if item.pos and Shaft:secondary_node(item.pos) then
|
for pos,item in pairs(tAllElevators) do
|
||||||
hyperloop.data.tAllElevators[key] = item
|
local tbl = {}
|
||||||
|
for _,floor in ipairs(item.floors) do
|
||||||
|
if floor.pos and Shaft:secondary_node(floor.pos) then
|
||||||
|
tbl[#tbl+1] = floor
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
hyperloop.data.tAllElevators[pos] = {floors = tbl}
|
||||||
end
|
end
|
||||||
for key,item in pairs(tAllElevators) do
|
for pos,item in pairs(tAllElevators) do
|
||||||
if item.pos and Shaft:secondary_node(item.pos) then
|
for _,floor in ipairs(item.floors) do
|
||||||
convert_shaft_line(item.pos)
|
if floor.pos and Shaft:secondary_node(floor.pos) then
|
||||||
|
convert_shaft_line(floor.pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -247,17 +226,16 @@ function hyperloop.file2table(filename)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function migrate()
|
local function migrate()
|
||||||
|
Shaft:add_legacy_node_names({"hyperloop:shaft", "hyperloop:shaft2"})
|
||||||
|
Tube:add_legacy_node_names({"hyperloop:tube", "hyperloop:tube1", "hyperloop:tube2"})
|
||||||
local data = hyperloop.file2table("mod_hyperloop.data")
|
local data = hyperloop.file2table("mod_hyperloop.data")
|
||||||
if data then
|
if data then
|
||||||
hyperloop.convert = true
|
hyperloop.convert = true
|
||||||
convert_station_data(data.tAllStations)
|
convert_station_data(data.tAllStations)
|
||||||
convert_elevator_data(data.tAllElevators)
|
convert_elevator_data(data.tAllElevators)
|
||||||
minetest.safe_file_write(wpath..DIR_DELIM.."mod_hyperloop.data", "")
|
os.remove(wpath..DIR_DELIM.."mod_hyperloop.data")
|
||||||
hyperloop.convert = nil
|
hyperloop.convert = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
print("NodesWithPeerMeta", dump(NodesWithPeerMeta))
|
|
||||||
print("tWifiNodes", dump(tWifiNodes))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(10, migrate)
|
minetest.after(5, migrate)
|
2
seat.lua
2
seat.lua
@ -145,7 +145,7 @@ local function on_start_travel(pos, node, clicker)
|
|||||||
-- 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
|
||||||
pos.y = pos.y + 0.5
|
pos.y = pos.y - 0.5
|
||||||
clicker:set_pos(pos)
|
clicker:set_pos(pos)
|
||||||
-- rotate player to look in move direction
|
-- rotate player to look in move direction
|
||||||
clicker:set_look_horizontal(hyperloop.facedir_to_rad(tDeparture.facedir))
|
clicker:set_look_horizontal(hyperloop.facedir_to_rad(tDeparture.facedir))
|
||||||
|
11
tube.lua
11
tube.lua
@ -61,7 +61,7 @@ end
|
|||||||
|
|
||||||
local Tube = tubelib2.Tube:new({
|
local Tube = tubelib2.Tube:new({
|
||||||
allowed_6d_dirs = allowed_6d_dirs,
|
allowed_6d_dirs = allowed_6d_dirs,
|
||||||
max_tube_length = 1000,
|
max_tube_length = 10000,
|
||||||
show_infotext = true,
|
show_infotext = true,
|
||||||
primary_node_names = {"hyperloop:tube", "hyperloop:tube2"},
|
primary_node_names = {"hyperloop:tube", "hyperloop:tube2"},
|
||||||
secondary_node_names = {"hyperloop:junction", "hyperloop:station"},
|
secondary_node_names = {"hyperloop:junction", "hyperloop:station"},
|
||||||
@ -71,13 +71,6 @@ local Tube = tubelib2.Tube:new({
|
|||||||
else
|
else
|
||||||
minetest.set_node(pos, {name = "hyperloop:tube", param2 = param2})
|
minetest.set_node(pos, {name = "hyperloop:tube", param2 = param2})
|
||||||
end
|
end
|
||||||
if not hyperloop.convert then
|
|
||||||
minetest.sound_play({
|
|
||||||
name="default_place_node_metal"},{
|
|
||||||
gain=1,
|
|
||||||
max_hear_distance=5,
|
|
||||||
loop=false})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -167,7 +160,7 @@ function hyperloop.update_routes(pos, called_from_peer, player_name)
|
|||||||
if player_name then
|
if player_name then
|
||||||
minetest.chat_send_player(player_name, "[Hyperloop] "..S(pos))
|
minetest.chat_send_player(player_name, "[Hyperloop] "..S(pos))
|
||||||
end
|
end
|
||||||
for dir = 1,4 do -- check all 4 directions
|
for dir = 1,6 do -- check all 6 directions
|
||||||
local npos = Tube:get_connected_node_pos(pos, dir)
|
local npos = Tube:get_connected_node_pos(pos, dir)
|
||||||
if Tube:secondary_node(npos) then
|
if Tube:secondary_node(npos) then
|
||||||
table.insert(tRoutes, {S(pos), S(npos)})
|
table.insert(tRoutes, {S(pos), S(npos)})
|
||||||
|
@ -63,6 +63,11 @@ local function remove_tube(itemstack, placer, pointed_thing)
|
|||||||
else
|
else
|
||||||
Tube:tool_remove_tube(pos, "default_break_metal")
|
Tube:tool_remove_tube(pos, "default_break_metal")
|
||||||
Shaft:tool_remove_tube(pos, "default_break_metal")
|
Shaft:tool_remove_tube(pos, "default_break_metal")
|
||||||
|
minetest.sound_play({
|
||||||
|
name="default_place_node_metal"},{
|
||||||
|
gain=1,
|
||||||
|
max_hear_distance=5,
|
||||||
|
loop=false})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
tube_crowbar_help(placer)
|
tube_crowbar_help(placer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user