From 395089dfd83a797ef408a28a8087276b8845bd3d Mon Sep 17 00:00:00 2001 From: Fixer Date: Sun, 15 Jul 2018 13:27:52 +0300 Subject: [PATCH 1/9] Wrench: Allow picking up with protection_bypass privilege (#393) This allows admins to move other players locked chests/etc without hassle (relocating flying chests). --- wrench/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrench/init.lua b/wrench/init.lua index bae77aa..adb80c9 100644 --- a/wrench/init.lua +++ b/wrench/init.lua @@ -120,7 +120,7 @@ minetest.register_tool("wrench:wrench", { return end local meta = minetest.get_meta(pos) - if def.owned then + if def.owned and not minetest.check_player_privs(placer, "protection_bypass") then local owner = meta:get_string("owner") if owner and owner ~= player_name then minetest.log("action", player_name.. From 68fac3ed7b28d05d71f26a8dcd1be49ba376afaf Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 15 Jul 2018 13:28:34 +0300 Subject: [PATCH 2/9] Fix wooden chest formspec (#429) --- technic_chests/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/technic_chests/init.lua b/technic_chests/init.lua index 3565987..6b1a1b2 100644 --- a/technic_chests/init.lua +++ b/technic_chests/init.lua @@ -15,3 +15,11 @@ dofile(modpath.."/silver_chest.lua") dofile(modpath.."/gold_chest.lua") dofile(modpath.."/mithril_chest.lua") +minetest.register_lbm({ + name = "technic_chests:fix_wooden_chests", + nodenames = {"default:chest"}, + action = function(pos, node) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "") + end +}) From 0fcc7a14c2d60e22d41b66b9008119171aff1681 Mon Sep 17 00:00:00 2001 From: Thomas--S Date: Mon, 16 Jul 2018 17:25:43 +0200 Subject: [PATCH 3/9] Replace old nodeupdate() with new minetest.check_for_falling() (#391) --- technic/machines/other/constructor.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/technic/machines/other/constructor.lua b/technic/machines/other/constructor.lua index 5847fdb..0a62a7c 100644 --- a/technic/machines/other/constructor.lua +++ b/technic/machines/other/constructor.lua @@ -99,7 +99,7 @@ local function make_on(mark, length) if node.name == "technic:constructor_mk"..mark.."_off" then technic.swap_node(pos, "technic:constructor_mk"..mark.."_on") - nodeupdate(pos) + minetest.check_for_falling(pos) for i = 1, length do place_pos = vector.add(place_pos, dir) local place_node = minetest.get_node(place_pos) @@ -113,7 +113,7 @@ local function make_off(mark) return function(pos, node) if node.name == "technic:constructor_mk"..mark.."_on" then technic.swap_node(pos,"technic:constructor_mk"..mark.."_off") - nodeupdate(pos) + minetest.check_for_falling(pos) end end end From 6af0376c23e000b7e2cd4db2659ff5d632c4e60b Mon Sep 17 00:00:00 2001 From: HybridDog Date: Mon, 16 Jul 2018 17:25:53 +0200 Subject: [PATCH 4/9] Use a:iter instead of for loops for sulfur generation (#423) --- technic_worldgen/oregen.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/technic_worldgen/oregen.lua b/technic_worldgen/oregen.lua index 8e7af91..16a3b8d 100644 --- a/technic_worldgen/oregen.lua +++ b/technic_worldgen/oregen.lua @@ -141,17 +141,20 @@ minetest.register_on_generated(function(minp, maxp, seed) for y = minp.y + math.floor(grid_size / 2), maxp.y, grid_size do for z = minp.z + math.floor(grid_size / 2), maxp.z, grid_size do local c = data[a:index(x, y, z)] - if (c == c_lava or c == c_lava_flowing) and sulfur_noise:get3d({x = x, y = z, z = z}) >= 0.4 then - for xx = math.max(minp.x, x - grid_size), math.min(maxp.x, x + grid_size) do - for yy = math.max(minp.y, y - grid_size), math.min(maxp.y, y + grid_size) do - for zz = math.max(minp.z, z - grid_size), math.min(maxp.z, z + grid_size) do - local i = a:index(xx, yy, zz) + if (c == c_lava or c == c_lava_flowing) + and sulfur_noise:get3d({x = x, y = z, z = z}) >= 0.4 then + for i in a:iter( + math.max(minp.x, x - grid_size), + math.max(minp.y, y - grid_size), + math.max(minp.z, z - grid_size), + math.min(maxp.x, x + grid_size), + math.min(maxp.y, y + grid_size), + math.min(maxp.z, z + grid_size) + ) do if data[i] == c_stone and pr:next(1, 10) <= 7 then data[i] = c_sulfur end end - end - end end end end From 41f175986d18ef9cf697b95e4570555471068857 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Mon, 16 Jul 2018 17:26:39 +0200 Subject: [PATCH 5/9] Show EU power values more readable (#424) Add the EU_string helper function In comparison to pretty_num it uses SI prefixes, adds "EU" (e.g. kEU) and rounds the number for readability Add a constant_digit_count boolean setting --- technic/doc/api.md | 7 ++- technic/helpers.lua | 65 +++++++++++++++++------ technic/machines/LV/solar_panel.lua | 5 +- technic/machines/MV/wind_mill.lua | 3 +- technic/machines/power_monitor.lua | 2 +- technic/machines/register/battery_box.lua | 5 +- technic/machines/register/solar_array.lua | 5 +- technic/machines/supply_converter.lua | 4 +- technic/machines/switching_station.lua | 6 +-- 9 files changed, 72 insertions(+), 30 deletions(-) diff --git a/technic/doc/api.md b/technic/doc/api.md index 2e5b6d3..178ab0a 100644 --- a/technic/doc/api.md +++ b/technic/doc/api.md @@ -11,9 +11,12 @@ switching station handles the network activity. Helper functions ---------------- +* `technic.EU_string(num)` + * Converts num to a human-readable string (see pretty_num) + and adds the `EU` unit + * Use this function when showing players energy values * `technic.pretty_num(num)` - * Converts the number `num` to a human-readable string. - * Use this function when showing players power values. + * Converts the number `num` to a human-readable string with SI prefixes * `technic.swap_node(pos, nodename)` * Same as `mintest.swap_node` but it only changes the nodename. * It uses `minetest.get_node` before swapping to ensure the new nodename diff --git a/technic/helpers.lua b/technic/helpers.lua index 5780f27..5963b68 100644 --- a/technic/helpers.lua +++ b/technic/helpers.lua @@ -1,23 +1,56 @@ -local digit_sep_esc -do - local sep = technic.config:get("digit_separator") - sep = tonumber(sep) and string.char(sep) or sep or " " - -- Escape for gsub - for magic in ("().%+-*?[^$"):gmatch(".") do - if sep == magic then - sep = "%"..sep - end +local constant_digit_count = technic.config:get("constant_digit_count") + +-- converts a number to a readable string with SI prefix, e.g. 10000 → "10 k", +-- 15 → "15 ", 0.1501 → "150.1 m" +-- a non-breaking space (U+a0) instead of a usual one is put after number +-- The precision is 4 digits +local prefixes = {[-8] = "y", [-7] = "z", [-6] = "a", [-5] = "f", [-4] = "p", + [-3] = "n", [-2] = "µ", [-1] = "m", [0] = "", [1] = "k", [2] = "M", + [3] = "G", [4] = "T", [5] = "P", [6] = "E", [7] = "Z", [8] = "Y"} +function technic.pretty_num(num) + -- the small number added is due to floating point inaccuracy + local b = math.floor(math.log10(math.abs(num)) +0.000001) + local pref_i + if b ~= 0 then + -- b is decremented by 1 to avoid a single digit with many decimals, + -- e.g. instead of 1.021 MEU, 1021 kEU is shown + pref_i = math.floor((b - 1) / 3) + else + -- as special case, avoid showing e.g. 1100 mEU instead of 1.1 EU + pref_i = 0 end - digit_sep_esc = sep + if not prefixes[pref_i] then + -- This happens for 0, nan, inf, very big values, etc. + if num == 0 then + -- handle 0 explicilty to avoid showing "-0" + if not constant_digit_count then + return "0 " + end + -- gives 0.000 + return string.format("%.3f ", 0) + end + return string.format("%.4g ", num) + end + + num = num * 10 ^ (-3 * pref_i) + if constant_digit_count then + local comma_digits_cnt = 3 - (b - 3 * pref_i) + return string.format("%." .. comma_digits_cnt .. "f %s", + num, prefixes[pref_i]) + end + return string.format("%.4g %s", num, prefixes[pref_i]) end +-- some unittests +assert(technic.pretty_num(-0) == "0 ") +assert(technic.pretty_num(0) == "0 ") +assert(technic.pretty_num(1234) == "1234 ") +assert(technic.pretty_num(123456789) == "123.5 M") -function technic.pretty_num(num) - local str, k = tostring(num), nil - repeat - str, k = str:gsub("^(-?%d+)(%d%d%d)", "%1"..digit_sep_esc.."%2") - until k == 0 - return str + +-- used to display power values +function technic.EU_string(num) + return technic.pretty_num(num) .. "EU" end diff --git a/technic/machines/LV/solar_panel.lua b/technic/machines/LV/solar_panel.lua index a06ddb8..c072b13 100644 --- a/technic/machines/LV/solar_panel.lua +++ b/technic/machines/LV/solar_panel.lua @@ -35,7 +35,8 @@ local run = function(pos, node) local charge_to_give = math.floor((light + pos1.y) * 3) charge_to_give = math.max(charge_to_give, 0) charge_to_give = math.min(charge_to_give, 200) - meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.pretty_num(charge_to_give))) + meta:set_string("infotext", S("@1 Active (@2)", machine_name, + technic.EU_string(charge_to_give))) meta:set_int("LV_EU_supply", charge_to_give) else meta:set_string("infotext", S("%s Idle"):format(machine_name)) @@ -54,7 +55,7 @@ minetest.register_node("technic:solar_panel", { active = false, drawtype = "nodebox", paramtype = "light", - is_ground_content = true, + is_ground_content = true, node_box = { type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, diff --git a/technic/machines/MV/wind_mill.lua b/technic/machines/MV/wind_mill.lua index 28a075d..9df12b9 100644 --- a/technic/machines/MV/wind_mill.lua +++ b/technic/machines/MV/wind_mill.lua @@ -60,7 +60,8 @@ local run = function(pos, node) elseif check == true then local power = math.min(pos.y * 100, 5000) meta:set_int("MV_EU_supply", power) - meta:set_string("infotext", S("@1 (@2 EU)", machine_name, technic.pretty_num(power))) + meta:set_string("infotext", S("@1 (@2)", machine_name, + technic.EU_string(power))) end -- check == nil: assume nothing has changed end diff --git a/technic/machines/power_monitor.lua b/technic/machines/power_monitor.lua index 4d722a2..7e8b850 100644 --- a/technic/machines/power_monitor.lua +++ b/technic/machines/power_monitor.lua @@ -55,7 +55,7 @@ minetest.register_abm({ local demand = sw_meta:get_int("demand") meta:set_string("infotext", S("Power Monitor. Supply: @1 Demand: @2", - technic.pretty_num(supply), technic.pretty_num(demand))) + technic.EU_string(supply), technic.EU_string(demand))) else meta:set_string("infotext",S("Power Monitor Has No Network")) end diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua index 84e992c..7f25dfd 100644 --- a/technic/machines/register/battery_box.lua +++ b/technic/machines/register/battery_box.lua @@ -255,8 +255,9 @@ function technic.register_battery_box(data) local charge_percent = math.floor(current_charge / max_charge * 100) meta:set_string("formspec", formspec..add_on_off_buttons(meta, ltier, charge_percent)) - local infotext = S("@1 Battery Box: @2/@3", tier, - technic.pretty_num(current_charge), technic.pretty_num(max_charge)) + local infotext = S("@1 Battery Box: @2 / @3", tier, + technic.EU_string(current_charge), + technic.EU_string(max_charge)) if eu_input == 0 then infotext = S("%s Idle"):format(infotext) end diff --git a/technic/machines/register/solar_array.lua b/technic/machines/register/solar_array.lua index 422bfcf..03f11d9 100644 --- a/technic/machines/register/solar_array.lua +++ b/technic/machines/register/solar_array.lua @@ -30,14 +30,15 @@ function technic.register_solar_array(data) local charge_to_give = math.floor((light + pos.y) * data.power) charge_to_give = math.max(charge_to_give, 0) charge_to_give = math.min(charge_to_give, data.power * 50) - meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.pretty_num(charge_to_give))) + meta:set_string("infotext", S("@1 Active (@2)", machine_name, + technic.EU_string(charge_to_give))) meta:set_int(tier.."_EU_supply", charge_to_give) else meta:set_string("infotext", S("%s Idle"):format(machine_name)) meta:set_int(tier.."_EU_supply", 0) end end - + minetest.register_node("technic:solar_array_"..ltier, { tiles = {"technic_"..ltier.."_solar_array_top.png", "technic_"..ltier.."_solar_array_bottom.png", "technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png", diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua index 8527bcf..9202c4a 100644 --- a/technic/machines/supply_converter.lua +++ b/technic/machines/supply_converter.lua @@ -149,7 +149,9 @@ local run = function(pos, node, run_stage) meta:set_int(from.."_EU_supply", 0) meta:set_int(to.."_EU_demand", 0) meta:set_int(to.."_EU_supply", input * remain) - meta:set_string("infotext", S("@1 (@2 @3 -> @4 @5)", machine_name, technic.pretty_num(input), from, technic.pretty_num(input * remain), to)) + meta:set_string("infotext", S("@1 (@2 @3 -> @4 @5)", machine_name, + technic.EU_string(input), from, + technic.EU_string(input * remain), to)) else meta:set_string("infotext", S("%s Has Bad Cabling"):format(machine_name)) if to then diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index 21d394b..d645847 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -361,9 +361,9 @@ minetest.register_abm({ end --dprint("Total BA demand:"..BA_eu_demand) - meta:set_string("infotext", - S("@1. Supply: @2 Demand: @3", - machine_name, technic.pretty_num(PR_eu_supply), technic.pretty_num(RE_eu_demand))) + meta:set_string("infotext", S("@1. Supply: @2 Demand: @3", + machine_name, technic.EU_string(PR_eu_supply), + technic.EU_string(RE_eu_demand))) -- If mesecon signal and power supply or demand changed then -- send them via digilines. From fb93388f06fe87ee75aaaf04cf6edcf01a26d981 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Thu, 19 Jul 2018 14:36:21 +0200 Subject: [PATCH 6/9] Replace deprecated invsize[] with size[] --- technic/machines/LV/cnc.lua | 2 +- technic/machines/MV/tool_workshop.lua | 2 +- technic/machines/other/injector.lua | 2 +- technic/machines/register/generator.lua | 2 +- technic/machines/register/machine_base.lua | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/technic/machines/LV/cnc.lua b/technic/machines/LV/cnc.lua index 58ec6ba..fdfec99 100644 --- a/technic/machines/LV/cnc.lua +++ b/technic/machines/LV/cnc.lua @@ -48,7 +48,7 @@ local twosize_products = { } local cnc_formspec = - "invsize[9,11;]".. + "size[9,11;]".. "label[1,0;"..S("Choose Milling Program:").."]".. "image_button[1,0.5;1,1;technic_cnc_slope.png;slope; ]".. "image_button[2,0.5;1,1;technic_cnc_slope_edge.png;slope_edge; ]".. diff --git a/technic/machines/MV/tool_workshop.lua b/technic/machines/MV/tool_workshop.lua index 6679d1d..a220ac0 100644 --- a/technic/machines/MV/tool_workshop.lua +++ b/technic/machines/MV/tool_workshop.lua @@ -19,7 +19,7 @@ minetest.register_craft({ local workshop_demand = {5000, 3500, 2000} local workshop_formspec = - "invsize[8,9;]".. + "size[8,9;]".. "list[current_name;src;3,1;1,1;]".. "label[0,0;"..S("%s Tool Workshop"):format("MV").."]".. "list[current_name;upgrade1;1,3;1,1;]".. diff --git a/technic/machines/other/injector.lua b/technic/machines/other/injector.lua index b34dd79..4fe78b2 100644 --- a/technic/machines/other/injector.lua +++ b/technic/machines/other/injector.lua @@ -55,7 +55,7 @@ minetest.register_craft({ local function set_injector_formspec(meta) local is_stack = meta:get_string("mode") == "whole stacks" meta:set_string("formspec", - "invsize[8,9;]".. + "size[8,9;]".. "item_image[0,0;1,1;technic:injector]".. "label[1,0;"..S("Self-Contained Injector").."]".. (is_stack and diff --git a/technic/machines/register/generator.lua b/technic/machines/register/generator.lua index 7805bf0..87ef6e7 100644 --- a/technic/machines/register/generator.lua +++ b/technic/machines/register/generator.lua @@ -35,7 +35,7 @@ function technic.register_generator(data) for k, v in pairs(groups) do active_groups[k] = v end local generator_formspec = - "invsize[8,9;]".. + "size[8,9;]".. "label[0,0;"..S("Fuel-Fired %s Generator"):format(tier).."]".. "list[current_name;src;3,1;1,1;]".. "image[4,1;1,1;default_furnace_fire_bg.png]".. diff --git a/technic/machines/register/machine_base.lua b/technic/machines/register/machine_base.lua index 0c6a6b3..14cf998 100644 --- a/technic/machines/register/machine_base.lua +++ b/technic/machines/register/machine_base.lua @@ -44,7 +44,7 @@ function technic.register_base_machine(data) for k, v in pairs(groups) do active_groups[k] = v end local formspec = - "invsize[8,9;]".. + "size[8,9;]".. "list[current_name;src;"..(4-input_size)..",1;"..input_size..",1;]".. "list[current_name;dst;5,1;2,2;]".. "list[current_player;main;0,5;8,4;]".. From 80c6a14566e5688bbfd06dbffb984143cbf53fe1 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Sat, 21 Jul 2018 19:09:27 +0200 Subject: [PATCH 7/9] Tidy up ore registrations (#422) --- technic_worldgen/oregen.lua | 252 ++++++++++++++++++++---------------- 1 file changed, 141 insertions(+), 111 deletions(-) diff --git a/technic_worldgen/oregen.lua b/technic_worldgen/oregen.lua index 16a3b8d..fb7ac84 100644 --- a/technic_worldgen/oregen.lua +++ b/technic_worldgen/oregen.lua @@ -1,132 +1,157 @@ -local uranium_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 420, octaves = 3, persist = 0.7} +local uranium_params = { + offset = 0, + scale = 1, + spread = {x = 100, y = 100, z = 100}, + seed = 420, + octaves = 3, + persist = 0.7 +} local uranium_threshold = 0.55 -local chromium_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 421, octaves = 3, persist = 0.7} +local chromium_params = { + offset = 0, + scale = 1, + spread = {x = 100, y = 100, z = 100}, + seed = 421, + octaves = 3, + persist = 0.7 +} local chromium_threshold = 0.55 -local zinc_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 422, octaves = 3, persist = 0.7} +local zinc_params = { + offset = 0, + scale = 1, + spread = {x = 100, y = 100, z = 100}, + seed = 422, + octaves = 3, + persist = 0.7 +} local zinc_threshold = 0.5 -local lead_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 423, octaves = 3, persist = 0.7} +local lead_params = { + offset = 0, + scale = 1, + spread = {x = 100, y = 100, z = 100}, + seed = 423, + octaves = 3, + persist = 0.7 +} local lead_threshold = 0.3 minetest.register_ore({ - ore_type = "scatter", - ore = "technic:mineral_uranium", - wherein = "default:stone", - clust_scarcity = 8*8*8, - clust_num_ores = 4, - clust_size = 3, - y_min = -300, - y_max = -80, - noise_params = uranium_params, + ore_type = "scatter", + ore = "technic:mineral_uranium", + wherein = "default:stone", + clust_scarcity = 8*8*8, + clust_num_ores = 4, + clust_size = 3, + y_min = -300, + y_max = -80, + noise_params = uranium_params, noise_threshold = uranium_threshold, }) minetest.register_ore({ - ore_type = "scatter", - ore = "technic:mineral_chromium", - wherein = "default:stone", - clust_scarcity = 8*8*8, - clust_num_ores = 2, - clust_size = 3, - y_min = -200, - y_max = -100, - noise_params = chromium_params, + ore_type = "scatter", + ore = "technic:mineral_chromium", + wherein = "default:stone", + clust_scarcity = 8*8*8, + clust_num_ores = 2, + clust_size = 3, + y_min = -200, + y_max = -100, + noise_params = chromium_params, noise_threshold = chromium_threshold, }) minetest.register_ore({ - ore_type = "scatter", - ore = "technic:mineral_chromium", - wherein = "default:stone", - clust_scarcity = 6*6*6, - clust_num_ores = 2, - clust_size = 3, - y_min = -31000, - y_max = -200, - flags = "absheight", - noise_params = chromium_params, + ore_type = "scatter", + ore = "technic:mineral_chromium", + wherein = "default:stone", + clust_scarcity = 6*6*6, + clust_num_ores = 2, + clust_size = 3, + y_min = -31000, + y_max = -200, + flags = "absheight", + noise_params = chromium_params, noise_threshold = chromium_threshold, }) minetest.register_ore({ - ore_type = "scatter", - ore = "technic:mineral_zinc", - wherein = "default:stone", - clust_scarcity = 8*8*8, - clust_num_ores = 5, - clust_size = 7, - y_min = -32, - y_max = 2, - noise_params = zinc_params, + ore_type = "scatter", + ore = "technic:mineral_zinc", + wherein = "default:stone", + clust_scarcity = 8*8*8, + clust_num_ores = 5, + clust_size = 7, + y_min = -32, + y_max = 2, + noise_params = zinc_params, noise_threshold = zinc_threshold, }) minetest.register_ore({ - ore_type = "scatter", - ore = "technic:mineral_zinc", - wherein = "default:stone", - clust_scarcity = 6*6*6, - clust_num_ores = 4, - clust_size = 3, - y_min = -31000, - y_max = -32, - flags = "absheight", - noise_params = zinc_params, + ore_type = "scatter", + ore = "technic:mineral_zinc", + wherein = "default:stone", + clust_scarcity = 6*6*6, + clust_num_ores = 4, + clust_size = 3, + y_min = -31000, + y_max = -32, + flags = "absheight", + noise_params = zinc_params, noise_threshold = zinc_threshold, }) minetest.register_ore({ - ore_type = "scatter", - ore = "technic:mineral_lead", - wherein = "default:stone", - clust_scarcity = 9*9*9, - clust_num_ores = 5, - clust_size = 3, - y_min = -16, - y_max = 16, - noise_params = lead_params, + ore_type = "scatter", + ore = "technic:mineral_lead", + wherein = "default:stone", + clust_scarcity = 9*9*9, + clust_num_ores = 5, + clust_size = 3, + y_min = -16, + y_max = 16, + noise_params = lead_params, noise_threshold = lead_threshold, }) minetest.register_ore({ - ore_type = "scatter", - ore = "technic:mineral_lead", - wherein = "default:stone", - clust_scarcity = 8*8*8, - clust_num_ores = 5, - clust_size = 3, - y_min = -128, - y_max = -16, - noise_params = lead_params, + ore_type = "scatter", + ore = "technic:mineral_lead", + wherein = "default:stone", + clust_scarcity = 8*8*8, + clust_num_ores = 5, + clust_size = 3, + y_min = -128, + y_max = -16, + noise_params = lead_params, noise_threshold = lead_threshold, }) minetest.register_ore({ - ore_type = "scatter", - ore = "technic:mineral_lead", - wherein = "default:stone", - clust_scarcity = 6*6*6, - clust_num_ores = 5, - clust_size = 3, - y_min = -31000, - y_max = -128, - flags = "absheight", - noise_params = lead_params, + ore_type = "scatter", + ore = "technic:mineral_lead", + wherein = "default:stone", + clust_scarcity = 6*6*6, + clust_num_ores = 5, + clust_size = 3, + y_min = -31000, + y_max = -128, + flags = "absheight", + noise_params = lead_params, noise_threshold = lead_threshold, }) -- Sulfur local sulfur_buf = {} -local sulfur_noise= nil +local sulfur_noise -minetest.register_on_generated(function(minp, maxp, seed) +minetest.register_on_generated(function(minp, maxp) local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") - local a = VoxelArea:new{ - MinEdge = {x = emin.x, y = emin.y, z = emin.z}, - MaxEdge = {x = emax.x, y = emax.y, z = emax.z}, - } + local a = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) local data = vm:get_data(sulfur_buf) local pr = PseudoRandom(17 * minp.x + 42 * minp.y + 101 * minp.z) sulfur_noise = sulfur_noise or minetest.get_perlin(9876, 3, 0.5, 100) @@ -142,7 +167,7 @@ minetest.register_on_generated(function(minp, maxp, seed) for z = minp.z + math.floor(grid_size / 2), maxp.z, grid_size do local c = data[a:index(x, y, z)] if (c == c_lava or c == c_lava_flowing) - and sulfur_noise:get3d({x = x, y = z, z = z}) >= 0.4 then + and sulfur_noise:get_3d({x = x, y = z, z = z}) >= 0.4 then for i in a:iter( math.max(minp.x, x - grid_size), math.max(minp.y, y - grid_size), @@ -166,32 +191,37 @@ end) if technic.config:get_bool("enable_marble_generation") then -minetest.register_ore({ - ore_type = "sheet", - ore = "technic:marble", - wherein = "default:stone", - clust_scarcity = 1, - clust_num_ores = 1, - clust_size = 3, - y_min = -31000, - y_max = -50, - noise_threshold = 0.4, - noise_params = {offset=0, scale=15, spread={x=150, y=150, z=150}, seed=23, octaves=3, persist=0.70} -}) + minetest.register_ore({ + ore_type = "sheet", + ore = "technic:marble", + wherein = "default:stone", + clust_scarcity = 1, + clust_num_ores = 1, + clust_size = 3, + y_min = -31000, + y_max = -50, + noise_threshold = 0.4, + noise_params = { + offset = 0, scale = 15, spread = {x = 150, y = 150, z = 150}, + seed = 23, octaves = 3, persist = 0.70 + } + }) end if technic.config:get_bool("enable_granite_generation") then -minetest.register_ore({ - ore_type = "sheet", - ore = "technic:granite", - wherein = "default:stone", - clust_scarcity = 1, - clust_num_ores = 1, - clust_size = 4, - y_min = -31000, - y_max = -150, - noise_threshold = 0.4, - noise_params = {offset=0, scale=15, spread={x=130, y=130, z=130}, seed=24, octaves=3, persist=0.70} -}) + minetest.register_ore({ + ore_type = "sheet", + ore = "technic:granite", + wherein = "default:stone", + clust_scarcity = 1, + clust_num_ores = 1, + clust_size = 4, + y_min = -31000, + y_max = -150, + noise_threshold = 0.4, + noise_params = { + offset = 0, scale = 15, spread = {x = 130, y = 130, z = 130}, + seed = 24, octaves = 3, persist = 0.70 + } + }) end - From f013d2dd1f76fe1e84203a81210b9a9b1987fbdd Mon Sep 17 00:00:00 2001 From: HybridDog Date: Sat, 21 Jul 2018 19:10:32 +0200 Subject: [PATCH 8/9] Mining laser fixes (#421) Do not remove air and group:hot nodes instead of using a fixed list Abort mining when encountering an unknown node Add random to the smoke puff particle Set mining laser tool range to 0 --- technic/tools/mining_lasers.lua | 84 ++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/technic/tools/mining_lasers.lua b/technic/tools/mining_lasers.lua index ef1eecb..6015e5a 100644 --- a/technic/tools/mining_lasers.lua +++ b/technic/tools/mining_lasers.lua @@ -4,43 +4,43 @@ local mining_lasers_list = { {"2", 14, 200000, 2000}, {"3", 21, 650000, 3000}, } +local allow_entire_discharging = true local S = technic.getter minetest.register_craft({ - output = 'technic:laser_mk1', + output = "technic:laser_mk1", recipe = { - {'default:diamond', 'technic:brass_ingot', 'default:obsidian_glass'}, - {'', 'technic:brass_ingot', 'technic:red_energy_crystal'}, - {'', '', 'default:copper_ingot'}, + {"default:diamond", "technic:brass_ingot", "default:obsidian_glass"}, + {"", "technic:brass_ingot", "technic:red_energy_crystal"}, + {"", "", "default:copper_ingot"}, } }) minetest.register_craft({ - output = 'technic:laser_mk2', + output = "technic:laser_mk2", recipe = { - {'default:diamond', 'technic:carbon_steel_ingot', 'technic:laser_mk1'}, - {'', 'technic:carbon_steel_ingot', 'technic:green_energy_crystal'}, - {'', '', 'default:copper_ingot'}, + {"default:diamond", "technic:carbon_steel_ingot", "technic:laser_mk1"}, + {"", "technic:carbon_steel_ingot", "technic:green_energy_crystal"}, + {"", "", "default:copper_ingot"}, } }) minetest.register_craft({ - output = 'technic:laser_mk3', + output = "technic:laser_mk3", recipe = { - {'default:diamond', 'technic:carbon_steel_ingot', 'technic:laser_mk2'}, - {'', 'technic:carbon_steel_ingot', 'technic:blue_energy_crystal'}, - {'', '', 'default:copper_ingot'}, + {"default:diamond", "technic:carbon_steel_ingot", "technic:laser_mk2"}, + {"", "technic:carbon_steel_ingot", "technic:blue_energy_crystal"}, + {"", "", "default:copper_ingot"}, } }) local function laser_node(pos, node, player) local def = minetest.registered_nodes[node.name] - if def and def.liquidtype ~= "none" then + if def.liquidtype ~= "none" and def.buildable_to then minetest.remove_node(pos) minetest.add_particle({ pos = pos, - velocity = {x=0, y=2, z=0}, - acceleration = {x=0, y=-1, z=0}, - expirationtime = 1.5, + velocity = {x = 0, y = 1.5 + math.random(), z = 0}, + acceleration = {x = 0, y = -1, z = 0}, size = 6 + math.random() * 2, texture = "smoke_puff.png^[transform" .. math.random(0, 7), }) @@ -49,11 +49,15 @@ local function laser_node(pos, node, player) minetest.node_dig(pos, node, player) end -local no_destroy = { - ["air"] = true, - ["default:lava_source"] = true, - ["default:lava_flowing"] = true, -} +local keep_node = {air = true} +local function can_keep_node(name) + if keep_node[name] ~= nil then + return keep_node[name] + end + keep_node[name] = minetest.get_item_group(name, "hot") ~= 0 + return keep_node[name] +end + local function laser_shoot(player, range, particle_texture, sound) local player_pos = player:getpos() local player_name = player:get_player_name() @@ -61,12 +65,12 @@ local function laser_shoot(player, range, particle_texture, sound) local start_pos = vector.new(player_pos) -- Adjust to head height - start_pos.y = start_pos.y + 1.6 + start_pos.y = start_pos.y + (player:get_properties().eye_height or 1.625) minetest.add_particle({ - pos = startpos, + pos = start_pos, velocity = dir, acceleration = vector.multiply(dir, 50), - expirationtime = range / 11, + expirationtime = (math.sqrt(1 + 100 * (range + 0.4)) - 1) / 50, size = 1, texture = particle_texture .. "^[transform" .. math.random(0, 7), }) @@ -76,42 +80,48 @@ local function laser_shoot(player, range, particle_texture, sound) minetest.record_protection_violation(pos, player_name) break end - local node = minetest.get_node_or_nil(pos) - if not node then + local node = minetest.get_node(pos) + if node.name == "ignore" + or not minetest.registered_nodes[node.name] then break end - if not no_destroy[node.name] then + if not can_keep_node(node.name) then laser_node(pos, node, player) end end end - for _, m in pairs(mining_lasers_list) do technic.register_power_tool("technic:laser_mk"..m[1], m[3]) minetest.register_tool("technic:laser_mk"..m[1], { description = S("Mining Laser Mk%d"):format(m[1]), inventory_image = "technic_mining_laser_mk"..m[1]..".png", + range = 0, stack_max = 1, wear_represents = "technic_RE_charge", on_refill = technic.refill_RE_charge, on_use = function(itemstack, user) local meta = minetest.deserialize(itemstack:get_metadata()) - if not meta or not meta.charge then + if not meta or not meta.charge or meta.charge == 0 then return end - -- If there's enough charge left, fire the laser - if meta.charge >= m[4] then - laser_shoot(user, m[2], "technic_laser_beam_mk"..m[1]..".png", "technic_laser_mk"..m[1]) - if not technic.creative_mode then - meta.charge = meta.charge - m[4] - technic.set_RE_wear(itemstack, meta.charge, m[3]) - itemstack:set_metadata(minetest.serialize(meta)) + local range = m[2] + if meta.charge < m[4] then + if not allow_entire_discharging then + return end + -- If charge is too low, give the laser a shorter range + range = range * meta.charge / m[4] + end + laser_shoot(user, range, "technic_laser_beam_mk" .. m[1] .. ".png", + "technic_laser_mk" .. m[1]) + if not technic.creative_mode then + meta.charge = math.max(meta.charge - m[4], 0) + technic.set_RE_wear(itemstack, meta.charge, m[3]) + itemstack:set_metadata(minetest.serialize(meta)) end return itemstack end, }) end - From d1b54a573c6287ea1d63b9c3f979c39058b1331a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sat, 21 Jul 2018 20:11:12 +0300 Subject: [PATCH 9/9] Use tin from MTG instead of `moreores` (#401) Register tin dust unconditionally --- technic/crafts.lua | 2 +- technic/machines/register/alloy_recipes.lua | 2 +- technic/machines/register/battery_box.lua | 2 +- technic/machines/register/grinder_recipes.lua | 6 +++--- technic/radiation.lua | 4 ++-- technic/tools/mining_drill.lua | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/technic/crafts.lua b/technic/crafts.lua index 14bafd3..5d3ae04 100644 --- a/technic/crafts.lua +++ b/technic/crafts.lua @@ -164,7 +164,7 @@ minetest.register_craft({ recipe = { {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'}, {'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'}, - {'moreores:tin_ingot', 'moreores:tin_ingot', 'moreores:tin_ingot'}, + {'default:tin_ingot', 'default:tin_ingot', 'default:tin_ingot'}, } }) diff --git a/technic/machines/register/alloy_recipes.lua b/technic/machines/register/alloy_recipes.lua index bd09bd6..3aeacd5 100644 --- a/technic/machines/register/alloy_recipes.lua +++ b/technic/machines/register/alloy_recipes.lua @@ -13,7 +13,7 @@ end local recipes = { {"technic:copper_dust 3", "technic:tin_dust", "technic:bronze_dust 4"}, - {"default:copper_ingot 3", "moreores:tin_ingot", "default:bronze_ingot 4"}, + {"default:copper_ingot 3", "default:tin_ingot", "default:bronze_ingot 4"}, {"technic:wrought_iron_dust", "technic:coal_dust", "technic:carbon_steel_dust", 3}, {"technic:wrought_iron_ingot", "technic:coal_dust", "technic:carbon_steel_ingot", 3}, {"technic:carbon_steel_dust", "technic:coal_dust", "technic:cast_iron_dust", 3}, diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua index 7f25dfd..d10b705 100644 --- a/technic/machines/register/battery_box.lua +++ b/technic/machines/register/battery_box.lua @@ -18,7 +18,7 @@ minetest.register_craft({ output = "technic:battery", recipe = { {"group:wood", "default:copper_ingot", "group:wood"}, - {"group:wood", "moreores:tin_ingot", "group:wood"}, + {"group:wood", "default:tin_ingot", "group:wood"}, {"group:wood", "default:copper_ingot", "group:wood"}, } }) diff --git a/technic/machines/register/grinder_recipes.lua b/technic/machines/register/grinder_recipes.lua index fa55e7a..1f4047c 100644 --- a/technic/machines/register/grinder_recipes.lua +++ b/technic/machines/register/grinder_recipes.lua @@ -15,6 +15,7 @@ local recipes = { {"default:desert_stone", "default:desert_sand"}, {"default:gold_lump", "technic:gold_dust 2"}, {"default:iron_lump", "technic:wrought_iron_dust 2"}, + {"default:tin_lump", "technic:tin_dust 2"}, {"technic:chromium_lump", "technic:chromium_dust 2"}, {"technic:uranium_lump", "technic:uranium_dust 2"}, {"technic:zinc_lump", "technic:zinc_dust 2"}, @@ -43,7 +44,6 @@ end if minetest.get_modpath("moreores") then table.insert(recipes, {"moreores:mithril_lump", "technic:mithril_dust 2"}) table.insert(recipes, {"moreores:silver_lump", "technic:silver_dust 2"}) - table.insert(recipes, {"moreores:tin_lump", "technic:tin_dust 2"}) end if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then @@ -94,9 +94,9 @@ register_dust("Gold", "default:gold_ingot") register_dust("Mithril", "moreores:mithril_ingot") register_dust("Silver", "moreores:silver_ingot") register_dust("Stainless Steel", "technic:stainless_steel_ingot") -register_dust("Stone", "default:stone") +register_dust("Stone", "default:stone") register_dust("Sulfur", nil) -register_dust("Tin", "moreores:tin_ingot") +register_dust("Tin", "default:tin_ingot") register_dust("Wrought Iron", "technic:wrought_iron_ingot") register_dust("Zinc", "technic:zinc_ingot") if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then diff --git a/technic/radiation.lua b/technic/radiation.lua index 722b0ac..a4c49c6 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -54,6 +54,7 @@ local rad_resistance_node = { ["default:lava_source"] = 17, ["default:mese"] = 21, ["default:mossycobble"] = 15, + ["default:tinblock"] = 37, ["pbj_pup:pbj_pup"] = 10000, ["pbj_pup:pbj_pup_candies"] = 10000, ["gloopblocks:rainbow_block_diagonal"] = 5000, @@ -76,6 +77,7 @@ local rad_resistance_node = { ["default:stone_with_gold"] = 34, ["default:stone_with_iron"] = 20, ["default:stone_with_mese"] = 17, + ["default:stone_with_tin"] = 19, ["default:stonebrick"] = 17, ["default:water_flowing"] = 2.8, ["default:water_source"] = 5.6, @@ -141,10 +143,8 @@ local rad_resistance_node = { ["moreblocks:wood_tile_up"] = 1.7, ["moreores:mineral_mithril"] = 18, ["moreores:mineral_silver"] = 21, - ["moreores:mineral_tin"] = 19, ["moreores:mithril_block"] = 26, ["moreores:silver_block"] = 53, - ["moreores:tin_block"] = 37, ["snow:snow_brick"] = 2.8, ["technic:brass_block"] = 43, ["technic:carbon_steel_block"] = 40, diff --git a/technic/tools/mining_drill.lua b/technic/tools/mining_drill.lua index bc426e7..1cf7491 100644 --- a/technic/tools/mining_drill.lua +++ b/technic/tools/mining_drill.lua @@ -6,7 +6,7 @@ local S = technic.getter minetest.register_craft({ output = 'technic:mining_drill', recipe = { - {'moreores:tin_ingot', 'technic:diamond_drill_head', 'moreores:tin_ingot'}, + {'default:tin_ingot', 'technic:diamond_drill_head', 'default:tin_ingot'}, {'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'}, {'', 'technic:red_energy_crystal', 'default:copper_ingot'}, }