waypoint added
This commit is contained in:
parent
af0258a3b0
commit
576be05072
@ -21,7 +21,6 @@
|
||||
-- return sorted list of all network stations
|
||||
local function get_station_list(key_str)
|
||||
local tRes = {}
|
||||
print("get_station_list")
|
||||
local local_pos = hyperloop.data.tAllStations[key_str]["pos"]
|
||||
for idx,dest_key in ipairs(hyperloop.get_network_stations(key_str)) do
|
||||
local dest_pos = hyperloop.data.tAllStations[dest_key]["pos"]
|
||||
|
1
door.lua
1
door.lua
@ -76,7 +76,6 @@ end
|
||||
-- door command based on the station data table
|
||||
function hyperloop.open_pod_door(tStation)
|
||||
if tStation ~= nil then
|
||||
print(S(tStation.pos), tStation.facedir)
|
||||
local door_pos = hyperloop.new_pos(tStation.pos, tStation.facedir, "1F1L", 1)
|
||||
door_command(door_pos, "open")
|
||||
end
|
||||
|
@ -283,7 +283,6 @@ local function update_elevator(pos, called_from_peer)
|
||||
-- check lower position
|
||||
npos = Shaft:get_connected_node_pos(pos, 5)
|
||||
down = Shaft:secondary_node(npos) ~= nil
|
||||
print("update_elevator down", S(pos), S(npos), down)
|
||||
-- update the evelator on the other end if it's not the caller
|
||||
if down and not called_from_peer then
|
||||
-- address the elevator lower part
|
||||
@ -295,7 +294,6 @@ local function update_elevator(pos, called_from_peer)
|
||||
pos.y = pos.y + 1
|
||||
npos = Shaft:get_connected_node_pos(pos, 6)
|
||||
up = Shaft:secondary_node(npos) ~= nil
|
||||
print("update_elevator up", S(pos), S(npos), up)
|
||||
-- update the evelator on the other end if it's not the caller
|
||||
if up and not called_from_peer then
|
||||
update_elevator(npos, true)
|
||||
|
2
init.lua
2
init.lua
@ -60,7 +60,7 @@ dofile(minetest.get_modpath("hyperloop") .. "/door.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/seat.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/robot.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/lcd.lua")
|
||||
--dofile(minetest.get_modpath("hyperloop") .. "/nametag.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/waypoint.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/deco.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/tubecrowbar.lua")
|
||||
dofile(minetest.get_modpath("hyperloop") .. "/recipes.lua")
|
||||
|
@ -9,7 +9,7 @@
|
||||
See LICENSE.txt for more information
|
||||
|
||||
History:
|
||||
see junction.lua
|
||||
see init.lua
|
||||
|
||||
]]--
|
||||
|
||||
|
2
lcd.lua
2
lcd.lua
@ -189,7 +189,7 @@ minetest.register_entity(":hyperloop_lcd:text", {
|
||||
textures = {},
|
||||
|
||||
on_activate = function(self)
|
||||
local meta = minetest.get_meta(self.object:getpos())
|
||||
local meta = minetest.get_meta(self.object:get_pos())
|
||||
local text = meta:get_string("text")
|
||||
self.object:set_properties({textures={generate_texture(create_lines(text))}})
|
||||
end
|
||||
|
36
map.lua
36
map.lua
@ -13,37 +13,6 @@
|
||||
|
||||
]]--
|
||||
|
||||
-- Check data base and remove invalid entries
|
||||
local function check_station_data()
|
||||
local tRes = {}
|
||||
local node
|
||||
--local keys = {}
|
||||
for key,item in pairs(table.copy(hyperloop.data.tAllStations)) do
|
||||
--keys[#keys + 1] = key
|
||||
if item.pos ~= nil then
|
||||
node = minetest.get_node(item.pos)
|
||||
if node ~= nil then
|
||||
if node.name == "hyperloop:station" or node.name == "hyperloop:junction" or node.name == "ignore" then
|
||||
-- valid data
|
||||
tRes[key] = item
|
||||
--tRes[idx] = #keys
|
||||
else -- node removed via WorldEdit?
|
||||
print("[Hyperloop] "..key..": "..node.name.." is no station")
|
||||
end
|
||||
else -- unloaded?
|
||||
print("[Hyperloop] "..key..": node is nil")
|
||||
-- probably valid data
|
||||
tRes[key] = item
|
||||
end
|
||||
else
|
||||
-- invalid data
|
||||
print("[Hyperloop] "..key..": item.pos == nil")
|
||||
end
|
||||
end
|
||||
hyperloop.data.tAllStations = tRes
|
||||
end
|
||||
|
||||
|
||||
-- Return a text block with all station names and their attributes
|
||||
local function station_list_as_string(pos)
|
||||
-- First sort the station list according to the players distance.
|
||||
@ -114,10 +83,8 @@ end
|
||||
|
||||
|
||||
local function map_on_use(itemstack, user)
|
||||
--check_station_data()
|
||||
local player_name = user:get_player_name()
|
||||
--local pos = user:get_pos()
|
||||
local pos = user:getpos()
|
||||
local pos = user:get_pos()
|
||||
local sStationList = station_list_as_string(pos)
|
||||
local formspec = "size[12,10]" .. default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
@ -136,5 +103,6 @@ minetest.register_node("hyperloop:station_map", {
|
||||
groups = {cracky=1, book=1},
|
||||
on_use = map_on_use,
|
||||
on_place = map_on_use,
|
||||
stack_max = 1,
|
||||
})
|
||||
|
||||
|
10
recipes.lua
10
recipes.lua
@ -183,6 +183,16 @@ minetest.register_craft({
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "hyperloop:waypoint",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"", "", ""},
|
||||
{"default:steel_ingot", "hyperloop:hypersteel_ingot", "default:gold_ingot"},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "dye:cyan",
|
||||
|
3
seat.lua
3
seat.lua
@ -95,9 +95,6 @@ local function display_timer(pos, elapsed)
|
||||
local key_str = meta:get_string("key_str")
|
||||
local tStation = hyperloop.get_station_data(key_str)
|
||||
local atime = meta:get_int("arrival_time") - 1
|
||||
if hyperloop.debugging then
|
||||
print("Timer".. atime)
|
||||
end
|
||||
meta:set_int("arrival_time", atime)
|
||||
local text = meta:get_string("lcd_text")
|
||||
if atime > 2 then
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
BIN
textures/hyperloop_waypoint.png
Normal file
BIN
textures/hyperloop_waypoint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 615 B |
BIN
textures/hyperloop_waypoint_inv.png
Normal file
BIN
textures/hyperloop_waypoint_inv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 499 B |
13
tube.lua
13
tube.lua
@ -9,7 +9,7 @@
|
||||
See LICENSE.txt for more information
|
||||
|
||||
History:
|
||||
see tube.lua
|
||||
see init.lua
|
||||
|
||||
]]--
|
||||
|
||||
@ -53,10 +53,14 @@ function hyperloop.check_network_level(pos, player)
|
||||
"Do you realy want to start a new network?!")
|
||||
end
|
||||
|
||||
-- North, East, South, West, Down, Up
|
||||
local allowed_6d_dirs = {true, true, true, true, false, false} -- horizontal only
|
||||
if hyperloop.free_tube_placement_enabled then
|
||||
allowed_6d_dirs = {true, true, true, true, true, true} -- all directions
|
||||
end
|
||||
|
||||
local Tube = tubelib2.Tube:new({
|
||||
-- North, East, South, West, Down, Up
|
||||
--allowed_6d_dirs = {true, true, true, true, false, false}, -- horizontal only
|
||||
allowed_6d_dirs = {true, true, true, true, true, true}, -- horizontal only
|
||||
allowed_6d_dirs = allowed_6d_dirs,
|
||||
max_tube_length = 1000,
|
||||
show_infotext = true,
|
||||
primary_node_names = {"hyperloop:tube", "hyperloop:tube2"},
|
||||
@ -165,7 +169,6 @@ function hyperloop.update_routes(pos, called_from_peer, player_name)
|
||||
end
|
||||
for dir = 1,4 do -- check all 4 directions
|
||||
local npos = Tube:get_connected_node_pos(pos, dir)
|
||||
--print(S(pos), dir, S(npos), minetest.get_node(npos).name)
|
||||
if Tube:secondary_node(npos) then
|
||||
table.insert(tRoutes, {S(pos), S(npos)})
|
||||
if not called_from_peer then
|
||||
|
@ -87,25 +87,25 @@ local function route_list(lStationPositions, routes)
|
||||
return table.concat(tRes)
|
||||
end
|
||||
|
||||
local function dump_station_list(itemstack, placer, pointed_thing)
|
||||
local lStationPositions = {}
|
||||
local idx = 1
|
||||
for _,item in pairs(hyperloop.data.tAllStations) do
|
||||
local spos = S(item.pos)
|
||||
lStationPositions[spos] = idx
|
||||
idx = idx + 1
|
||||
end
|
||||
print("[Hyperloop] Station list")
|
||||
for _,item in pairs(hyperloop.data.tAllStations) do
|
||||
local spos = item.pos and S(item.pos) or "<unknown>"
|
||||
local version = item.version or 0
|
||||
local station_name = item.station_name or "<unknown>"
|
||||
local junction = item.junction or false
|
||||
local routes = route_list(lStationPositions, item.routes)
|
||||
print("pos = "..spos..", ver = "..version..", name = "..station_name..", junc = "..dump(junction)..", routes = "..routes)
|
||||
end
|
||||
print(dump(hyperloop.data))
|
||||
end
|
||||
--local function dump_station_list(itemstack, placer, pointed_thing)
|
||||
-- local lStationPositions = {}
|
||||
-- local idx = 1
|
||||
-- for _,item in pairs(hyperloop.data.tAllStations) do
|
||||
-- local spos = S(item.pos)
|
||||
-- lStationPositions[spos] = idx
|
||||
-- idx = idx + 1
|
||||
-- end
|
||||
-- print("[Hyperloop] Station list")
|
||||
-- for _,item in pairs(hyperloop.data.tAllStations) do
|
||||
-- local spos = item.pos and S(item.pos) or "<unknown>"
|
||||
-- local version = item.version or 0
|
||||
-- local station_name = item.station_name or "<unknown>"
|
||||
-- local junction = item.junction or false
|
||||
-- local routes = route_list(lStationPositions, item.routes)
|
||||
-- print("pos = "..spos..", ver = "..version..", name = "..station_name..", junc = "..dump(junction)..", routes = "..routes)
|
||||
-- end
|
||||
-- print(dump(hyperloop.data))
|
||||
--end
|
||||
|
||||
|
||||
-- Tool for tube workers to crack a protected tube line
|
||||
@ -117,7 +117,7 @@ minetest.register_node("hyperloop:tube_crowbar", {
|
||||
groups = {cracky=1, book=1},
|
||||
on_use = remove_tube,
|
||||
on_place = repair_tubes,
|
||||
on_secondary_use = dump_station_list,
|
||||
--on_secondary_use = dump_station_list,
|
||||
node_placement_prediction = "",
|
||||
stack_max = 1,
|
||||
})
|
||||
|
@ -211,9 +211,6 @@ function hyperloop.reserve(departure, arrival, player)
|
||||
-- place a reservation for 20 seconds to start the trip
|
||||
hyperloop.data.tAllStations[departure].time_blocked = minetest.get_gametime() + 20
|
||||
hyperloop.data.tAllStations[arrival].time_blocked = minetest.get_gametime() + 20
|
||||
if hyperloop.debugging then
|
||||
print(departure.." and ".. arrival.." stations are reserved")
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -228,9 +225,6 @@ function hyperloop.block(departure, arrival, seconds)
|
||||
else
|
||||
hyperloop.data.tAllStations[departure].time_blocked = minetest.get_gametime() + seconds
|
||||
hyperloop.data.tAllStations[arrival].time_blocked = minetest.get_gametime() + seconds
|
||||
if hyperloop.debugging then
|
||||
print(departure.." and ".. arrival.." stations are blocked")
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
63
waypoint.lua
Normal file
63
waypoint.lua
Normal file
@ -0,0 +1,63 @@
|
||||
--[[
|
||||
|
||||
Hyperloop Mod
|
||||
=============
|
||||
|
||||
Copyright (C) 2017 Joachim Stolberg
|
||||
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
History:
|
||||
see init.lua
|
||||
|
||||
]]--
|
||||
|
||||
local Waypoints = {}
|
||||
|
||||
minetest.register_node("hyperloop:waypoint", {
|
||||
description = "Hyperloop Waypoint",
|
||||
inventory_image = "hyperloop_waypoint_inv.png",
|
||||
tiles = {
|
||||
"hyperloop_waypoint.png",
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -4/16, -8/16, -4/16, 4/16, -7/16, 4/16},
|
||||
},
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local name = placer:get_player_name()
|
||||
if Waypoints[name] then
|
||||
placer:hud_remove(Waypoints[name])
|
||||
Waypoints[name] = nil
|
||||
end
|
||||
Waypoints[name] = placer:hud_add({
|
||||
hud_elem_type = "waypoint",
|
||||
number = 0x99d8d9,
|
||||
name = "Hyperloop",
|
||||
text = "m",
|
||||
world_pos = pos
|
||||
})
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local name = digger:get_player_name()
|
||||
if Waypoints[name] then
|
||||
digger:hud_remove(Waypoints[name])
|
||||
Waypoints[name] = nil
|
||||
end
|
||||
end,
|
||||
|
||||
paramtype = "light",
|
||||
light_source = minetest.LIGHT_MAX,
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
stack_max = 1,
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user