open pod door on punch added
This commit is contained in:
parent
78b1905bdc
commit
09b35998b0
25
door.lua
25
door.lua
@ -13,11 +13,20 @@
|
|||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
-- Open the door for an emergency
|
||||||
|
local function door_on_punch(pos, node, puncher, pointed_thing)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local station_name = meta:get_string("station_name")
|
||||||
|
if not hyperloop.is_blocked(station_name) then
|
||||||
|
hyperloop.open_pod_door(station_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Open/close/animate the pod door
|
-- Open/close/animate the pod door
|
||||||
-- seat_pos: position of the seat
|
-- seat_pos: position of the seat
|
||||||
-- facedir: direction to the display
|
-- facedir: direction to the display
|
||||||
-- cmnd: "close", "open", or "animate"
|
-- cmnd: "close", "open", or "animate"
|
||||||
function hyperloop.door_command(seat_pos, facedir, cmnd)
|
function hyperloop.door_command(seat_pos, facedir, cmnd, station_name)
|
||||||
-- one step forward
|
-- one step forward
|
||||||
local lcd_pos = vector.add(seat_pos, hyperloop.facedir2dir(facedir))
|
local lcd_pos = vector.add(seat_pos, hyperloop.facedir2dir(facedir))
|
||||||
-- one step left
|
-- one step left
|
||||||
@ -52,9 +61,17 @@ function hyperloop.door_command(seat_pos, facedir, cmnd)
|
|||||||
node1.name = "hyperloop:doorBottom"
|
node1.name = "hyperloop:doorBottom"
|
||||||
node1.param2 = facedir
|
node1.param2 = facedir
|
||||||
minetest.swap_node(door_pos1, node1)
|
minetest.swap_node(door_pos1, node1)
|
||||||
|
if station_name ~= nil then
|
||||||
|
local meta = minetest.get_meta(door_pos1)
|
||||||
|
meta:set_string("station_name", station_name)
|
||||||
|
end
|
||||||
node2.name = "hyperloop:doorTopPassive"
|
node2.name = "hyperloop:doorTopPassive"
|
||||||
node2.param2 = facedir
|
node2.param2 = facedir
|
||||||
minetest.swap_node(door_pos2, node2)
|
minetest.swap_node(door_pos2, node2)
|
||||||
|
if station_name ~= nil then
|
||||||
|
meta = minetest.get_meta(door_pos2)
|
||||||
|
meta:set_string("station_name", station_name)
|
||||||
|
end
|
||||||
elseif cmnd == "animate" then
|
elseif cmnd == "animate" then
|
||||||
node2.name = "hyperloop:doorTopActive"
|
node2.name = "hyperloop:doorTopActive"
|
||||||
node2.param2 = facedir
|
node2.param2 = facedir
|
||||||
@ -78,6 +95,9 @@ 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,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
diggable = false,
|
diggable = false,
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
@ -133,6 +153,9 @@ 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,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
diggable = false,
|
diggable = false,
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
1
init.lua
1
init.lua
@ -38,6 +38,7 @@ dofile(minetest.get_modpath("hyperloop") .. "/seat.lua")
|
|||||||
dofile(minetest.get_modpath("hyperloop") .. "/pod.lua")
|
dofile(minetest.get_modpath("hyperloop") .. "/pod.lua")
|
||||||
dofile(minetest.get_modpath("hyperloop") .. "/lcd.lua")
|
dofile(minetest.get_modpath("hyperloop") .. "/lcd.lua")
|
||||||
dofile(minetest.get_modpath("hyperloop") .. "/wifi.lua")
|
dofile(minetest.get_modpath("hyperloop") .. "/wifi.lua")
|
||||||
|
--dofile(minetest.get_modpath("hyperloop") .. "/elevator.lua")
|
||||||
dofile(minetest.get_modpath("hyperloop") .. "/recipes.lua")
|
dofile(minetest.get_modpath("hyperloop") .. "/recipes.lua")
|
||||||
|
|
||||||
print ("[MOD] Hyperloop loaded")
|
print ("[MOD] Hyperloop loaded")
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
Connect two Junction blocks with a line of Tube blocks. The tube itself is automatically protected. You can dig only the ends of a tube line (head blocks). The junction block / station has to be protected by manually.
|
Connect two Junction blocks with a line of Tube blocks. The tube itself is automatically protected. You can dig only the ends of a tube line (head blocks). The junction block / station has to be protected manually.
|
||||||
|
|
||||||
A Junction block, which is the basis for a station, can have up to four tubes. That means you can build complex networks of tube lines. Each junction/station can be reaches from each point with on trip.
|
A Junction block, which is the basis for a station, can have up to four tubes. That means you can build complex networks of tube lines. Each junction/station can be reaches from each point with one trip.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
8
map.lua
8
map.lua
@ -31,13 +31,13 @@ local function station_list_as_string(pos)
|
|||||||
print("tWifi="..dump(hyperloop.tWifi))
|
print("tWifi="..dump(hyperloop.tWifi))
|
||||||
end
|
end
|
||||||
--local tRes = {"(player distance: station name (position) seat/machine/owner => directly connected with)\n\n"}
|
--local tRes = {"(player distance: station name (position) seat/machine/owner => directly connected with)\n\n"}
|
||||||
local tRes = {"size[10,10]label[0,0;Dist.]label[0.8,0;Station]label[2.5,0;Position]label[4.2,0;State]label[5.7,0;Owner]label[7.1,0;Connected with]"}
|
local tRes = {"size[10,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 state, owner
|
local state, owner
|
||||||
for idx,dataSet in ipairs(sortedList) do
|
for idx,dataSet in ipairs(sortedList) do
|
||||||
if idx == 18 then
|
if idx == 18 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
ypos = 0.2 + idx * 0.4
|
local ypos = 0.2 + idx * 0.4
|
||||||
if dataSet.seat == true and dataSet.booking_pos ~= nil then
|
if dataSet.seat == true and dataSet.booking_pos ~= nil then
|
||||||
state = "completed"
|
state = "completed"
|
||||||
elseif dataSet.seat == true then
|
elseif dataSet.seat == true then
|
||||||
@ -51,10 +51,10 @@ local function station_list_as_string(pos)
|
|||||||
owner = "unknown"
|
owner = "unknown"
|
||||||
end
|
end
|
||||||
tRes[#tRes+1] = "label[0,"..ypos..";"..dataSet.distance.." m]"
|
tRes[#tRes+1] = "label[0,"..ypos..";"..dataSet.distance.." m]"
|
||||||
tRes[#tRes+1] = "label[0.8,"..ypos..";"..dataSet.name.."]"
|
tRes[#tRes+1] = "label[0.9,"..ypos..";"..dataSet.name.."]"
|
||||||
tRes[#tRes+1] = "label[2.5,"..ypos..";"..dataSet.pos.."]"
|
tRes[#tRes+1] = "label[2.5,"..ypos..";"..dataSet.pos.."]"
|
||||||
tRes[#tRes+1] = "label[4.2,"..ypos..";"..state.."]"
|
tRes[#tRes+1] = "label[4.2,"..ypos..";"..state.."]"
|
||||||
tRes[#tRes+1] = "label[5.7,"..ypos..";"..owner.."]"
|
tRes[#tRes+1] = "label[5.6,"..ypos..";"..owner.."]"
|
||||||
tRes[#tRes+1] = "label[7.1,"..ypos..";"
|
tRes[#tRes+1] = "label[7.1,"..ypos..";"
|
||||||
for _,s in ipairs(hyperloop.get_connections(dataSet.name)) do
|
for _,s in ipairs(hyperloop.get_connections(dataSet.name)) do
|
||||||
tRes[#tRes + 1] = s
|
tRes[#tRes + 1] = s
|
||||||
|
14
seat.lua
14
seat.lua
@ -20,7 +20,7 @@ local function on_final_close_door(pos, facedir)
|
|||||||
-- try again later
|
-- try again later
|
||||||
minetest.after(3.0, on_final_close_door, pos, facedir)
|
minetest.after(3.0, on_final_close_door, pos, facedir)
|
||||||
else
|
else
|
||||||
hyperloop.door_command(pos, facedir, "close")
|
hyperloop.door_command(pos, facedir, "close", nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ local function on_open_door(pos, facedir)
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_int("arrival_time", 0) -- finished
|
meta:set_int("arrival_time", 0) -- finished
|
||||||
-- open door
|
-- open door
|
||||||
hyperloop.door_command(pos, facedir, "open")
|
hyperloop.door_command(pos, facedir, "open", nil)
|
||||||
-- prepare dislay for the next trip
|
-- prepare dislay for the next trip
|
||||||
hyperloop.enter_display(pos, facedir, "Thank you | for | travelling | with | Hyperloop.")
|
hyperloop.enter_display(pos, facedir, "Thank you | for | travelling | with | Hyperloop.")
|
||||||
minetest.after(5.0, on_final_close_door, pos, facedir)
|
minetest.after(5.0, on_final_close_door, pos, facedir)
|
||||||
@ -53,7 +53,7 @@ local function on_arrival(player, src_pos, src_facedir, dst_pos, snd, radiant)
|
|||||||
-- rotate player to look in correct arrival direction
|
-- rotate player to look in correct arrival direction
|
||||||
-- calculate the look correction
|
-- calculate the look correction
|
||||||
local offs = radiant - player:get_look_horizontal()
|
local offs = radiant - player:get_look_horizontal()
|
||||||
local yaw = hyperloop.facedir2rad(facedir) + offs
|
local yaw = hyperloop.facedir2rad(facedir) - offs
|
||||||
player:set_look_yaw(yaw)
|
player:set_look_yaw(yaw)
|
||||||
end
|
end
|
||||||
-- play arrival sound
|
-- play arrival sound
|
||||||
@ -77,7 +77,7 @@ local function on_travel(src_pos, facedir, player, dst_pos, radiant, atime)
|
|||||||
max_hear_distance = 1,
|
max_hear_distance = 1,
|
||||||
loop = true,
|
loop = true,
|
||||||
})
|
})
|
||||||
hyperloop.door_command(src_pos, facedir, "animate")
|
hyperloop.door_command(src_pos, facedir, "animate", nil)
|
||||||
minetest.after(atime, on_arrival, player, src_pos, facedir, dst_pos, snd, radiant)
|
minetest.after(atime, on_arrival, player, src_pos, facedir, dst_pos, snd, radiant)
|
||||||
minetest.after(atime, on_final_close_door, src_pos, facedir)
|
minetest.after(atime, on_final_close_door, src_pos, facedir)
|
||||||
end
|
end
|
||||||
@ -151,7 +151,7 @@ local function on_start_travel(pos, node, clicker)
|
|||||||
max_hear_distance = 10
|
max_hear_distance = 10
|
||||||
})
|
})
|
||||||
-- close the door at arrival station
|
-- close the door at arrival station
|
||||||
hyperloop.door_command(dest_pos, dest_facedir, "close")
|
hyperloop.door_command(dest_pos, dest_facedir, "close", dest_name)
|
||||||
-- place player on the seat
|
-- place player on the seat
|
||||||
clicker:setpos(pos)
|
clicker:setpos(pos)
|
||||||
-- rotate player to look in move direction
|
-- rotate player to look in move direction
|
||||||
@ -178,7 +178,7 @@ local function on_start_travel(pos, node, clicker)
|
|||||||
meta:set_string("lcd_text", text)
|
meta:set_string("lcd_text", text)
|
||||||
minetest.get_node_timer(pos):start(1.0)
|
minetest.get_node_timer(pos):start(1.0)
|
||||||
|
|
||||||
hyperloop.door_command(pos, facedir, "close")
|
hyperloop.door_command(pos, facedir, "close", station_name)
|
||||||
|
|
||||||
atime = atime - 9 -- substract start/arrival time
|
atime = atime - 9 -- substract start/arrival time
|
||||||
minetest.after(4.9, on_travel, pos, facedir, clicker, dest_pos, hyperloop.facedir2rad(facedir), atime)
|
minetest.after(4.9, on_travel, pos, facedir, clicker, dest_pos, hyperloop.facedir2rad(facedir), atime)
|
||||||
@ -202,7 +202,7 @@ function hyperloop.close_pod_door(station_name)
|
|||||||
local seat_pos = vector.add(pos, {x=0, y=1, z=0})
|
local seat_pos = vector.add(pos, {x=0, y=1, z=0})
|
||||||
local meta = minetest.get_meta(seat_pos)
|
local meta = minetest.get_meta(seat_pos)
|
||||||
local facedir = meta:get_int("facedir")
|
local facedir = meta:get_int("facedir")
|
||||||
hyperloop.door_command(seat_pos, facedir, "close")
|
hyperloop.door_command(seat_pos, facedir, "close", station_name)
|
||||||
hyperloop.enter_display(seat_pos, facedir, " | | << Hyperloop >> | be anywhere")
|
hyperloop.enter_display(seat_pos, facedir, " | | << Hyperloop >> | be anywhere")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
11
utils.lua
11
utils.lua
@ -261,6 +261,17 @@ function hyperloop.block(departure, arrival, seconds)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- check if station is blocked
|
||||||
|
function hyperloop.is_blocked(station)
|
||||||
|
if hyperloop.tAllStations[station] == nil then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
local t = hyperloop.tAllStations[station].time_blocked or 0
|
||||||
|
print(t, minetest.get_gametime())
|
||||||
|
return t > minetest.get_gametime()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Store and read the station list to / from a file
|
-- Store and read the station list to / from a file
|
||||||
-- so that upcoming actions are remembered when the game
|
-- so that upcoming actions are remembered when the game
|
||||||
-- is restarted
|
-- is restarted
|
||||||
|
Loading…
x
Reference in New Issue
Block a user