some corrections

This commit is contained in:
Joachim Stolberg 2017-07-06 20:05:17 +02:00
parent 038df15f0e
commit f8f2bd3102
10 changed files with 168 additions and 174 deletions

View File

@ -9,7 +9,7 @@
* 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. It also includes a WiFi tube block for very large distances (admin feature).
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).
Browse on: ![GitHub](https://github.com/joe7575/Minetest-Hyperloop)
@ -22,6 +22,13 @@ Download: ![GitHub](https://github.com/joe7575/Minetest-Hyperloop/archive/master
[Contruction Manual](introduction.md)
## Still To Do
* recipes
* better formspec for the map tool
* performance improvements
## Dependencies
default

View File

@ -23,7 +23,6 @@ function hyperloop.update_all_booking_machines()
if dataset.booking_pos ~= nil then
local pos = minetest.string_to_pos(dataset.booking_pos)
minetest.registered_nodes["hyperloop:booking"].update(pos)
break--------------------------TODO
end
end
t = minetest.get_us_time() - t
@ -50,6 +49,9 @@ local function formspec(station_name)
tRes[2] = "label[1,1;Destination]label[3,1;Distance]label[4.5,1;Position]label[6,1;Local Info]"
local local_pos = hyperloop.tAllStations[station_name]["pos"]
for idx,dest_name in ipairs(get_station_list(station_name)) do
if idx >= 12 then
break
end
local ypos = 1 + idx*0.8
local ypos2 = ypos - 0.2
local dest_info = hyperloop.tAllStations[dest_name]["booking_info"] or ""
@ -114,11 +116,11 @@ minetest.register_node("hyperloop:booking", {
meta:set_string("station_name", station_name)
meta:set_string("infotext", "Station: "..station_name)
meta:set_string("formspec", formspec(station_name))
--hyperloop.update_all_booking_machines()
hyperloop.change_counter = hyperloop.change_counter + 1
else
minetest.chat_send_player(player:get_player_name(), "[Hyperloop] Error: Invalid station name!")
end
-- destination selected?
-- destination selected?
elseif fields.button ~= nil then
local station_name = meta:get_string("station_name")
local idx = tonumber(fields.button)
@ -141,6 +143,7 @@ minetest.register_node("hyperloop:booking", {
and hyperloop.tAllStations[station_name]["booking_pos"] ~= nil then
hyperloop.tAllStations[station_name]["booking_pos"] = nil
end
hyperloop.change_counter = hyperloop.change_counter + 1
end,
update = function(pos)
@ -157,22 +160,22 @@ minetest.register_node("hyperloop:booking", {
})
minetest.register_abm({
label = "[Hyperloop] Booking machine update",
nodenames = {"hyperloop:booking"},
interval = 10.0, -- Run every 10 seconds
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local counter = meta:get_int("change_counter") or 0
if hyperloop.change_counter ~= counter then
local station_name = meta:get_string("station_name") or nil
if station_name ~= nil and hyperloop.tAllStations[station_name] ~= nil then
local stations = get_station_list(station_name)
meta:set_string("formspec", formspec(station_name, stations))
label = "[Hyperloop] Booking machine update",
nodenames = {"hyperloop:booking"},
interval = 10.0, -- Run every 10 seconds
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local counter = meta:get_int("change_counter") or 0
if hyperloop.change_counter ~= counter then
local station_name = meta:get_string("station_name") or nil
if station_name ~= nil and hyperloop.tAllStations[station_name] ~= nil then
local stations = get_station_list(station_name)
meta:set_string("formspec", formspec(station_name, stations))
end
meta:set_int("change_counter", hyperloop.change_counter)
print("booking")
end
meta:set_int("change_counter", hyperloop.change_counter)
print("booking")
end
end
})
})

231
door.lua
View File

@ -18,142 +18,125 @@
-- facedir: direction to the display
-- cmnd: "close", "open", or "animate"
function hyperloop.door_command(seat_pos, facedir, cmnd)
-- one step forward
local lcd_pos = vector.add(seat_pos, hyperloop.facedir2dir(facedir))
-- one step left
local door_pos1 = vector.add(lcd_pos, hyperloop.facedir2dir(facedir + 1))
-- one step up
local door_pos2 = vector.add(door_pos1, {x=0, y=1, z=0})
-- one step forward
local lcd_pos = vector.add(seat_pos, hyperloop.facedir2dir(facedir))
-- one step left
local door_pos1 = vector.add(lcd_pos, hyperloop.facedir2dir(facedir + 1))
-- one step up
local door_pos2 = vector.add(door_pos1, {x=0, y=1, z=0})
local node1 = minetest.get_node(door_pos1)
local node2 = minetest.get_node(door_pos2)
local node1 = minetest.get_node(door_pos1)
local node2 = minetest.get_node(door_pos2)
-- switch from the radian following facedir to the silly original one
local tbl = {[0]=0, [1]=3, [2]=2, [3]=1}
facedir = (facedir + 3) % 4 -- first turn left
facedir = tbl[facedir]
-- switch from the radian following facedir to the silly original one
local tbl = {[0]=0, [1]=3, [2]=2, [3]=1}
facedir = (facedir + 3) % 4 -- first turn left
facedir = tbl[facedir]
if cmnd == "open" then
if cmnd == "open" then
minetest.sound_play("door", {
pos = seat_pos,
gain = 0.5,
max_hear_distance = 5,
})
node1.name = "air"
minetest.swap_node(door_pos1, node1)
node2.name = "air"
minetest.swap_node(door_pos2, node2)
elseif cmnd == "close" then
pos = seat_pos,
gain = 0.5,
max_hear_distance = 5,
})
node1.name = "air"
minetest.swap_node(door_pos1, node1)
node2.name = "air"
minetest.swap_node(door_pos2, node2)
elseif cmnd == "close" then
minetest.sound_play("door", {
pos = seat_pos,
gain = 0.5,
max_hear_distance = 5,
})
node1.name = "hyperloop:doorBottom"
node1.param2 = facedir
minetest.swap_node(door_pos1, node1)
node2.name = "hyperloop:doorTopPassive"
node2.param2 = facedir
minetest.swap_node(door_pos2, node2)
elseif cmnd == "animate" then
node2.name = "hyperloop:doorTopActive"
node2.param2 = facedir
minetest.swap_node(door_pos2, node2)
end
pos = seat_pos,
gain = 0.5,
max_hear_distance = 5,
})
node1.name = "hyperloop:doorBottom"
node1.param2 = facedir
minetest.swap_node(door_pos1, node1)
node2.name = "hyperloop:doorTopPassive"
node2.param2 = facedir
minetest.swap_node(door_pos2, node2)
elseif cmnd == "animate" then
node2.name = "hyperloop:doorTopActive"
node2.param2 = facedir
minetest.swap_node(door_pos2, node2)
end
end
minetest.register_node("hyperloop:doorTopPassive", {
description = "Hyperloop Door Top",
tiles = {
-- up, down, right, left, back, front
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_door1OUT.png",
"hyperloop_door1OUT.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-8/16, -8/16, -6/16, 8/16, 8/16, 6/16},
},
paramtype2 = "facedir",
diggable = false,
sounds = default.node_sound_metal_defaults(),
groups = {cracky=1, not_in_creative_inventory=1},
is_ground_content = false,
})
description = "Hyperloop Door Top",
tiles = {
-- up, down, right, left, back, front
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_door1OUT.png",
"hyperloop_door1OUT.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
},
paramtype2 = "facedir",
diggable = false,
sounds = default.node_sound_metal_defaults(),
groups = {cracky=1, not_in_creative_inventory=1},
is_ground_content = false,
})
minetest.register_node("hyperloop:doorTopActive", {
description = "Hyperloop Door Top",
tiles = {
-- up, down, right, left, back, front
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
{
name = "hyperloop_door1IN.png",
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 1.0,
description = "Hyperloop Door Top",
tiles = {
-- up, down, right, left, back, front
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
{
name = "hyperloop_door1IN.png",
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 1.0,
},
},
"hyperloop_door1OUT.png",
},
"hyperloop_door1OUT.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-8/16, -8/16, -6/16, 8/16, 8/16, 6/16},
},
paramtype2 = "facedir",
diggable = false,
light_source = 2,
sounds = default.node_sound_metal_defaults(),
groups = {cracky=1, not_in_creative_inventory=1},
is_ground_content = false,
})
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
},
paramtype2 = "facedir",
diggable = false,
light_source = 2,
sounds = default.node_sound_metal_defaults(),
groups = {cracky=1, not_in_creative_inventory=1},
is_ground_content = false,
})
minetest.register_node("hyperloop:doorBottom", {
description = "Hyperloop Door Bottom",
tiles = {
-- up, down, right, left, back, front
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_door2IN.png",
"hyperloop_door2OUT.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
},
paramtype2 = "facedir",
diggable = false,
sounds = default.node_sound_metal_defaults(),
groups = {cracky=1, not_in_creative_inventory=1},
is_ground_content = false,
})
minetest.register_node("hyperloop:doorframe", {
description = "Hyperloop Pod Doorframe",
tiles = {
-- up, down, right, left, back, front
"hyperloop_skin_door.png^[transformR90]",
"hyperloop_skin_door.png^[transformR90]",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin.png",
"hyperloop_skin.png",
},
paramtype2 = "facedir",
sounds = default.node_sound_metal_defaults(),
groups = {cracky=1},
is_ground_content = false,
})
description = "Hyperloop Door Bottom",
tiles = {
-- up, down, right, left, back, front
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_skin_door.png",
"hyperloop_door2IN.png",
"hyperloop_door2OUT.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-8/16, -8/16, -5/16, 8/16, 8/16, 5/16},
},
paramtype2 = "facedir",
diggable = false,
sounds = default.node_sound_metal_defaults(),
groups = {cracky=1, not_in_creative_inventory=1},
is_ground_content = false,
})

View File

@ -3,7 +3,7 @@
Hyperloop Mod
=============
v0.01 by JoSt
v0.02 by JoSt
Copyright (C) 2017 Joachim Stolberg
@ -12,6 +12,7 @@
History:
2017-06-18 v0.01 First version
2017-07-06 v0.02 Version on GitHub
]]--
@ -23,7 +24,7 @@ hyperloop = {
change_counter = 0, -- used for booking machine updates
}
hyperloop.debugging = true
hyperloop.debugging = false
dofile(minetest.get_modpath("hyperloop") .. "/utils.lua")
dofile(minetest.get_modpath("hyperloop") .. "/tube.lua")
@ -35,6 +36,5 @@ dofile(minetest.get_modpath("hyperloop") .. "/seat.lua")
dofile(minetest.get_modpath("hyperloop") .. "/pod.lua")
dofile(minetest.get_modpath("hyperloop") .. "/lcd.lua")
dofile(minetest.get_modpath("hyperloop") .. "/wifi.lua")
--dofile(minetest.get_modpath("hyperloop") .. "/robot.lua")
print ("[MOD] Hyperloop loaded")

View File

@ -15,7 +15,7 @@ Build the pod around the seat according to the following picture. To get the bes
![Image](https://github.com/joe7575/Minetest-Hyperloop/blob/master/img/intro04.png)
The pod shell is not important for the function, the minimal equipment for testing is: the Tube line with Junction Blocks, a Pod Seat on each station, the Display in front of the seat, and the Booking Machine. The Booking Machine has to get the same station name as the Junction block and has to be placed nearby the Junction block (max. 20 blocks difference).
The pod shell is not important for the function, the minimal equipment for testing is: the Tube line with Junction blocks, a Pod Seat on each station, the Display in front of the seat, and the Booking Machine. The Booking Machine has to get the same station name as the Junction block and has to be placed nearby the Junction block (max. 30 blocks difference).
![Image](https://github.com/joe7575/Minetest-Hyperloop/blob/master/img/intro02.png)

View File

@ -72,7 +72,7 @@ minetest.register_node("hyperloop:junction", {
meta:set_string("infotext", "Station "..default_name(pos))
meta:set_string("formspec", formspec)
store_routes(pos, placer)
--hyperloop.update_all_booking_machines()
hyperloop.change_counter = hyperloop.change_counter + 1
end,
on_receive_fields = function(pos, formname, fields, player)
@ -98,7 +98,7 @@ minetest.register_node("hyperloop:junction", {
meta:set_string("station_name", station_name)
meta:set_string("infotext", "Station '"..station_name.."'")
store_routes(pos, player)
--hyperloop.update_all_booking_machines()
hyperloop.change_counter = hyperloop.change_counter + 1
end,
on_destruct = function(pos)
@ -107,7 +107,7 @@ minetest.register_node("hyperloop:junction", {
local station_name = meta:get_string("station_name")
if hyperloop.tAllStations[station_name] ~= nil then
hyperloop.tAllStations[station_name] = nil
--hyperloop.update_all_booking_machines()
hyperloop.change_counter = hyperloop.change_counter + 1
end
end,
@ -125,15 +125,15 @@ minetest.register_node("hyperloop:junction", {
})
minetest.register_lbm({
label = "[Hyperloop] Junction update",
name = "hyperloop:update",
nodenames = {"hyperloop:junction"},
run_at_every_load = true,
action = function(pos, node)
if hyperloop.debugging then
print("Junction loaded")
label = "[Hyperloop] Junction update",
name = "hyperloop:update",
nodenames = {"hyperloop:junction"},
run_at_every_load = true,
action = function(pos, node)
if hyperloop.debugging then
print("Junction loaded")
end
store_routes(pos, nil)
end
store_routes(pos, nil)
end
})
})

View File

@ -28,7 +28,7 @@ end
-- to build the pod
minetest.register_node("hyperloop:pod_wall", {
description = "Hyperloop Pod Wall",
description = "Hyperloop Pod Shell",
tiles = {
-- up, down, right, left, back, front
"hyperloop_skin2.png",

View File

@ -43,15 +43,15 @@ local function on_arrival(player, src_pos, src_facedir, dst_pos, snd, radiant)
-- activate display
local station_name = meta:get_string("station_name")
local text = " | Welcome at | | "..station_name
local text = " | Welcome at | | "..string.sub(station_name, 1, 13)
hyperloop.enter_display(dst_pos, facedir, text)
-- stop timer
minetest.get_node_timer(src_pos):stop()
-- move player to the arrival station
player:setpos(dst_pos)
-- rotate player to look in correct arrival direction
-- calculate the look correction
if player ~= nil then -- player already gone?
if player ~= nil then
player:setpos(dst_pos)
-- rotate player to look in correct arrival direction
-- calculate the look correction
local offs = radiant - player:get_look_horizontal()
local yaw = hyperloop.facedir2rad(facedir) + offs
player:set_look_yaw(yaw)
@ -105,9 +105,9 @@ local function meter_to_km(dist)
if dist < 1000 then
return tostring(dist).." m"
elseif dist < 10000 then
return tostring(math.floor(dist/1000)).."."..string.sub(tostring(math.floor(dist%1000)),1, -2).." km"
return string.format("%.3f km", dist/1000)
else
return tostring(math.floor(dist/1000)).."."..string.sub(tostring(math.floor(dist%1000)),1, -3).." km"
return string.format("%.1f km", dist/1000)
end
end
@ -159,7 +159,7 @@ local function on_start_travel(pos, node, clicker)
-- activate display
local dist = hyperloop.distance(pos, dest_pos)
local text = "Destination: | "..dest_name.." | Distance: | "..meter_to_km(dist).." | Arrival in: | "
local text = "Destination: | "..string.sub(dest_name, 1, 13).." | Distance: | "..meter_to_km(dist).." | Arrival in: | "
local atime
if dist < 1000 then
atime = 10 + math.floor(dist/100) -- 10..20 sec

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -222,6 +222,7 @@ for idx = 0,1 do
groups = {cracky=2, not_in_creative_inventory=idx},
is_ground_content = false,
drop = "hyperloop:tube0",
sounds = default.node_sound_metal_defaults(),
})
end