From 576be05072fef946fd4696dfbe52334023bac16d Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sun, 28 Oct 2018 20:25:47 +0100 Subject: [PATCH] waypoint added --- booking.lua | 1 - door.lua | 1 - elevator.lua | 2 - init.lua | 2 +- junction.lua | 2 +- lcd.lua | 2 +- map.lua | 36 +--------------- recipes.lua | 10 +++++ seat.lua | 3 -- textures/hyperloop_tubecrowbar.png | Bin 2244 -> 2241 bytes textures/hyperloop_waypoint.png | Bin 0 -> 615 bytes textures/hyperloop_waypoint_inv.png | Bin 0 -> 499 bytes tube.lua | 13 +++--- tubecrowbar.lua | 40 +++++++++--------- utils.lua | 6 --- waypoint.lua | 63 ++++++++++++++++++++++++++++ 16 files changed, 106 insertions(+), 75 deletions(-) create mode 100644 textures/hyperloop_waypoint.png create mode 100644 textures/hyperloop_waypoint_inv.png create mode 100644 waypoint.lua 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 a47c6dd80ae1de5f395c8706169699282c3eb5a9..db94e8a7a2b52a660cda549b89de809e0541435d 100644 GIT binary patch delta 1936 zcmV;B2XFYq5y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C3cCOrtQ2sY(@P+^BFga2d6XtH)|KhWyD-G2A)$;NTu8?VR zWxZTK*bN0W2nZ|6GXUn%zvIZ+a|Y@FpTTx5<}y$Im)__f)S~46d)1lG@fm;X1^Zw3 z*I(2U2zmbHzdbJyh?p+GHlMHl>?Jb!3HpC( z>VN1ZhyQ6{*xk1Gm7PrWoHawe`jE%eW(w)s_HN$^FfO5odqby8ryM4C$kVuel~Bag z0Ouoed=Kejc)0PvL^h8fhr{Ct>GdA>H9I7%UQZ1nhkj_tbjuyLvC}tm8XZF+)4;+T xZW6Q8bH4qi!F2MORRRv{_Vriaefa`=`9BY~N`E|@qf-C?002ovPDHLkV1hhANR0ph diff --git a/textures/hyperloop_waypoint.png b/textures/hyperloop_waypoint.png new file mode 100644 index 0000000000000000000000000000000000000000..6d8bf47b18abb9e5b7e38895fbd07186ec276770 GIT binary patch literal 615 zcmV-t0+{`YP)Px#32;bRa{vGf6951U69E94oEQKA0Ps*uR7KL)+jV$* zaCCNmf`v^_P=}0U}a~I zla**}ZgP2isH&`xl9Y6Le1wRLdVGF&e1CFvcYA+;ot>VCi;keeKaB_{2 zlyZ1`d3}IjWoBPwW{;4Pou8s`b$N}Cl81|rlb4!^ij91Je{ytnhKh}fjgWPAc#Myd zNlQ$2d3&Iwri_h`bar`*jgE?nj7?5YQBqS-QBzb_S5#J3Pf=1%P*Je7xJpe;OHEEq zP*GJ^SVu`pLPSMKN=rydN>Ni(NlQ&kO;0_YbdCT30RTxvK~y-)-ILi;0x=LpFGB!_ zA#r0@Sp-p#T^!kF0Ko-Z`2WAbs-}y?2OfB&^K$B>>ZX(G0NaX%uWL_%=a;Y@uy2y* zLHsZ0?D8rUx^Fx_+})-xPNO)kiUs$*!{2VoCQM1+m%fy8BIRs0Wox65B`kbKPIgPM z&7zejYRU)*6p0HwD!k|Jpc-0fW*;X*D5)S7^4{WO#)d@#JPjK1RVYRoX z83{jZ+ZcBV$40`MZ5RCxVSl10D7GE+nuI;$7E`uOl#7IABf(=^L@q;^GkSPun?WK@ zm=NMasbAN1zm`h9v5mut?we{yo9@L?O!uL`djsk>B5ZQULGAzm002ovPDHLkV1h4} B1~&iz literal 0 HcmV?d00001 diff --git a/textures/hyperloop_waypoint_inv.png b/textures/hyperloop_waypoint_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..153730ea7c3c38bd6a3ee4e52f6dff1418e4248f GIT binary patch literal 499 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstUx|vage(c z!@6@aFM%A+0*}aI1_o|n5N2eUHAey{_$t6B#I=-Dz}L?|Feo@6Fxbn-*VEglcf#b? zmpy#_0|Ekr+I#v#!oows!n*q=mR3|3l#~IL`UM2mH#QYj*3>k%)Hk*EPo6q&;gX_? zs=0ILO`bMAAvJx<^jRg9H5oa1UcSB^z5P`+b>%hnMHSU89o@YXr%aeMWyPvB-oAe2 zmDTYnX$7T~?cM$D-F=g%&nhY{U%hT)LTZ}3r&o1-LupxsZ$MyPL6L`-cTq{{-1&)t9yF;eSH19 zd;0=|LrTgjg?8I70{VKAr;B5V#O2VlNBIsLFfa!!_r0~mA`J+h{r&&`%?=m4$f`|( z<-boaF0b9umfrJvrbd?2" - 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, +})