diff --git a/booking.lua b/booking.lua index b5ddb47..95dc32b 100644 --- a/booking.lua +++ b/booking.lua @@ -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"] diff --git a/door.lua b/door.lua index c7a7583..bfdb179 100644 --- a/door.lua +++ b/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 diff --git a/elevator.lua b/elevator.lua index 62c9917..af5d570 100644 --- a/elevator.lua +++ b/elevator.lua @@ -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) diff --git a/init.lua b/init.lua index 85dcc09..dd7977b 100755 --- a/init.lua +++ b/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") diff --git a/junction.lua b/junction.lua index 970c0ce..874e5cb 100644 --- a/junction.lua +++ b/junction.lua @@ -9,7 +9,7 @@ See LICENSE.txt for more information History: - see junction.lua + see init.lua ]]-- diff --git a/lcd.lua b/lcd.lua index 291dd6f..32dcf0c 100644 --- a/lcd.lua +++ b/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 diff --git a/map.lua b/map.lua index 18aa7b6..93f51c1 100644 --- a/map.lua +++ b/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, }) diff --git a/recipes.lua b/recipes.lua index 330624c..e0e025e 100644 --- a/recipes.lua +++ b/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", diff --git a/seat.lua b/seat.lua index 4e78182..636b816 100644 --- a/seat.lua +++ b/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 diff --git a/textures/hyperloop_tubecrowbar.png b/textures/hyperloop_tubecrowbar.png index a47c6dd..db94e8a 100644 Binary files a/textures/hyperloop_tubecrowbar.png and b/textures/hyperloop_tubecrowbar.png differ diff --git a/textures/hyperloop_waypoint.png b/textures/hyperloop_waypoint.png new file mode 100644 index 0000000..6d8bf47 Binary files /dev/null and b/textures/hyperloop_waypoint.png differ diff --git a/textures/hyperloop_waypoint_inv.png b/textures/hyperloop_waypoint_inv.png new file mode 100644 index 0000000..153730e Binary files /dev/null and b/textures/hyperloop_waypoint_inv.png differ diff --git a/tube.lua b/tube.lua index 8a74ebd..ba33e35 100644 --- a/tube.lua +++ b/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 diff --git a/tubecrowbar.lua b/tubecrowbar.lua index 7f515b4..382b933 100644 --- a/tubecrowbar.lua +++ b/tubecrowbar.lua @@ -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 "" - local version = item.version or 0 - local station_name = item.station_name or "" - 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 "" +-- local version = item.version or 0 +-- local station_name = item.station_name or "" +-- 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, }) diff --git a/utils.lua b/utils.lua index 14bf2d0..62e23e8 100644 --- a/utils.lua +++ b/utils.lua @@ -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 diff --git a/waypoint.lua b/waypoint.lua new file mode 100644 index 0000000..e66dc47 --- /dev/null +++ b/waypoint.lua @@ -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, +})