diff options
-rw-r--r-- | origin | 0 | ||||
-rw-r--r-- | technic/README.md | 8 | ||||
-rw-r--r-- | technic/config.lua | 3 | ||||
-rw-r--r-- | technic/crafts.lua | 11 | ||||
-rw-r--r-- | technic/locale/it.txt | 48 | ||||
-rw-r--r-- | technic/machines/HV/quarry.lua | 13 | ||||
-rw-r--r-- | technic/machines/LV/water_mill.lua | 16 | ||||
-rw-r--r-- | technic/machines/register/cables.lua | 17 | ||||
-rw-r--r-- | technic/machines/register/centrifuge_recipes.lua | 3 | ||||
-rw-r--r-- | technic/machines/register/grinder_recipes.lua | 6 | ||||
-rw-r--r-- | technic/machines/supply_converter.lua | 61 | ||||
-rw-r--r-- | technic/machines/switching_station.lua | 26 | ||||
-rw-r--r-- | technic/radiation.lua | 109 | ||||
-rw-r--r-- | technic/sounds/technic_hv_nuclear_reactor_siren_danger_loop.ogg | bin | 13059 -> 36524 bytes | |||
-rw-r--r-- | technic/textures/technic_stone_dust.png | bin | 0 -> 417 bytes | |||
-rw-r--r-- | technic/textures/technicx32/technic_stone_dust.png | bin | 0 -> 1284 bytes | |||
-rw-r--r-- | technic/tools/mining_drill.lua | 16 | ||||
-rw-r--r-- | technic_chests/common.lua | 28 | ||||
-rw-r--r-- | technic_chests/register.lua | 45 | ||||
-rw-r--r-- | technic_worldgen/oregen.lua | 10 |
20 files changed, 321 insertions, 99 deletions
diff --git a/technic/README.md b/technic/README.md index b6aa05f..e5adf31 100644 --- a/technic/README.md +++ b/technic/README.md @@ -25,3 +25,11 @@ RealBadAngel: (WTFPL) * Everything else. CC BY-SA 3.0: <http://creativecommons.org/licenses/by-sa/3.0/> + +Sound licenses: + +veikk0 (Veikko Mäkelä) (CC BY-SA 4.0): + * technic_hv_nuclear_reactor_siren_danger_loop.ogg + * Derived from "Nuclear alarm.wav" by Freesound.org user rene___ from <https://freesound.org/people/rene___/sounds/56778/>. Originally licensed under CC0 1.0 <https://creativecommons.org/publicdomain/zero/1.0/> + +CC BY-SA 4.0: <https://creativecommons.org/licenses/by-sa/4.0/>
\ No newline at end of file diff --git a/technic/config.lua b/technic/config.lua index 81a2224..29321f9 100644 --- a/technic/config.lua +++ b/technic/config.lua @@ -9,6 +9,9 @@ local defaults = { enable_wind_mill = "false", enable_frames = "false", enable_corium_griefing = "true", + enable_radiation_protection = "true", + enable_entity_radiation_damage = "true", + enable_longterm_radiation_damage = "true", } for k, v in pairs(defaults) do diff --git a/technic/crafts.lua b/technic/crafts.lua index 8a8cd37..4859768 100644 --- a/technic/crafts.lua +++ b/technic/crafts.lua @@ -191,3 +191,14 @@ minetest.register_craft({ }, }) +minetest.register_craft({ + output = "default:dirt 2", + type = "shapeless", + replacements = {{"bucket:bucket_water","bucket:bucket_empty"}}, + recipe = { + "technic:stone_dust", + "group:leaves", + "bucket:bucket_water", + "group:sand", + }, +}) diff --git a/technic/locale/it.txt b/technic/locale/it.txt index 59ba7f6..a092a53 100644 --- a/technic/locale/it.txt +++ b/technic/locale/it.txt @@ -26,8 +26,8 @@ Graphite = Lastra in graffite Carbon Cloth = Fibra di carbonio Raw Latex = Latex grezzo Rubber Fiber = Fibra di gomma -%.1f%%-Fissile Uranium Ingot = -%.1f%%-Fissile Uranium Block = +%.1f%%-Fissile Uranium Ingot = %.1f%%-Lingotto di uranio fissile +%.1f%%-Fissile Uranium Block = %.1f%%-Blocco di uranio fissile ## Machine misc Machine cannot be removed because it is not empty = La macchina non può essere rimossa perchè non è vuota @@ -36,7 +36,7 @@ Inventory move disallowed due to protection = Impossibile muovere l'inventario a @1 Active (@2 EU) = @1 Attivo (@2 EU) %s Active = %s Attivo %s Disabled = %s Disabilitato -%s Enabled = +%s Enabled = %s Abilitato %s Idle = %s Inattivo %s Improperly Placed = %s Piazzato impropiamente %s Unpowered = %s Non alimentato @@ -46,18 +46,18 @@ Inventory move disallowed due to protection = Impossibile muovere l'inventario a %s Finished = %s Finito Enable/Disable = Abilita/Disabilita Range = Raggio -Upgrade Slots = +Upgrade Slots = Alloggi di aggiornamento In: = Ingresso: Out: = Uscita: -Slot %d = +Slot %d = Alloggio %d Itemwise = Singolo elemento Stackwise = pila completa -Owner: = -Unlocked = -Locked = -Radius: = -Enabled = -Disabled = +Owner: = Proprietario: +Unlocked = Non chiuso a chiave +Locked = Chiuso a chiave +Radius: = Raggio: +Enabled = Abilitato +Disabled = Disabilitato ## Machine names # $1: Tier @@ -84,10 +84,10 @@ Self-Contained Injector = Ignettore Constructor Mk%d = Costruttore Mk%d Frame = Cornice Frame Motor = Cornice del motore -Template = -Template (replacing) = Template (rimpiazzato) -Template Motor = -Template Tool = +Template = Sagoma +Template (replacing) = Sagoma (di rimpiazzo) +Template Motor = Motore per sagome +Template Tool = Strumento per sagome Battery Box = Box batterie Supply Converter = Trasformatore Switching Station = Stazione di controllo @@ -96,7 +96,7 @@ Fuel-Fired Furnace = Fornace a carbone Wind Mill Frame = Pala eolica Forcefield = Campo di forza Nuclear Reactor Rod Compartment = Compartimento combustibile nucleare -Administrative World Anchor = +Administrative World Anchor = Ancora-mondo amministrativa ## Machine-specific # $1: Pruduced EU @@ -111,12 +111,12 @@ Production at %d%% = Produzione a %d%% Choose Milling Program: = Scegliere un programma di Fresatura Slim Elements half / normal height: = Metà elementi sottili / altezza normale: Current track %s = Traccia corrente %s -Stopped = -Keeping %d/%d map blocks loaded = -Digging not started = -Digging finished = -Digging %d m above machine = -Digging %d m below machine = +Stopped = Fermato +Keeping %d/%d map blocks loaded = Mantenimento di %d/%d blocchi mappa caricati +Digging not started = Scavo non iniziato +Digging finished = Scavo finito +Digging %d m above machine = Scavo di %d m sopra la macchina +Digging %d m below machine = Scavo di %d m sotto la macchina ## CNC Cylinder = Cilindro @@ -174,10 +174,10 @@ Talinite = Talinite Tin = Stagno Wrought Iron = Ferro Battuto Zinc = Zinco -%.1f%%-Fissile Uranium = +%.1f%%-Fissile Uranium = %.1f%%-Uranio fissile ## Tools -RE Battery = +RE Battery = Batteria RE Water Can = Serbatoio d'acqua Lava Can = Serbatoio di lava Chainsaw = Motosega diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index 8255676..8d87b65 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -12,6 +12,7 @@ minetest.register_craft({ local quarry_dig_above_nodes = 3 -- How far above the quarry we will dig nodes local quarry_max_depth = 100 local quarry_demand = 10000 +local quarry_eject_dir = vector.new(0, 1, 0) local function set_quarry_formspec(meta) local radius = meta:get_int("size") @@ -83,7 +84,7 @@ local function quarry_handle_purge(pos) if stack then local item = stack:to_table() if item then - technic.tube_inject_item(pos, pos, vector.new(0, 1, 0), item) + technic.tube_inject_item(pos, pos, quarry_eject_dir, item) stack:clear() inv:set_stack("cache", i, stack) break @@ -217,6 +218,16 @@ minetest.register_node("technic:quarry", { connect_sides = {"bottom", "front", "left", "right"}, tube = { connect_sides = {top = 1}, + -- lower priority than other tubes, so that quarries will prefer any + -- other tube to another quarry, which could lead to server freezes + -- in certain quarry placements (2x2 for example would never eject) + priority = 10, + can_go = function(pos, node, velocity, stack) + -- always eject the same, even if items came in another way + -- this further mitigates loops and generally avoids random sideway movement + -- that can be expected in certain quarry placements + return { quarry_eject_dir } + end }, on_construct = function(pos) local meta = minetest.get_meta(pos) diff --git a/technic/machines/LV/water_mill.lua b/technic/machines/LV/water_mill.lua index c853310..acb778c 100644 --- a/technic/machines/LV/water_mill.lua +++ b/technic/machines/LV/water_mill.lua @@ -17,19 +17,21 @@ minetest.register_craft({ local function check_node_around_mill(pos) local node = minetest.get_node(pos) - if node.name == "default:water_flowing" or - node.name == "default:water_source" then - return true + if node.name == "default:water_flowing" + or node.name == "default:river_water_flowing" then + return node.param2 -- returns approx. water flow, if any end return false end local run = function(pos, node) local meta = minetest.get_meta(pos) - local water_nodes = 0 + local water_flow = 0 local lava_nodes = 0 local production_level = 0 local eu_supply = 0 + local max_output = 35 * 45 -- four param2's at 15 makes 60, cap it lower for "overload protection" + -- (plus we want the gen to report 100% if three sides have full flow) local positions = { {x=pos.x+1, y=pos.y, z=pos.z}, @@ -41,12 +43,12 @@ local run = function(pos, node) for _, p in pairs(positions) do local check = check_node_around_mill(p) if check then - water_nodes = water_nodes + 1 + water_flow = water_flow + check end end - production_level = 25 * water_nodes - eu_supply = 30 * water_nodes + eu_supply = math.min(35 * water_flow, max_output) + production_level = math.floor(100 * eu_supply / max_output) if production_level > 0 then meta:set_int("LV_EU_supply", eu_supply) diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index 28984c0..a7e72a3 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -11,8 +11,19 @@ function technic.get_cable_tier(name) return cable_tier[name] end -local function clear_networks() - technic.networks = {} +local function clear_networks(pos) + local positions = { + {x=pos.x+1, y=pos.y, z=pos.z}, + {x=pos.x-1, y=pos.y, z=pos.z}, + {x=pos.x, y=pos.y+1, z=pos.z}, + {x=pos.x, y=pos.y-1, z=pos.z}, + {x=pos.x, y=pos.y, z=pos.z+1}, + {x=pos.x, y=pos.y, z=pos.z-1}} + for _,connected_pos in pairs(positions) do + if technic.cables[minetest.hash_node_position(connected_pos)] then + technic.networks[technic.cables[minetest.hash_node_position(connected_pos)]] = nil + end + end end function technic.register_cable(tier, size) @@ -55,7 +66,7 @@ end local function clear_nets_if_machine(pos, node) for tier, machine_list in pairs(technic.machines) do if machine_list[node.name] ~= nil then - return clear_networks() + return clear_networks(pos) end end end diff --git a/technic/machines/register/centrifuge_recipes.lua b/technic/machines/register/centrifuge_recipes.lua index 05642f5..b4db47c 100644 --- a/technic/machines/register/centrifuge_recipes.lua +++ b/technic/machines/register/centrifuge_recipes.lua @@ -14,6 +14,7 @@ local recipes = { { "technic:bronze_dust 4", "technic:copper_dust 3", "technic:tin_dust" }, { "technic:stainless_steel_dust 4", "technic:wrought_iron_dust 3", "technic:chromium_dust" }, { "technic:brass_dust 3", "technic:copper_dust 2", "technic:zinc_dust" }, + { "default:dirt 4", "default:sand", "default:gravel", "default:clay_lump 2" }, } local function uranium_dust(p) @@ -34,5 +35,5 @@ if minetest.get_modpath("farming") then end for _, data in pairs(recipes) do - technic.register_separating_recipe({ input = { data[1] }, output = { data[2], data[3] } }) + technic.register_separating_recipe({ input = { data[1] }, output = { data[2], data[3], data[4] } }) end diff --git a/technic/machines/register/grinder_recipes.lua b/technic/machines/register/grinder_recipes.lua index 87c6ade..7eaa7d4 100644 --- a/technic/machines/register/grinder_recipes.lua +++ b/technic/machines/register/grinder_recipes.lua @@ -20,11 +20,12 @@ local recipes = { {"technic:zinc_lump", "technic:zinc_dust 2"}, {"technic:lead_lump", "technic:lead_dust 2"}, {"technic:sulfur_lump", "technic:sulfur_dust 2"}, + {"default:stone", "technic:stone_dust"}, + {"default:sand", "technic:stone_dust"}, -- Other {"default:cobble", "default:gravel"}, - {"default:gravel", "default:dirt"}, - {"default:stone", "default:sand"}, + {"default:gravel", "default:sand"}, {"default:sandstone", "default:sand 2"}, -- reverse recipe can be found in the compressor } @@ -103,6 +104,7 @@ register_dust("Sulfur", nil) register_dust("Tin", "moreores:tin_ingot") register_dust("Wrought Iron", "technic:wrought_iron_ingot") register_dust("Zinc", "technic:zinc_ingot") +register_dust("Stone", "default:stone") if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then register_dust("Akalin", "glooptest:akalin_ingot") register_dust("Alatro", "glooptest:alatro_ingot") diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua index 32597de..15c761d 100644 --- a/technic/machines/supply_converter.lua +++ b/technic/machines/supply_converter.lua @@ -9,12 +9,62 @@ local S = technic.getter +local function set_supply_converter_formspec(meta) + local formspec = "size[5,2.25]".. + "field[0.3,0.5;2,1;power;"..S("Input Power")..";"..meta:get_int("power").."]" + -- The names for these toggle buttons are explicit about which + -- state they'll switch to, so that multiple presses (arising + -- from the ambiguity between lag and a missed press) only make + -- the single change that the user expects. + if meta:get_int("mesecon_mode") == 0 then + formspec = formspec.."button[0,1;5,1;mesecon_mode_1;"..S("Ignoring Mesecon Signal").."]" + else + formspec = formspec.."button[0,1;5,1;mesecon_mode_0;"..S("Controlled by Mesecon Signal").."]" + end + if meta:get_int("enabled") == 0 then + formspec = formspec.."button[0,1.75;5,1;enable;"..S("%s Disabled"):format(S("Supply Converter")).."]" + else + formspec = formspec.."button[0,1.75;5,1;disable;"..S("%s Enabled"):format(S("Supply Converter")).."]" + end + meta:set_string("formspec", formspec) +end + +local supply_converter_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + local power = nil + if fields.power then + power = tonumber(fields.power) or 0 + power = 100 * math.floor(power / 100) + power = math.max(power, 0) + power = math.min(power, 10000) + if power == meta:get_int("power") then power = nil end + end + if power then meta:set_int("power", power) end + if fields.enable then meta:set_int("enabled", 1) end + if fields.disable then meta:set_int("enabled", 0) end + if fields.mesecon_mode_0 then meta:set_int("mesecon_mode", 0) end + if fields.mesecon_mode_1 then meta:set_int("mesecon_mode", 1) end + set_supply_converter_formspec(meta) +end + +local mesecons = { + effector = { + action_on = function(pos, node) + minetest.get_meta(pos):set_int("mesecon_effect", 1) + end, + action_off = function(pos, node) + minetest.get_meta(pos):set_int("mesecon_effect", 0) + end + } +} + local run = function(pos, node) - local demand = 10000 local remain = 0.9 -- Machine information local machine_name = S("Supply Converter") local meta = minetest.get_meta(pos) + local enabled = meta:get_int("enabled") ~= 0 and (meta:get_int("mesecon_mode") == 0 or meta:get_int("mesecon_effect") ~= 0) + local demand = enabled and meta:get_int("power") or 10000 local pos_up = {x=pos.x, y=pos.y+1, z=pos.z} local pos_down = {x=pos.x, y=pos.y-1, z=pos.z} @@ -53,12 +103,19 @@ minetest.register_node("technic:supply_converter", { technic_machine=1, technic_all_tiers=1}, connect_sides = {"top", "bottom"}, sounds = default.node_sound_wood_defaults(), + on_receive_fields = supply_converter_receive_fields, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", S("Supply Converter")) - meta:set_float("active", false) + meta:set_int("power", 10000) + meta:set_int("enabled", 1) + meta:set_int("mesecon_mode", 0) + meta:set_int("mesecon_effect", 0) + set_supply_converter_formspec(meta) end, + mesecons = mesecons, technic_run = run, + technic_on_disable = run, }) minetest.register_craft({ diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index f7ec0b6..2051acf 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -32,6 +32,7 @@ -- This way the supplies are separated per network. technic.networks = {} +technic.cables = {} local S = technic.getter @@ -64,7 +65,8 @@ minetest.register_node("technic:switching_station",{ -------------------------------------------------- -- Add a wire node to the LV/MV/HV network -local add_new_cable_node = function(nodes, pos) +local add_new_cable_node = function(nodes, pos, network_id) + technic.cables[minetest.hash_node_position(pos)] = network_id -- Ignore if the node has already been added for i = 1, #nodes do if pos.x == nodes[i].x and @@ -78,31 +80,31 @@ local add_new_cable_node = function(nodes, pos) end -- Generic function to add found connected nodes to the right classification array -local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, pos, machines, tier, sw_pos, from_below) +local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, pos, machines, tier, sw_pos, from_below, network_id) technic.get_or_load_node(pos) local meta = minetest.get_meta(pos) local name = minetest.get_node(pos).name if technic.is_tier_cable(name, tier) then - add_new_cable_node(all_nodes, pos) + add_new_cable_node(all_nodes, pos,network_id) elseif machines[name] then --dprint(name.." is a "..machines[name]) if machines[name] == technic.producer then - add_new_cable_node(PR_nodes, pos) + add_new_cable_node(PR_nodes, pos, network_id) elseif machines[name] == technic.receiver then - add_new_cable_node(RE_nodes, pos) + add_new_cable_node(RE_nodes, pos, network_id) elseif machines[name] == technic.producer_receiver then - add_new_cable_node(PR_nodes, pos) - add_new_cable_node(RE_nodes, pos) + add_new_cable_node(PR_nodes, pos, network_id) + add_new_cable_node(RE_nodes, pos, network_id) elseif machines[name] == "SPECIAL" and (pos.x ~= sw_pos.x or pos.y ~= sw_pos.y or pos.z ~= sw_pos.z) and from_below then -- Another switching station -> disable it - add_new_cable_node(SP_nodes, pos) + add_new_cable_node(SP_nodes, pos, network_id) meta:set_int("active", 0) meta:set_string("active_pos", minetest.serialize(sw_pos)) elseif machines[name] == technic.battery then - add_new_cable_node(BA_nodes, pos) + add_new_cable_node(BA_nodes, pos, network_id) end meta:set_int(tier.."_EU_timeout", 2) -- Touch node @@ -110,7 +112,7 @@ local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nod end -- Traverse a network given a list of machines and a cable type name -local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, i, machines, tier, sw_pos) +local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, i, machines, tier, sw_pos, network_id) local pos = all_nodes[i] local positions = { {x=pos.x+1, y=pos.y, z=pos.z}, @@ -121,7 +123,7 @@ local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_no {x=pos.x, y=pos.y, z=pos.z-1}} --print("ON") for i, cur_pos in pairs(positions) do - check_node_subp(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, cur_pos, machines, tier, sw_pos, i == 3) + check_node_subp(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, cur_pos, machines, tier, sw_pos, i == 3, network_id) end end @@ -153,7 +155,7 @@ local get_network = function(sw_pos, pos1, tier) local all_nodes = {pos1} repeat traverse_network(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, - i, technic.machines[tier], tier, sw_pos) + i, technic.machines[tier], tier, sw_pos, minetest.hash_node_position(pos1)) i = i + 1 until all_nodes[i] == nil technic.networks[minetest.hash_node_position(pos1)] = {tier = tier, PR_nodes = PR_nodes, diff --git a/technic/radiation.lua b/technic/radiation.lua index ac3f166..13936f9 100644 --- a/technic/radiation.lua +++ b/technic/radiation.lua @@ -242,6 +242,10 @@ local cache_scaled_shielding = {} local rad_dmg_cutoff = 0.2 local radiated_players = {} +local armor_enabled = technic.config:get_bool("enable_radiation_protection") +local entity_damage = technic.config:get_bool("enable_entity_radiation_damage") +local longterm_damage = technic.config:get_bool("enable_longterm_radiation_damage") + local function apply_fractional_damage(o, dmg) local dmg_int = math.floor(dmg) -- The closer you are to getting one more damage point, @@ -257,26 +261,69 @@ local function apply_fractional_damage(o, dmg) return false end -local function dmg_player(pos, player, strength) - local pl_pos = player:getpos() - pl_pos.y = pl_pos.y + abdomen_offset +local function calculate_base_damage(node_pos, object_pos, strength) local shielding = 0 - local dist = vector.distance(pos, pl_pos) + local dist = vector.distance(node_pos, object_pos) - for ray_pos in technic.trace_node_ray(pos, - vector.direction(pos, pl_pos), dist) do + for ray_pos in technic.trace_node_ray(node_pos, + vector.direction(node_pos, object_pos), dist) do local shield_name = minetest.get_node(ray_pos).name - shielding = shielding + node_radiation_resistance(shield_name) * 0.1 + shielding = shielding + node_radiation_resistance(shield_name) * 0.025 end local dmg = (strength * strength) / (math.max(0.75, dist * dist) * math.exp(shielding)) if dmg < rad_dmg_cutoff then return end - apply_fractional_damage(player, dmg) + return dmg +end + +local function calculate_damage_multiplier(object) + local ag = object.get_armor_groups and object:get_armor_groups() + if not ag then + return 0 + end + if ag.immortal then + return 0 + end + if ag.radiation then + return 0.01 * ag.radiation + end + if ag.fleshy then + return math.sqrt(0.01 * ag.fleshy) + end + return 0 +end - local pn = player:get_player_name() - radiated_players[pn] = (radiated_players[pn] or 0) + dmg +local function calculate_object_center(object) + if object:is_player() then + return {x=0, y=abdomen_offset, z=0} + end + return {x=0, y=0, z=0} +end + +local function dmg_object(pos, object, strength) + local obj_pos = vector.add(object:getpos(), calculate_object_center(object)) + local mul + if armor_enabled or entity_damage then + -- we need to check may the object be damaged even if armor is disabled + mul = calculate_damage_multiplier(object) + if mul == 0 then + return + end + end + local dmg = calculate_base_damage(pos, obj_pos, strength) + if not dmg then + return + end + if armor_enabled then + dmg = dmg * mul + end + apply_fractional_damage(object, dmg) + if longterm_damage and object:is_player() then + local pn = object:get_player_name() + radiated_players[pn] = (radiated_players[pn] or 0) + dmg + end end local rad_dmg_mult_sqrt = math.sqrt(1 / rad_dmg_cutoff) @@ -285,8 +332,8 @@ local function dmg_abm(pos, node) local max_dist = strength * rad_dmg_mult_sqrt for _, o in pairs(minetest.get_objects_inside_radius(pos, max_dist + abdomen_offset)) do - if o:is_player() then - dmg_player(pos, o, strength) + if entity_damage or o:is_player() then + dmg_object(pos, o, strength) end end end @@ -299,26 +346,28 @@ if minetest.setting_getbool("enable_damage") then action = dmg_abm, }) - minetest.register_globalstep(function(dtime) - for pn, dmg in pairs(radiated_players) do - dmg = dmg - (dtime / 8) - local player = minetest.get_player_by_name(pn) - local killed - if player and dmg > rad_dmg_cutoff then - killed = apply_fractional_damage(player, (dmg * dtime) / 8) - else - dmg = nil - end - -- on_dieplayer will have already set this if the player died - if not killed then - radiated_players[pn] = dmg + if longterm_damage then + minetest.register_globalstep(function(dtime) + for pn, dmg in pairs(radiated_players) do + dmg = dmg - (dtime / 8) + local player = minetest.get_player_by_name(pn) + local killed + if player and dmg > rad_dmg_cutoff then + killed = apply_fractional_damage(player, (dmg * dtime) / 8) + else + dmg = nil + end + -- on_dieplayer will have already set this if the player died + if not killed then + radiated_players[pn] = dmg + end end - end - end) + end) - minetest.register_on_dieplayer(function(player) - radiated_players[player:get_player_name()] = nil - end) + minetest.register_on_dieplayer(function(player) + radiated_players[player:get_player_name()] = nil + end) + end end -- Radioactive materials that can result from destroying a reactor diff --git a/technic/sounds/technic_hv_nuclear_reactor_siren_danger_loop.ogg b/technic/sounds/technic_hv_nuclear_reactor_siren_danger_loop.ogg Binary files differindex 3d290b0..1f21a16 100644 --- a/technic/sounds/technic_hv_nuclear_reactor_siren_danger_loop.ogg +++ b/technic/sounds/technic_hv_nuclear_reactor_siren_danger_loop.ogg diff --git a/technic/textures/technic_stone_dust.png b/technic/textures/technic_stone_dust.png Binary files differnew file mode 100644 index 0000000..ce9d9e4 --- /dev/null +++ b/technic/textures/technic_stone_dust.png diff --git a/technic/textures/technicx32/technic_stone_dust.png b/technic/textures/technicx32/technic_stone_dust.png Binary files differnew file mode 100644 index 0000000..3c49fe6 --- /dev/null +++ b/technic/textures/technicx32/technic_stone_dust.png diff --git a/technic/tools/mining_drill.lua b/technic/tools/mining_drill.lua index 487804d..bc426e7 100644 --- a/technic/tools/mining_drill.lua +++ b/technic/tools/mining_drill.lua @@ -254,10 +254,9 @@ local function mining_drill_mk2_setmode(user,itemstack) mode=mode+1 if mode>=5 then mode=1 end minetest.chat_send_player(player_name, S("Mining Drill Mk%d Mode %d"):format(2, mode)..": "..mining_drill_mode_text[mode][1]) - item["name"]="technic:mining_drill_mk2_"..mode + itemstack:set_name("technic:mining_drill_mk2_"..mode); meta["mode"]=mode - item["metadata"]=minetest.serialize(meta) - itemstack:replace(item) + itemstack:set_metadata(minetest.serialize(meta)) return itemstack end @@ -278,10 +277,9 @@ local function mining_drill_mk3_setmode(user,itemstack) mode=mode+1 if mode>=6 then mode=1 end minetest.chat_send_player(player_name, S("Mining Drill Mk%d Mode %d"):format(3, mode)..": "..mining_drill_mode_text[mode][1]) - item["name"]="technic:mining_drill_mk3_"..mode + itemstack:set_name("technic:mining_drill_mk3_"..mode); meta["mode"]=mode - item["metadata"]=minetest.serialize(meta) - itemstack:replace(item) + itemstack:set_metadata(minetest.serialize(meta)) return itemstack end @@ -298,7 +296,7 @@ local function mining_drill_mk2_handler(itemstack, user, pointed_thing) end local charge_to_take = cost_to_use(2, meta.mode) if meta.charge >= charge_to_take then - local pos = minetest.get_pointed_thing_position(pointed_thing, above) + local pos = minetest.get_pointed_thing_position(pointed_thing, false) drill_dig_it(pos, user, meta.mode) if not technic.creative_mode then meta.charge = meta.charge - charge_to_take @@ -321,7 +319,7 @@ local function mining_drill_mk3_handler(itemstack, user, pointed_thing) end local charge_to_take = cost_to_use(3, meta.mode) if meta.charge >= charge_to_take then - local pos = minetest.get_pointed_thing_position(pointed_thing, above) + local pos = minetest.get_pointed_thing_position(pointed_thing, false) drill_dig_it(pos, user, meta.mode) if not technic.creative_mode then meta.charge = meta.charge - charge_to_take @@ -350,7 +348,7 @@ minetest.register_tool("technic:mining_drill", { end local charge_to_take = cost_to_use(1, 1) if meta.charge >= charge_to_take then - local pos = minetest.get_pointed_thing_position(pointed_thing, above) + local pos = minetest.get_pointed_thing_position(pointed_thing, false) drill_dig_it(pos, user, 1) if not technic.creative_mode then meta.charge = meta.charge - charge_to_take diff --git a/technic_chests/common.lua b/technic_chests/common.lua index 47054f5..b8e30a4 100644 --- a/technic_chests/common.lua +++ b/technic_chests/common.lua @@ -65,7 +65,31 @@ function technic.chests.on_inv_take(pos, listname, index, stack, player) ..minetest.pos_to_string(pos)) end -function has_locked_chest_privilege(meta, player) - return player:get_player_name() == meta:get_string("owner") +local function has_locked_chest_privilege(meta, player) + if player then + if minetest.check_player_privs(player, "protection_bypass") then + return true + end + else + return false + end + + -- is player wielding the right key? + local item = player:get_wielded_item() + if item:get_name() == "default:key" then + local key_meta = minetest.parse_json(item:get_metadata()) + local secret = meta:get_string("key_lock_secret") + if secret ~= key_meta.secret then + return false + end + + return true + end + + if player:get_player_name() ~= meta:get_string("owner") then + return false + end + + return true end diff --git a/technic_chests/register.lua b/technic_chests/register.lua index 25e4cde..bf2f0e1 100644 --- a/technic_chests/register.lua +++ b/technic_chests/register.lua @@ -263,12 +263,55 @@ function technic.chests:definition(name, data) on_receive_fields = get_receive_fields(name, data), on_metadata_inventory_move = self.on_inv_move, on_metadata_inventory_put = self.on_inv_put, - on_metadata_inventory_take = self.on_inv_take, + on_metadata_inventory_take = self.on_inv_take, + on_blast = function(pos) + local drops = {} + default.get_inventory_drops(pos, "main", drops) + drops[#drops+1] = "default:chest" + minetest.remove_node(pos) + return drops + end, } if data.locked then def.allow_metadata_inventory_move = self.inv_move def.allow_metadata_inventory_put = self.inv_put def.allow_metadata_inventory_take = self.inv_take + def.on_blast = function() end, + def.on_key_use = function(pos, player) + local secret = minetest.get_meta(pos):get_string("key_lock_secret") + local itemstack = player:get_wielded_item() + local key_meta = minetest.parse_json(itemstack:get_metadata()) + + if secret ~= key_meta.secret then + return + end + + minetest.show_formspec( + player:get_player_name(), + "default:chest_locked", + get_locked_chest_formspec(pos) + ) + end, + def.on_skeleton_key_use = function(pos, player, newsecret) + local meta = minetest.get_meta(pos) + local owner = meta:get_string("owner") + local name = player:get_player_name() + + -- verify placer is owner of lockable chest + if owner ~= name then + minetest.record_protection_violation(pos, name) + minetest.chat_send_player(name, "You do not own this chest.") + return nil + end + + local secret = meta:get_string("key_lock_secret") + if secret == "" then + secret = newsecret + meta:set_string("key_lock_secret", secret) + end + + return secret, "a locked chest", owner + end, end return def end diff --git a/technic_worldgen/oregen.lua b/technic_worldgen/oregen.lua index 795f0ec..c6782e6 100644 --- a/technic_worldgen/oregen.lua +++ b/technic_worldgen/oregen.lua @@ -54,13 +54,13 @@ minetest.register_ore({ ore_type = "scatter", ore = "technic:mineral_zinc", wherein = "default:stone", - clust_scarcity = 8*8*8, - clust_num_ores = 4, - clust_size = 3, + clust_scarcity = 9*9*9, + clust_num_ores = 5, + clust_size = 7, y_min = -32, y_max = 2, - noise_params = zinc_params, - noise_threshhold = zinc_threshhold, + noise_params = lead_params, + noise_threshhold = lead_threshhold, }) minetest.register_ore({ |