bugfixes
This commit is contained in:
parent
dd2b3383c5
commit
dd81b1589e
20
README.md
20
README.md
@ -4,12 +4,13 @@
|
||||
|
||||
## Minetest goes Hyperloop!
|
||||
|
||||
* It allows travelling from point point in seconds (900 km/h) :-)
|
||||
The fast and modern way of traveling.
|
||||
* Hyperloop allows travelling from point point in seconds (900 km/h) :-)
|
||||
* Hyperloop tubes can be build in teamwork together with other players
|
||||
* It can be used even on small servers (Raspberry PI) without lagging
|
||||
* No configuration or programming of the tube network is necessary (only the station names have to be entered)
|
||||
|
||||
The mod includes many different blocks for the tubes, the junctions, the stations, the pod, the ticket/booking machine and the map tool. It also includes a WiFi tube block for very large distances (admin feature).
|
||||
The mod includes many different blocks for tubes, junctions, stations, elevators, ticket/booking machine, map tool, station builder, tube robot, and some signs and decoration blocks. It also includes WiFi tube blocks for very large distances (admin feature).
|
||||
|
||||
|
||||
Browse on: 
|
||||
@ -19,12 +20,23 @@ Download: 
|
||||
Hyperloop is passenger transportation system for travelling through evacuated tubes my means of passenger pods.
|
||||
The tubes system with all stations and pods have to be build by the players.
|
||||
|
||||
The pods can reach a maximum speed of up to 900 km/h. This requires a tube system on one level. That means all stations from one network have to be on the same level. Therefore, Hyperloop provides an elevator system to reach the station in the underground or in the air, depending on the tube level.
|
||||
|
||||
To build a first route with 2 station, craft and place two Hyperloop Station Blocks, add items to the Station Block to build the Station Pod, place a Booking Machines nearby both stations, and connect the stations by means of Hyperloop Tube blocks. You can use the Hyperloop Tube Robot to simplify the job.
|
||||
|
||||
|
||||
**Some additional facts:**
|
||||
|
||||
The tube route is automatically protected. You can dig only the ends of a tube line (head blocks). The junction block / station has to be protected manually.
|
||||
|
||||
Junction and Station Blocks can connect up to four tube lines. That means you can build complex networks of tube lines. Each junction/station can be reaches from each point with one trip.
|
||||
|
||||
|
||||
## Still To Do
|
||||
|
||||
* configuration settings
|
||||
* Admin tool to interrupt tube routes
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Hyperloop Mod for faster traveling.
|
||||
Hyperloop Mod, the fast and modern way of traveling.
|
1
door.lua
1
door.lua
@ -17,7 +17,6 @@
|
||||
local function door_on_punch(pos, node, puncher, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local key_str = meta:get_string("key_str")
|
||||
print("punch "..key_str)
|
||||
if hyperloop.data.tAllStations[key_str] ~= nil then
|
||||
local station_name = hyperloop.data.tAllStations[key_str].station_name
|
||||
if station_name == nil then
|
||||
|
41
elevator.lua
41
elevator.lua
@ -67,7 +67,6 @@ end
|
||||
local function remove_elevator_list(pos)
|
||||
local spos = tostring(pos.x)..":"..tostring(pos.z)
|
||||
hyperloop.data.tAllElevators[spos] = nil
|
||||
--print(spos, dump(hyperloop.data.tAllElevators))
|
||||
end
|
||||
|
||||
-- determine the elevator floor item or create one
|
||||
@ -84,7 +83,6 @@ end
|
||||
|
||||
-- Add the given arguments to the elevator table
|
||||
local function add_to_elevator_list(pos, tArgs)
|
||||
--print("add_to_elevator_list", dump(pos))
|
||||
local floor = get_floor_item(pos)
|
||||
for k,v in pairs(tArgs) do
|
||||
floor[k] = v
|
||||
@ -110,7 +108,6 @@ local function floor_list(pos)
|
||||
end)
|
||||
-- check if elevator is complete
|
||||
for idx,floor in ipairs(floors) do
|
||||
--print(idx, #floors, floor.name, floor.up, floor.down)
|
||||
if idx == 1 then
|
||||
if floor.down == false then
|
||||
return {}
|
||||
@ -182,7 +179,6 @@ local function remove_from_elevator_list(pos)
|
||||
else
|
||||
-- update all other elevator cars
|
||||
for _,floor in ipairs(get_elevator_list(pos)) do
|
||||
print(_, floor.name)
|
||||
if floor.name ~= "<unknown>" then
|
||||
update_formspec(floor.pos)
|
||||
end
|
||||
@ -193,7 +189,6 @@ end
|
||||
function hyperloop.update_elevator(pos)
|
||||
local up = false
|
||||
local down = false
|
||||
--print("update y=", pos.y)
|
||||
|
||||
pos.y = pos.y - 1
|
||||
if string.find(minetest.get_node_or_nil(pos).name, "hyperloop:shaft") then
|
||||
@ -207,11 +202,9 @@ function hyperloop.update_elevator(pos)
|
||||
|
||||
pos.y = pos.y - 2
|
||||
add_to_elevator_list(pos, {up=up, down=down})
|
||||
--dbg_out("update", pos)
|
||||
|
||||
-- update all elevator cars which are already named
|
||||
for _,floor in ipairs(get_elevator_list(pos)) do
|
||||
print(_, floor.name)
|
||||
if floor.name ~= "<unknown>" then
|
||||
update_formspec(floor.pos)
|
||||
end
|
||||
@ -345,7 +338,6 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
||||
-- store floor_pos (lower car block) as meta data
|
||||
set_floor_pos(pos, floor_pos)
|
||||
pos.y = pos.y - 1
|
||||
--dbg_out("after_place_node", pos)
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, formname, fields, player)
|
||||
@ -359,7 +351,6 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
||||
local floor_pos = get_floor_pos(pos)
|
||||
add_to_elevator_list(floor_pos, {name=floor})
|
||||
hyperloop.update_elevator(floor_pos)
|
||||
--dbg_out("on_receive_fields", floor_pos)
|
||||
-- destination selected?
|
||||
elseif fields.button ~= nil then
|
||||
local floor_pos = get_floor_pos(pos)
|
||||
@ -389,12 +380,9 @@ minetest.register_node("hyperloop:elevator_bottom", {
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
pos.y = pos.y + 2
|
||||
--print("pos.y="..pos.y)
|
||||
minetest.remove_node(pos)
|
||||
pos.y = pos.y - 1
|
||||
remove_from_elevator_list(pos)
|
||||
--local facedir = minetest.get_meta(pos):get_int("facedir")
|
||||
--door_command(pos, facedir, "open")
|
||||
end,
|
||||
|
||||
})
|
||||
@ -470,7 +458,6 @@ minetest.register_node("hyperloop:elevator_door", {
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
local floor_pos = get_floor_pos(pos)
|
||||
local floor = get_floor_item(floor_pos)
|
||||
print(dump(floor.pos), floor.facedir)
|
||||
door_command(floor.pos, floor.facedir, "open")
|
||||
end,
|
||||
|
||||
@ -480,31 +467,3 @@ minetest.register_node("hyperloop:elevator_door", {
|
||||
groups = {snappy = 3, not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
-------------------------------------------------------
|
||||
--[[
|
||||
local pos = {x=1, y=2, z=3}
|
||||
local spos = tostring(pos.x)..":"..tostring(pos.z)
|
||||
hyperloop.data.tAllElevators[spos].floors = nil
|
||||
|
||||
local floor = get_floor_item(pos)
|
||||
dbg_out("1", pos)
|
||||
add_to_elevator_list(pos, {name="test1", up=false, down=false, facedir=1, pos=pos})
|
||||
dbg_out("2", pos)
|
||||
remove_from_elevator_list(pos)
|
||||
dbg_out("3", pos)
|
||||
add_to_elevator_list(pos, {name="test1", up=false, down=false, facedir=1, pos=pos})
|
||||
dbg_out("4", pos)
|
||||
add_to_elevator_list(pos, {up=true})
|
||||
dbg_out("5", pos)
|
||||
print("6: ", dump(floor_list(pos)))
|
||||
|
||||
local pos2 = {x=1, y=5, z=3}
|
||||
add_to_elevator_list(pos2, {name="test2", up=true, down=true, facedir=1, pos=pos2})
|
||||
dbg_out("7", pos2)
|
||||
print("8: ", dump(floor_list(pos2)))
|
||||
|
||||
local pos3 = {x=1, y=9, z=3}
|
||||
add_to_elevator_list(pos3, {name="test3", up=false, down=true, facedir=1, pos=pos3})
|
||||
dbg_out("9", pos3)
|
||||
print("10: ", dump(floor_list(pos3)))
|
||||
]]--
|
||||
|
4
init.lua
4
init.lua
@ -18,6 +18,7 @@
|
||||
2017-07-16 v0.05 Doors can be opened manually
|
||||
2017-07-24 v0.06 Tubes with limited slope, elevator and deco blocks added
|
||||
2017-07-28 v0.07 Slope removed, Station auto-builder added
|
||||
2017-07-29 v0.08 Signs added, tube robot added
|
||||
|
||||
]]--
|
||||
|
||||
@ -32,12 +33,11 @@ hyperloop = {
|
||||
}
|
||||
}
|
||||
|
||||
hyperloop.debugging = true
|
||||
hyperloop.debugging = false
|
||||
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/utils.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/tube.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/booking.lua")
|
||||
--dofile(minetest.get_modpath("hyperloop") .. "/junction.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/station.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/map.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/door.lua")
|
||||
|
33
map.lua
33
map.lua
@ -30,8 +30,8 @@ local function station_list_as_string(pos)
|
||||
print("tAllStations="..dump(sortedList))
|
||||
print("tWifi="..dump(hyperloop.data.tWifi))
|
||||
end
|
||||
--local tRes = {"(player distance: station name (position) seat/machine/owner => directly connected with)\n\n"}
|
||||
local tRes = {"size[12,10]label[0,0;Dist.]label[0.9,0;Station]label[2.5,0;Position]label[4.2,0;State]label[5.6,0;Owner]label[7.1,0;Connected with]"}
|
||||
local tRes = {"label[0,0;Dist.]label[0.9,0;Station/Junction]label[2.7,0;Position]"..
|
||||
"label[4.7,0;State]label[6.2,0;Owner]label[7.8,0;Directly connected with]"}
|
||||
local state, owner
|
||||
for idx,dataSet in ipairs(sortedList) do
|
||||
if idx == 18 then
|
||||
@ -39,10 +39,13 @@ local function station_list_as_string(pos)
|
||||
end
|
||||
local ypos = 0.2 + idx * 0.4
|
||||
if dataSet.station_name ~= nil then
|
||||
state = "completed"
|
||||
state = "Station"
|
||||
elseif dataSet.junction == true then
|
||||
dataSet.station_name = "<no name>"
|
||||
state = "Junction"
|
||||
else
|
||||
dataSet.station_name = ""
|
||||
state = "no Booking M."
|
||||
dataSet.station_name = "<no name>"
|
||||
state = "No Booking M."
|
||||
end
|
||||
if dataSet.owner ~= nil then
|
||||
owner = dataSet.owner
|
||||
@ -51,12 +54,16 @@ local function station_list_as_string(pos)
|
||||
end
|
||||
tRes[#tRes+1] = "label[0,"..ypos..";"..dataSet.distance.." m]"
|
||||
tRes[#tRes+1] = "label[0.9,"..ypos..";"..dataSet.station_name.."]"
|
||||
tRes[#tRes+1] = "label[2.5,"..ypos..";"..minetest.pos_to_string(dataSet.pos).."]"
|
||||
tRes[#tRes+1] = "label[4.2,"..ypos..";"..state.."]"
|
||||
tRes[#tRes+1] = "label[5.6,"..ypos..";"..owner.."]"
|
||||
tRes[#tRes+1] = "label[7.1,"..ypos..";"
|
||||
for _,s in ipairs(hyperloop.get_connections(dataSet.key_str)) do
|
||||
tRes[#tRes + 1] = s
|
||||
tRes[#tRes+1] = "label[2.7,"..ypos..";"..minetest.pos_to_string(dataSet.pos).."]"
|
||||
tRes[#tRes+1] = "label[4.7,"..ypos..";"..state.."]"
|
||||
tRes[#tRes+1] = "label[6.2,"..ypos..";"..owner.."]"
|
||||
tRes[#tRes+1] = "label[7.8,"..ypos..";"
|
||||
for _,key_str in ipairs(hyperloop.get_connections(dataSet.key_str)) do
|
||||
if hyperloop.data.tAllStations[key_str].station_name ~= nil then
|
||||
tRes[#tRes + 1] = hyperloop.data.tAllStations[key_str].station_name
|
||||
else
|
||||
tRes[#tRes + 1] = key_str
|
||||
end
|
||||
tRes[#tRes + 1] = ", "
|
||||
end
|
||||
tRes[#tRes] = "]"
|
||||
@ -70,11 +77,11 @@ local function map_on_use(itemstack, user)
|
||||
--local pos = user:get_pos()
|
||||
local pos = user:getpos()
|
||||
local sStationList = station_list_as_string(pos)
|
||||
local formspec = "size[10,8]" .. default.gui_bg ..
|
||||
local formspec = "size[12,10]" .. default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
"textarea[0.5,0.5;9.5,8;text;Station List:;" ..
|
||||
sStationList .. "]" ..
|
||||
"button_exit[4,7.5;2,1;close;Close]"
|
||||
"button_exit[5,9.5;2,1;close;Close]"
|
||||
|
||||
minetest.show_formspec(player_name, "hyperloop:station_map", formspec)
|
||||
return itemstack
|
||||
|
34
robot.lua
34
robot.lua
@ -44,7 +44,9 @@ local function place_tube(pos, name, facedir, placer)
|
||||
if minetest.is_protected(pos, placer:get_player_name()) then
|
||||
hyperloop.chat(placer, "Area is protected!")
|
||||
return false
|
||||
elseif minetest.get_node_or_nil(pos).name ~= "air" and minetest.get_node_or_nil(pos).name ~= "default:water_source" then
|
||||
elseif minetest.get_node_or_nil(pos).name ~= "air" and
|
||||
minetest.get_node_or_nil(pos).name ~= "default:water_source" and
|
||||
minetest.get_node_or_nil(pos).name ~= "default:water_flowing" then
|
||||
return false
|
||||
end
|
||||
if hyperloop.scan_neighbours(pos) ~= 1 then
|
||||
@ -56,27 +58,26 @@ local function place_tube(pos, name, facedir, placer)
|
||||
end
|
||||
|
||||
local function move_robot(pos, inv, facedir, placer)
|
||||
print("move_robot")
|
||||
if minetest.get_meta(pos):get_int("stopped") ~= 1 then
|
||||
if get_inventory_item(inv) then
|
||||
print("get_inventory_item")
|
||||
-- remve robot and replace through tube
|
||||
local stack = get_inventory(pos)
|
||||
minetest.dig_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
place_tube(pos, "hyperloop:tube1", facedir, placer)
|
||||
-- place robot on the new position
|
||||
pos = hyperloop.new_pos(pos, facedir, "1F", 0)
|
||||
if place_tube(pos, "hyperloop:robot", facedir, placer) then
|
||||
inv = set_inventory(pos, stack)
|
||||
print("set_inventory")
|
||||
minetest.after(1, move_robot, pos, inv, facedir, placer)
|
||||
else
|
||||
pos = hyperloop.new_pos(pos, facedir, "1B", 0)
|
||||
minetest.dig_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
place_tube(pos, "hyperloop:robot", facedir, placer)
|
||||
stack:add_item("src", ItemStack("hyperloop:tube0"))
|
||||
set_inventory(pos, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local station_formspec =
|
||||
@ -93,12 +94,12 @@ minetest.register_node("hyperloop:robot", {
|
||||
description = "Hyperloop Tube Robot",
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"hyperloop_robot.png^[transformR90]",
|
||||
"hyperloop_robot.png^[transformR90]",
|
||||
"hyperloop_robot.png",
|
||||
"hyperloop_robot.png",
|
||||
"hyperloop_robot.png",
|
||||
"hyperloop_robot.png",
|
||||
"hyperloop_robot2.png",
|
||||
"hyperloop_robot2.png",
|
||||
"hyperloop_robot2.png",
|
||||
"hyperloop_robot2.png",
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
@ -126,12 +127,25 @@ minetest.register_node("hyperloop:robot", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local facedir = meta:get_int("facedir")
|
||||
meta:set_int("stopped", 0)
|
||||
minetest.after(1, move_robot, pos, inv, facedir, player)
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
if minetest.is_protected(pos, puncher:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("stopped", 1)
|
||||
end,
|
||||
|
||||
on_dig = function(pos, node, puncher, pointed_thing)
|
||||
if minetest.is_protected(pos, puncher:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
meta:set_int("stopped", 1)
|
||||
if inv:is_empty("src") then
|
||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||
end
|
||||
|
13
seat.lua
13
seat.lua
@ -11,10 +11,6 @@
|
||||
]]--
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
local function enter_display(tStation, text)
|
||||
-- determine position
|
||||
local lcd_pos = hyperloop.new_pos(tStation.pos, tStation.facedir, "1F", 2)
|
||||
@ -46,7 +42,6 @@ local function on_open_door(tArrival)
|
||||
minetest.after(5.0, on_final_close_door, tArrival, tArrival.facedir)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
local function on_arrival(tDeparture, tArrival, player, snd)
|
||||
-- activate display
|
||||
local text = " | Welcome at | | "..string.sub(tArrival.station_name, 1, 13)
|
||||
@ -75,7 +70,6 @@ local function on_arrival(tDeparture, tArrival, player, snd)
|
||||
minetest.after(6.0, on_open_door, tArrival)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
local function on_travel(tDeparture, tArrival, player, atime)
|
||||
-- play sound and switch door state
|
||||
local snd = minetest.sound_play("normal2", {
|
||||
@ -89,7 +83,6 @@ local function on_travel(tDeparture, tArrival, player, atime)
|
||||
minetest.after(atime, on_final_close_door, tDeparture)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
local function display_timer(pos, elapsed)
|
||||
-- update display with trip data
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -119,14 +112,12 @@ local function meter_to_km(dist)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- place the player, close the door, activate display
|
||||
local function on_start_travel(pos, node, clicker)
|
||||
-- departure data
|
||||
local meta = minetest.get_meta(pos)
|
||||
local key_str = meta:get_string("key_str")
|
||||
local tDeparture = hyperloop.get_station_data(key_str)
|
||||
print("tDeparture: "..dump(tDeparture))
|
||||
-- arrival data
|
||||
key_str = hyperloop.data.booking[tDeparture.key_str]
|
||||
if key_str == nil then
|
||||
@ -134,7 +125,6 @@ local function on_start_travel(pos, node, clicker)
|
||||
return
|
||||
end
|
||||
local tArrival = hyperloop.get_station_data(key_str)
|
||||
print("tArrival: "..dump(tArrival))
|
||||
-- delete booking
|
||||
hyperloop.data.booking[tDeparture.key_str] = nil
|
||||
if tArrival == nil then
|
||||
@ -180,9 +170,6 @@ local function on_start_travel(pos, node, clicker)
|
||||
minetest.after(4.9, on_travel, tDeparture, tArrival, clicker, atime)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- Hyperloop Seat
|
||||
minetest.register_node("hyperloop:seat", {
|
||||
description = "Hyperloop Pod Seat",
|
||||
|
28
station.lua
28
station.lua
@ -56,12 +56,6 @@
|
||||
- booking_pos = nil
|
||||
- booking_info = nil
|
||||
|
||||
Once a day:
|
||||
for key,item in tAllStations
|
||||
if node(item(pos)) ~= station
|
||||
del item
|
||||
|
||||
|
||||
]]--
|
||||
|
||||
-- Station Pod Assembly Plan
|
||||
@ -143,7 +137,6 @@ function hyperloop.get_station_data(key_str)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- used for station and junction blocks
|
||||
local function store_station(pos, placer)
|
||||
local key_str = hyperloop.get_key_str(pos)
|
||||
local facedir = hyperloop.get_facedir(placer)
|
||||
@ -159,6 +152,17 @@ local function store_station(pos, placer)
|
||||
}
|
||||
end
|
||||
|
||||
local function store_junction(pos, placer)
|
||||
local key_str = hyperloop.get_key_str(pos)
|
||||
hyperloop.data.tAllStations[key_str] = {
|
||||
version=2, -- for version checks
|
||||
pos=pos, -- station/junction block
|
||||
routes={}, -- will be calculated later
|
||||
owner=placer:get_player_name(),
|
||||
junction=true,
|
||||
}
|
||||
end
|
||||
|
||||
-- used for station and junction blocks
|
||||
local function delete_station(pos)
|
||||
local key_str = hyperloop.get_key_str(pos)
|
||||
@ -361,14 +365,6 @@ minetest.register_node("hyperloop:station", {
|
||||
hyperloop.data.change_counter = hyperloop.data.change_counter + 1
|
||||
end,
|
||||
|
||||
-- on_punch = function(pos, node, puncher, pointed_thing)
|
||||
-- local meta = minetest.get_meta(pos)
|
||||
-- local inv = meta:get_inventory()
|
||||
-- if inv:is_empty("src") and meta:get_int("built") ~= 1 then
|
||||
-- minetest.node_punch(pos, node, puncher, pointed_thing)
|
||||
-- end
|
||||
-- end,
|
||||
|
||||
on_dig = function(pos, node, puncher, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
@ -416,7 +412,7 @@ minetest.register_node("hyperloop:junction", {
|
||||
hyperloop.check_network_level(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Position "..hyperloop.get_key_str(pos))
|
||||
store_station(pos, placer)
|
||||
store_junction(pos, placer)
|
||||
store_routes(pos)
|
||||
hyperloop.data.change_counter = hyperloop.data.change_counter + 1
|
||||
end,
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.8 KiB |
11
tube.lua
11
tube.lua
@ -76,7 +76,7 @@ end
|
||||
|
||||
-- Degrade one node.
|
||||
-- Needed when a new node is placed nearby.
|
||||
function hyperloop.degrade_tupe_node(node)
|
||||
function hyperloop.degrade_tupe_node(node, new_node_pos)
|
||||
if node.name == "hyperloop:tube0" then
|
||||
node.name = "hyperloop:tube1"
|
||||
elseif node.name == "hyperloop:tube1" then
|
||||
@ -86,6 +86,9 @@ function hyperloop.degrade_tupe_node(node)
|
||||
else
|
||||
return
|
||||
end
|
||||
-- determine the correct tube facedir
|
||||
local dir = vector.subtract(node.pos, new_node_pos)
|
||||
node.param2 = minetest.dir_to_facedir(dir)
|
||||
minetest.swap_node(node.pos, node)
|
||||
end
|
||||
|
||||
@ -150,7 +153,7 @@ local function head_node(node, old_head)
|
||||
node.param2 = minetest.dir_to_facedir(dir)
|
||||
minetest.swap_node(node.pos, node)
|
||||
-- degrade old head
|
||||
hyperloop.degrade_tupe_node(old_head)
|
||||
hyperloop.degrade_tupe_node(old_head, node.pos)
|
||||
return true
|
||||
end
|
||||
|
||||
@ -171,8 +174,8 @@ local function link_node(node, node1, node2)
|
||||
node.diggable = true
|
||||
minetest.swap_node(node.pos, node)
|
||||
-- degrade both nodes
|
||||
hyperloop.degrade_tupe_node(node1)
|
||||
hyperloop.degrade_tupe_node(node2)
|
||||
hyperloop.degrade_tupe_node(node1, node.pos)
|
||||
hyperloop.degrade_tupe_node(node2, node.pos)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
37
utils.lua
37
utils.lua
@ -41,39 +41,6 @@ function hyperloop.chat(player, text)
|
||||
end
|
||||
end
|
||||
|
||||
--function hyperloop.rad_to_placedir(yaw)
|
||||
-- -- radiant (0..2*PI) to my placedir (0..3) from N, W, S, E
|
||||
-- return math.floor((yaw + PI/4) / PI * 2) % 4
|
||||
--end
|
||||
|
||||
--function hyperloop.placedir_to_rad(placedir)
|
||||
-- -- my placedir (0..3) from N, W, S, E to radiant (0..2*PI)
|
||||
-- return placedir / 2 * PI
|
||||
--end
|
||||
|
||||
--function hyperloop.placedir_to_dir(placedir)
|
||||
-- -- my placedir (0..3) from N, W, S to E to dir vector
|
||||
-- local tbl = {
|
||||
-- [0] = { x=0, y=0, z=1},
|
||||
-- [1] = { x=-1, y=0, z=0},
|
||||
-- [2] = { x=0, y=0, z=-1},
|
||||
-- [3] = { x=1, y=0, z=0},
|
||||
-- }
|
||||
-- return tbl[placedir % 4]
|
||||
--end
|
||||
|
||||
---- switch from original facedir to radiant oriented placedir
|
||||
--function hyperloop.facedir_to_placedir(facedir)
|
||||
-- local tbl = {[0]=0, [1]=3, [2]=2, [3]=1}
|
||||
-- return tbl[facedir]
|
||||
--end
|
||||
|
||||
---- switch from radiant oriented placedir to original facedir
|
||||
--function hyperloop.placedir_to_facedir(placedir)
|
||||
-- local tbl = {[0]=0, [1]=3, [2]=2, [3]=1}
|
||||
-- return tbl[placedir]
|
||||
--end
|
||||
|
||||
function hyperloop.get_facedir(placer)
|
||||
local lookdir = placer:get_look_dir()
|
||||
return core.dir_to_facedir(lookdir)
|
||||
@ -84,7 +51,7 @@ function hyperloop.facedir_to_rad(facedir)
|
||||
return tbl[facedir] / 2 * PI
|
||||
end
|
||||
|
||||
-- calculate the new pos based on the given pos, the players facedir
|
||||
-- calculate the new pos based on the given pos, the players facedir, the y-offset
|
||||
-- and the given walk path like "3F2L" (F-orward, L-eft, R-ight, B-ack).
|
||||
function hyperloop.new_pos(pos, facedir, path, y_offs)
|
||||
local _pos = table.copy(pos)
|
||||
@ -294,7 +261,6 @@ function hyperloop.is_blocked(key_str)
|
||||
return false
|
||||
else
|
||||
local t = hyperloop.data.tAllStations[key_str].time_blocked or 0
|
||||
print(t, minetest.get_gametime())
|
||||
return t > minetest.get_gametime()
|
||||
end
|
||||
end
|
||||
@ -316,7 +282,6 @@ local function convert_station_list(tAllStations)
|
||||
item.station_name = key
|
||||
end
|
||||
key = hyperloop.get_key_str(pos)
|
||||
print(key.." = "..dump(item))
|
||||
end
|
||||
if item.version == 2 then
|
||||
item.version = 3
|
||||
|
2
wifi.lua
2
wifi.lua
@ -125,7 +125,7 @@ local function place_wifi_node(pos, head_node)
|
||||
-- update peer
|
||||
hyperloop.update_head_node(peer_pos, minetest.pos_to_string(pos))
|
||||
-- degrade head tube to link tube
|
||||
hyperloop.degrade_tupe_node(head_node)
|
||||
hyperloop.degrade_tupe_node(head_node, pos)
|
||||
if hyperloop.debugging then
|
||||
print("wifi meta="..dump(minetest.get_meta(pos):to_table()))
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user