From 314c32e946742abdab7e6d2c12381f3c2f074adc Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Mon, 27 May 2019 21:12:17 +0200 Subject: [PATCH] explorer improved --- basis/firebox_lib.lua | 3 +- {basic_machines => basis}/mark.lua | 8 +- init.lua | 2 +- nodes/baborium.lua | 8 +- oil/explore.lua | 195 ++++++++++++--------- oil/storage.lua | 68 ------- textures/techage_appl_oilexplorer_top.png | Bin 178 -> 182 bytes textures/techage_appl_oilexplorer_top4.png | Bin 363 -> 393 bytes 8 files changed, 124 insertions(+), 160 deletions(-) rename {basic_machines => basis}/mark.lua (90%) delete mode 100644 oil/storage.lua diff --git a/basis/firebox_lib.lua b/basis/firebox_lib.lua index d41e203..b1088e1 100644 --- a/basis/firebox_lib.lua +++ b/basis/firebox_lib.lua @@ -22,12 +22,13 @@ local I,_ = dofile(MP.."/intllib.lua") techage.firebox = {} -local BURN_TIME_FACTOR = 2 +local BURN_TIME_FACTOR = 1 techage.firebox.Burntime = { ["techage:charcoal"] = true, -- will be replaced by burntime ["default:coal_lump"] = true, ["default:coalblock"] = true, + ["techage:oil_source"] = true } local function determine_burntimes() diff --git a/basic_machines/mark.lua b/basis/mark.lua similarity index 90% rename from basic_machines/mark.lua rename to basis/mark.lua index 185cdeb..bcb4d6b 100644 --- a/basic_machines/mark.lua +++ b/basis/mark.lua @@ -38,7 +38,8 @@ function techage.mark_region(name, pos1, pos2) if marker ~= nil then marker:set_properties({ visual_size={x=sizex * 2, y=sizey * 2}, - collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness}, + --collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness}, + collisionbox = {0,0,0, 0,0,0}, }) marker:get_luaentity().player_name = name table.insert(markers, marker) @@ -51,7 +52,8 @@ function techage.mark_region(name, pos1, pos2) if marker ~= nil then marker:set_properties({ visual_size={x=sizez * 2, y=sizey * 2}, - collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez}, + --collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez}, + collisionbox = {0,0,0, 0,0,0}, }) marker:setyaw(math.pi / 2) marker:get_luaentity().player_name = name @@ -73,10 +75,8 @@ end minetest.register_entity(":techage:region_cube", { initial_properties = { visual = "upright_sprite", - visual_size = {x=1.1, y=1.1}, textures = {"techage_cube_mark.png"}, use_texture_alpha = true, - visual_size = {x=10, y=10}, physical = false, }, on_step = function(self, dtime) diff --git a/init.lua b/init.lua index f12860c..1ff10cb 100644 --- a/init.lua +++ b/init.lua @@ -31,6 +31,7 @@ else dofile(MP.."/basis/command.lua") -- tubelib replacement dofile(MP.."/basis/consumer.lua") -- consumer base model dofile(MP.."/basis/firebox_lib.lua") -- common firebox functions + dofile(MP.."/basis/mark.lua") -- Overrides dofile(MP.."/overrides/signs_bot.lua") @@ -89,7 +90,6 @@ else dofile(MP.."/basic_machines/gravelrinser.lua") dofile(MP.."/basic_machines/chest.lua") dofile(MP.."/basic_machines/autocrafter.lua") - dofile(MP.."/basic_machines/mark.lua") dofile(MP.."/basic_machines/forceload.lua") dofile(MP.."/basic_machines/electronic_fab.lua") if techage.basalt_stone_enabled then diff --git a/nodes/baborium.lua b/nodes/baborium.lua index 084ec84..d0b7071 100644 --- a/nodes/baborium.lua +++ b/nodes/baborium.lua @@ -30,8 +30,6 @@ minetest.register_craftitem("techage:baborium_ingot", { inventory_image = "techage_baborium_ingot.png", }) - - minetest.register_ore({ ore_type = "scatter", ore = "techage:stone_with_baborium", @@ -43,3 +41,9 @@ minetest.register_ore({ y_max = -260, }) +minetest.register_craft({ + type = 'cooking', + output = 'techage:baborium_ingot', + recipe = 'techage:baborium_lump', + cooktime = 5, +}) diff --git a/oil/explore.lua b/oil/explore.lua index 1d400bd..76afa07 100644 --- a/oil/explore.lua +++ b/oil/explore.lua @@ -8,27 +8,18 @@ local MP = minetest.get_modpath("techage") local I,IS = dofile(MP.."/intllib.lua") -local PROBABILITY = 2 -local OIL_MIN = 1000 -local OIL_MAX = 20000 -local DEPTH_MIN = (16 * 7) - 8 -local DEPTH_MAX = (16 * 60) - 8 +local PROBABILITY = 10 +local OIL_MIN = 500 +local OIL_MAX = 10000 +local DEPTH_MIN = 8 +local DEPTH_MAX = (16 * 25) + 8 +local DEPTH_STEP = 96 -local seed = 1234 - -local function get_node_name(pos) - local node = minetest.get_node_or_nil(pos) - if node then - return node.name - end - local vm = minetest.get_voxel_manip() - local MinEdge, MaxEdge = vm:read_from_map(pos, pos) - local data = vm:get_data() - local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge}) - local idx = area:index(pos.x, pos.y, pos.z) - return minetest.get_name_from_content_id(data[idx]) -end +local seed = 1234 -- confidental! +local InvalidGroundNodes = { + "air", +} local function oil_amount(pos) local block_key = seed + @@ -49,10 +40,6 @@ local function center(coord) return (math.floor(coord/16) * 16) + 8 end -local Invalid = { - "air", -} - local function gen_oil_slice(pos1, posc, y, radius, data, id) local y_offs = (y - pos1.y) * 16 for x = posc.x - radius, posc.x + radius do @@ -66,6 +53,7 @@ end local function gen_oil_bubble(pos1, posC, amount, data) local id = minetest.get_content_id("techage:oil_source") + --local id = minetest.get_content_id("air") local radius = math.floor(math.pow(amount, 1.0/3) / 2) local sum = 0 for y = posC.y - radius, posC.y + radius do @@ -81,7 +69,7 @@ local function useable_stone_block(data) if not valid[id] then local itemname = minetest.get_name_from_content_id(id) local ndef = minetest.registered_nodes[itemname] - if not ndef or not ndef.is_ground_content or Invalid[itemname] then + if not ndef or not ndef.is_ground_content or InvalidGroundNodes[itemname] then return false end valid[id] = true @@ -90,77 +78,100 @@ local function useable_stone_block(data) return true end -local function explore_area(posS, depth, amount, player_name, pos1, pos2, posC) - if amount > 0 and M(posS):get_int("oil_amount") == 0 then - local vm = minetest.get_voxel_manip(pos1, pos2) - local data = vm:get_data() - - if useable_stone_block(data) then - gen_oil_bubble(pos1, posC, amount/10, data) - vm:set_data(data) - vm:write_to_map() - vm:update_map() - print("explore_area", S(pos1), S(pos2)) - else - amount = 0 - end - end - M(posS):set_int("oil_amount", amount) - minetest.chat_send_player(player_name, "[TA Oil] depth: "..tostring(depth).. - ", Oil: "..tostring(amount).." ") -end - local function get_next_depth(pos) local meta = M(pos) - local name = get_node_name(pos) - local depth = DEPTH_MIN - if name == "techage:oilstorage" then - if meta:get_int("oil_amount") == 0 then - depth = M(pos):get_int("exploration_depth") + 32 - else - depth = M(pos):get_int("exploration_depth") - end - else - minetest.set_node(pos, {name = "techage:oilstorage"}) + local depth = meta:get_int("exploration_depth") + if depth == 0 then + depth = DEPTH_MIN + end + if depth + DEPTH_STEP < DEPTH_MAX then + depth = depth + DEPTH_STEP + meta:set_int("exploration_depth", depth) end - M(pos):set_int("exploration_depth", depth) return depth end -local function emerge_area(pos, node, player_name) - node.name = "techage:oilexplorer_on" - minetest.swap_node(pos, node) - minetest.get_node_timer(pos):start(2.2) +local function get_oil_amount(pos) + return M(pos):get_int("oil_amount") +end + +local function set_oil_amount(pos, amount) + minetest.set_node(pos, {name = "techage:oilstorage"}) + return M(pos):set_int("oil_amount", amount) +end + +local function status(pos, player_name, depth, amount) + depth = depth + pos.y + local posC = {x = center(pos.x), y = pos.y, z = center(pos.z)} + minetest.chat_send_player(player_name, + "[TA Oil] "..S(posC).." depth: "..depth..", Oil: "..amount.." ") +end + +local function marker(player_name, pos) + local posC = {x = center(pos.x), y = pos.y, z = center(pos.z)} + local pos1 = {x = posC.x - 1, y = posC.y - 1, z = posC.z - 1} + local pos2 = {x = posC.x + 1, y = posC.y + 3, z = posC.z + 1} + techage.switch_region(player_name, pos1, pos2) +end + +local function explore_area(pos, pos1, pos2, posC, depth, amount, player_name) + local vm = minetest.get_voxel_manip(pos1, pos2) + local data = vm:get_data() - -- used to store the depth/amount info - local store_pos = {x = center(pos.x), y = -100, z = center(pos.z)} - local depth = get_next_depth(store_pos) - minetest.sound_play("techage_explore", { - pos = pos, - max_hear_distance = 8}) - local posC = {x = center(pos.x), y = center(pos.y-depth), z = center(pos.z)} - local amount = oil_amount(posC) - if amount > 0 then + if useable_stone_block(data) then + gen_oil_bubble(pos1, posC, amount/10, data) + vm:set_data(data) + vm:write_to_map() + vm:update_map() + print("explore_area", S(pos1), S(pos2)) + M(pos):set_int("oil_amount", amount) + M(pos):set_int("depth", depth) + set_oil_amount(posC, amount) + marker(player_name, pos) + else + amount = 0 + end + status(pos, player_name, depth, amount) +end + +local function emerge_area(pos, node, player_name) + if get_oil_amount(pos) == 0 then -- nothing found so far? + local depth = get_next_depth(pos) + local posC = {x = center(pos.x), y = center(-depth), z = center(pos.z)} local radius = 7 local pos1 = {x = posC.x - radius, y = posC.y - radius, z = posC.z - radius} local pos2 = {x = posC.x + radius, y = posC.y + radius, z = posC.z + radius} - print("emerge_area", S(pos1), S(pos2), S(posC)) - minetest.emerge_area(pos1, pos2) - minetest.after(2, explore_area, store_pos, depth, amount, player_name, pos1, pos2, posC) + local amount = oil_amount(posC) + + minetest.sound_play("techage_explore", { + pos = pos, + max_hear_distance = 8}) + + node.name = "techage:oilexplorer_on" + minetest.swap_node(pos, node) + minetest.get_node_timer(pos):start(2.2) + + if amount > 0 then + if get_oil_amount(posC) == 0 then -- not explored so far? + print("emerge_area", S(pos1), S(pos2), S(posC)) + minetest.emerge_area(pos1, pos2) + minetest.after(2, explore_area, pos, pos1, pos2, posC, depth, amount, player_name) + else + M(pos):set_int("oil_amount", amount) + M(pos):set_int("depth", depth) + minetest.after(2, status, pos, player_name, depth, amount) + minetest.after(2, marker, player_name, pos) + end + else + minetest.after(2, status, pos, player_name, depth, 0) + end else - minetest.after(2, explore_area, store_pos, depth, 0, player_name) - end + status(pos, player_name, M(pos):get_int("depth"), M(pos):get_int("oil_amount")) + marker(player_name, pos) + end end ---local function test(pos) --- local posC = {x = center(pos.x), y = center(pos.y+20), z = center(pos.z)} --- local pos1 = {x = posC.x - 8, y = posC.y - 8, z = posC.z - 8} --- local pos2 = {x = posC.x + 7, y = posC.y + 7, z = posC.z + 7} --- bubble(pos1, pos2, posC, math.random(10, 200)) ---end - -- Used as storage for already explored blocks --- Will be places -100 in the middle if a block (8,8) minetest.register_node("techage:oilstorage", { description = "TA Oil Storage", tiles = {"default_stone.png"}, @@ -196,7 +207,7 @@ minetest.register_node("techage:oilexplorer_on", { type = "vertical_frames", aspect_w = 32, aspect_h = 32, - length = 1.0, + length = 1.2, }, }, "techage_filling_ta3.png^techage_frame_ta3.png", @@ -209,8 +220,9 @@ minetest.register_node("techage:oilexplorer_on", { minetest.swap_node(pos, node) end, + diggable = false, is_ground_content = false, - groups = {snappy=2,cracky=2,oddly_breakable_by_hand=2}, + groups = {not_in_creative_inventory=1}, sounds = default.node_sound_wood_defaults(), }) @@ -301,4 +313,19 @@ minetest.register_node("techage:oil_flowing", { liquid_range = 10, post_effect_color = {a = 200, r = 1, g = 1, b = 1}, groups = {liquid = 5, not_in_creative_inventory = 1}, -}) \ No newline at end of file +}) + +minetest.register_craft({ + type = "fuel", + recipe = "techage:oil_source", + burntime = 40, +}) + +minetest.register_craft({ + output = "techage:oilexplorer", + recipe = { + {"group:wood", "default:diamond", "group:wood"}, + {"techage:baborium_ingot", "basic_materials:gear_steel", "techage:usmium_nuggets"}, + {"group:wood", "techage:vacuum_tube", "group:wood"}, + }, +}) diff --git a/oil/storage.lua b/oil/storage.lua deleted file mode 100644 index 34f81f5..0000000 --- a/oil/storage.lua +++ /dev/null @@ -1,68 +0,0 @@ -local S = function(pos) if pos then return minetest.pos_to_string(pos) end end -local DAYS_VALID = (30 * 72) -- 30 real days - -local storage = minetest.get_mod_storage() - -local function data_maintenance() - minetest.log("info", "[MOD] minecart maintenance") - local day_count = minetest.get_day_count() - local tbl = storage:to_table() - for key,s in pairs(tbl.fields) do - local route = minetest.deserialize(s) - if not route.waypoints or not route.best_before or route.best_before < day_count then - storage:set_string(key, "") - else - minetest.log("info", "[minecart] Route: start="..key.." length="..#(route.waypoints)) - end - end -end -minetest.after(1, data_maintenance) - - --- Store data of running carts -minecart.CartsOnRail = {} - -for key,val in pairs(minetest.deserialize(storage:get_string("CartsOnRail")) or {}) do - -- use invalid keys to force the cart spawning - minecart.CartsOnRail[-key] = val -end - -minetest.register_on_shutdown(function() - data_maintenance() - storage:set_string("CartsOnRail", minetest.serialize(minecart.CartsOnRail)) -end) - --- All positions as "pos_to_string" string ---Routes = { --- start_pos = { --- waypoints = {{spos, svel}, {spos, svel}, ...}, --- dest_pos = spos, --- junctions = { --- {spos = num}, --- {spos = num}, --- }, --- best_before = num --- }, --- start_pos = {...}, ---} -local Routes = {} -local NEW_ROUTE = {waypoints = {}, junctions = {}} - -function minecart.store_route(key, route) - Routes[key] = table.copy(route) - Routes[key].best_before = minetest.get_day_count() + DAYS_VALID - storage:set_string(key, minetest.serialize(Routes[key])) -end - -function minecart.get_route(key) - Routes[key] = Routes[key] or minetest.deserialize(storage:get_string(key)) or NEW_ROUTE - Routes[key].best_before = minetest.get_day_count() + DAYS_VALID - return Routes[key] -end - -function minecart.del_route(key) - Routes[key] = nil -- remove from memory - storage:set_string(key, "") -- and from storage -end - - diff --git a/textures/techage_appl_oilexplorer_top.png b/textures/techage_appl_oilexplorer_top.png index 12136bea49e020f09a4e430f889fb50279cda491..f456624e24c6d006c5391081f0233c928089dabe 100644 GIT binary patch delta 106 zcmdnQxQ%f_aI&liR_lFD&49=b|jv*0;lM^IZ7bl4HG)?4_;5_kv`BqzAj$&`9xyO0ienY;UMhW^0SG)@{an^L HB{Ts54)Z1E delta 102 zcmdnSxQTH>aJ-a=IcosZ5&;GV276Bz$B>A_$q5pyixWh8ngR_jF)9mY{kwdLPb|sj z#F>?|0Q>-c0000#u#?hkN*O+zppdrdxA+0dbE!Npz6|jL z008&_`~Uy|emG!zeqgnNVzbW|h(Y*Ua(`}WAG*2S-(ORnuX`2X2LJ%@18-1+s9t>0 RwI=`o002ovPDHLkV1lxBlL7z$ delta 289 zcmV++0p9+J1M32iQ-2y23JgN@K0N>c0QgBnK~#9!?c3oBgCG=!;Zy8p4R66;-9og> zb-#)TwNum0?0sOk*htBS`Ek~Xh!+6BlXZ&k_>z6RG-oi@t?%b)lp%4v^`6GVbN9I} z<*exJs{!mgh;?{%Ajx~cSm(XSsh6?NYwjQQ6&S2r=Q`AeK7Y?T1>1q7j&Juf1OQa= zNcPw5dCwdG0E^M>@&U~*dfBcO$p@D0_r7g