diff options
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | technic/flashlight.lua | 2 | ||||
-rw-r--r-- | technic/forcefield.lua | 204 | ||||
-rw-r--r-- | technic/init.lua | 2 | ||||
-rw-r--r-- | technic/power_radiator.lua | 4 | ||||
-rw-r--r-- | technic/sonic_screwdriver.lua | 2 | ||||
-rw-r--r-- | technic/supply_converter.lua | 6 | ||||
-rw-r--r-- | technic/switching_station.lua | 4 | ||||
-rw-r--r-- | technic/textures/technic_hv_down_converter_bottom.png | bin | 653 -> 0 bytes | |||
-rw-r--r-- | technic/textures/technic_hv_down_converter_side.png | bin | 609 -> 0 bytes | |||
-rw-r--r-- | technic/textures/technic_hv_down_converter_top.png | bin | 653 -> 0 bytes | |||
-rw-r--r-- | technic/textures/technic_supply_converter_bottom.png (renamed from technic/textures/technic_mv_down_converter_bottom.png) | bin | 738 -> 738 bytes | |||
-rw-r--r-- | technic/textures/technic_supply_converter_side.png (renamed from technic/textures/technic_mv_down_converter_side.png) | bin | 670 -> 670 bytes | |||
-rw-r--r-- | technic/textures/technic_supply_converter_top.png (renamed from technic/textures/technic_mv_down_converter_top.png) | bin | 738 -> 738 bytes |
14 files changed, 123 insertions, 106 deletions
@@ -1,12 +1,13 @@ -technic 0.4.6 +technic 0.4.7 -Technic mod for Minetest 0.4.6 +Technic mod for Minetest 0.4.7 Credits for contributing to the project: Nekogloop ShadowNinja VanessaE Nore/Novatux +kpoppel And many others for ideas/inspiring Licences: diff --git a/technic/flashlight.lua b/technic/flashlight.lua index dd36c31..5f3ea96 100644 --- a/technic/flashlight.lua +++ b/technic/flashlight.lua @@ -161,7 +161,7 @@ local hotbar=inv:get_list("main") charge=meta["charge"] if charge-2>0 then charge =charge-2; - set_RE_wear(item,charge,flashlight_max_charge) + technic.set_RE_wear(item,charge,flashlight_max_charge) meta["charge"]=charge item["metadata"]=set_item_meta(meta) hotbar[i]:replace(item) diff --git a/technic/forcefield.lua b/technic/forcefield.lua index 8af98f4..8ad5410 100644 --- a/technic/forcefield.lua +++ b/technic/forcefield.lua @@ -1,7 +1,11 @@ ---Forcefield mod by ShadowNinja - -local forcefield_emitter_buffer_size = 10000 -local forcefield_emitter_power_consumption = 0.8 +-- Forcefield mod by ShadowNinja +-- Modified by kpoppel +-- +-- Forcefields are powerful barriers but they consume huge amounts of power. +-- Forcefield Generator is a HV machine. + +-- How expensive is the generator? Leaves room for upgrades lowering the power drain? +local forcefield_power_drain = 10 -- default 10 local forcefield_update_interval = 1 minetest.register_craft({ @@ -13,22 +17,13 @@ minetest.register_craft({ } }) -local function get_forcefield_count(range) - local count = 0 - for x=-range,range do - for y=-range,range do - for z=-range,range do - if ((x*x+y*y+z*z) <= (range * range + range)) then - if (y == 0) or ((range-1) * (range-1) + (range-1) <= x*x+y*y+z*z) then - count = count + 1 - end - end - end - end - end - return count -end - +-- Idea: Let forcefields have different colors by upgrade slot. +-- Idea: Let forcefields add up by detecting if one hits another. +-- ___ __ +-- / \/ \ +-- | | +-- \___/\___/ +-- local function add_forcefield(pos, range) for x=-range,range do for y=-range,range do @@ -66,69 +61,90 @@ local function remove_forcefield(p, range) end end -local forcefield_receive_fields = function(pos, formname, fields, sender) - local meta = minetest.env:get_meta(pos) - local range = meta:get_int("range") - if fields.add then range = range + 1 end - if fields.subtract then range = range - 1 end - if fields.toggle then - if meta:get_int("enabled") == 1 then - meta:set_int("enabled", 0) - else - meta:set_int("enabled", 1) - end - end - if range <= 20 and range >= 0 and meta:get_int("range") ~= range then - remove_forcefield(pos, meta:get_int("range")) - meta:set_int("range", range) - local buffer = meta:get_float("internal_EU_buffer") - local buffer_size = meta:get_float("internal_EU_buffer_size") - local load = math.floor(buffer / buffer_size * 100) - meta:set_string("formspec", get_forcefield_formspec(range, 0)) - end -end - -local get_forcefield_formspec = function(range, load) - if not load then load = 0 end - return "invsize[8,9;]".. +local get_forcefield_formspec = function(range) + -- return "invsize[8,9;]".. (if upgrades added later - colors for instance) + return "invsize[3,4;]".. "label[0,0;Forcefield emitter]".. - "label[1,3;Power level]".. - "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. - load..":technic_power_meter_fg.png]".. - "label[4,1;Range]".. - "label[4,2;"..range.."]".. - "button[3,2;1,1;add;+]".. - "button[5,2;1,1;subtract;-]".. - "button[3,3;3,1;toggle;Enable/Disable]".. - "list[current_player;main;0,5;8,4;]" + "label[1,1;Range]".. + "label[1,2;"..range.."]".. + "button[0,2;1,1;subtract;-]".. + "button[2,2;1,1;add;+]".. + "button[0,3;3,1;toggle;Enable/Disable]" -- .. +-- "list[current_player;main;0,5;8,4;]" end -local forcefield_check = function(pos) - local meta = minetest.env:get_meta(pos) - local node = minetest.env:get_node(pos) - local internal_EU_buffer=meta:get_float("internal_EU_buffer") - local internal_EU_buffer_size=meta:get_float("internal_EU_buffer_size") - - local load = math.floor(internal_EU_buffer/internal_EU_buffer_size * 100) - meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range"), load)) - - local power_requirement = get_forcefield_count(meta:get_int("range")) * forcefield_emitter_power_consumption - if meta:get_int("enabled") == 1 and internal_EU_buffer >= power_requirement then - if node.name == "technic:forcefield_emitter_off" then - hacky_swap_node(pos, "technic:forcefield_emitter_on") - end - internal_EU_buffer=internal_EU_buffer-power_requirement; - meta:set_float("internal_EU_buffer", internal_EU_buffer) - add_forcefield(pos, meta:get_int("range")) - else - if node.name == "technic:forcefield_emitter_on" then - remove_forcefield(pos, meta:get_int("range")) - hacky_swap_node(pos, "technic:forcefield_emitter_off") - end - end - return true +local forcefield_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos) + local range = meta:get_int("range") + if fields.add then range = range + 1 end + if fields.subtract then range = range - 1 end + if fields.toggle then + if meta:get_int("enabled") == 1 then + meta:set_int("enabled", 0) + else + meta:set_int("enabled", 1) + end + end + -- Smallest field is 5. Anything less is asking for trouble. + -- Largest is 20. It is a matter of pratical node handling. + if range < 5 then range = 5 end + if range > 20 then range = 20 end + + if range <= 20 and range >= 5 and meta:get_int("range") ~= range then + remove_forcefield(pos, meta:get_int("range")) + meta:set_int("range", range) + meta:set_string("formspec", get_forcefield_formspec(range)) + end + end -end +local forcefield_check = function(pos) + local meta = minetest.env:get_meta(pos) + local node = minetest.env:get_node(pos) + local eu_input = meta:get_int("HV_EU_input") + local eu_demand = meta:get_int("HV_EU_demand") + local enabled = meta:get_int("enabled") + + -- Power off automatically if no longer connected to a switching station + technic.switching_station_timeout_count(pos, "HV") + + local power_requirement + if enabled == 1 then + power_requirement = math.floor(4*math.pi*math.pow(meta:get_int("range"), 2)) * forcefield_power_drain + else + power_requirement = eu_demand + end + + if eu_input == 0 then + meta:set_string("infotext", "Forcefield Generator Unpowered") + meta:set_int("HV_EU_demand", 100) + meta:set_int("enabled", 0) + if node.name == "technic:forcefield_emitter_on" then + remove_forcefield(pos, meta:get_int("range")) + hacky_swap_node(pos, "technic:forcefield_emitter_off") + end + elseif eu_input == power_requirement then + if meta:get_int("enabled") == 1 then + if node.name == "technic:forcefield_emitter_off" then + hacky_swap_node(pos, "technic:forcefield_emitter_on") + meta:set_string("infotext", "Forcefield Generator Active") + add_forcefield(pos, meta:get_int("range")) + else + -- Range updated. Move the forcefield. + add_forcefield(pos, meta:get_int("range")) + end + else + if node.name == "technic:forcefield_emitter_on" then + remove_forcefield(pos, meta:get_int("range")) + hacky_swap_node(pos, "technic:forcefield_emitter_off") + meta:set_int("HV_EU_demand", 100) + meta:set_string("infotext", "Forcefield Generator Idle") + end + end + else + meta:set_int("HV_EU_demand", power_requirement) + end + return true + end local mesecons = {effector = { action_on = function(pos, node) @@ -150,12 +166,12 @@ minetest.register_node("technic:forcefield_emitter_off", { on_construct = function(pos) minetest.env:get_node_timer(pos):start(forcefield_update_interval) local meta = minetest.env:get_meta(pos) - meta:set_float("technic_power_machine", 1) - meta:set_float("internal_EU_buffer", 0) - meta:set_float("internal_EU_buffer_size", forcefield_emitter_buffer_size) + meta:set_float("technic_hv_power_machine", 1) + meta:set_int("HV_EU_input", 0) + meta:set_int("HV_EU_demand", 0) meta:set_int("range", 10) - meta:set_int("enabled", 1) - meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range", 0))) + meta:set_int("enabled", 0) + meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range"))) meta:set_string("infotext", "Forcefield emitter"); end, mesecons = mesecons @@ -172,19 +188,18 @@ minetest.register_node("technic:forcefield_emitter_on", { on_construct = function(pos) minetest.env:get_node_timer(pos):start(forcefield_update_interval) local meta = minetest.env:get_meta(pos) - meta:set_float("technic_power_machine", 1) - meta:set_float("internal_EU_buffer", 0) - meta:set_float("internal_EU_buffer_size", forcefield_emitter_buffer_size) - meta:set_int("range", 10) - meta:set_int("enabled", 1) - meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range"), 0)) - meta:set_string("infotext", "Forcefield emitter"); +-- meta:set_float("technic_hv_power_machine", 1) +-- meta:set_float("HV_EU_input", 0) +-- meta:set_float("HV_EU_demand", 0) +-- meta:set_int("range", 10) +-- meta:set_int("enabled", 1) + meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range"))) +-- meta:set_string("infotext", "Forcefield emitter"); end, on_dig = function(pos, node, digger) remove_forcefield(pos, minetest.env:get_meta(pos):get_int("range")) return minetest.node_dig(pos, node, digger) end, - technic_power_machine=1, mesecons = mesecons }) @@ -192,6 +207,7 @@ minetest.register_node("technic:forcefield", { description = "Forcefield (you hacker you)", sunlight_propagates = true, drop = '', + light_source = 8, tiles = {{name="technic_forcefield_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}}, is_ground_content = true, groups = {not_in_creative_inventory=1, unbreakable=1}, @@ -205,5 +221,5 @@ minetest.register_node("technic:forcefield", { }, }) -technic.register_MV_machine("technic:forcefield_emitter_on","RE") -technic.register_MV_machine("technic:forcefield_emitter_off","RE") +technic.register_HV_machine("technic:forcefield_emitter_on","RE") +technic.register_HV_machine("technic:forcefield_emitter_off","RE") diff --git a/technic/init.lua b/technic/init.lua index 263b6b9..2d748bc 100644 --- a/technic/init.lua +++ b/technic/init.lua @@ -52,7 +52,7 @@ dofile(modpath.."/battery_box_mv.lua") dofile(modpath.."/solar_array_mv.lua") dofile(modpath.."/electric_furnace_mv.lua") dofile(modpath.."/alloy_furnace_mv.lua") ---dofile(modpath.."/forcefield.lua") +dofile(modpath.."/forcefield.lua") ---- The power radiator supplies appliances with inductive coupled power: ---- lighting and associated textures is taken directly from VanessaE's homedecor and made electric. dofile(modpath.."/power_radiator.lua") diff --git a/technic/power_radiator.lua b/technic/power_radiator.lua index 9a4c84a..8b0666a 100644 --- a/technic/power_radiator.lua +++ b/technic/power_radiator.lua @@ -87,8 +87,8 @@ local shutdown_inductive_appliances = function(pos) minetest.register_node( "technic:power_radiator", { description = "Power Radiator", - tiles = {"technic_hv_down_converter_top.png", "technic_hv_down_converter_bottom.png", "technic_hv_down_converter_side.png", - "technic_hv_down_converter_side.png", "technic_hv_down_converter_side.png", "technic_hv_down_converter_side.png"}, + tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png", + "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, sounds = default.node_sound_wood_defaults(), drawtype = "nodebox", diff --git a/technic/sonic_screwdriver.lua b/technic/sonic_screwdriver.lua index 1453862..00922f7 100644 --- a/technic/sonic_screwdriver.lua +++ b/technic/sonic_screwdriver.lua @@ -38,7 +38,7 @@ minetest.register_tool("technic:sonic_screwdriver", { charge=charge-100; meta1["charge"]=charge item["metadata"]=set_item_meta(meta1) - set_RE_wear(item,charge,sonic_screwdriver_max_charge) + technic.set_RE_wear(item,charge,sonic_screwdriver_max_charge) itemstack:replace(item) end return itemstack diff --git a/technic/supply_converter.lua b/technic/supply_converter.lua index 5e04d42..d0714e7 100644 --- a/technic/supply_converter.lua +++ b/technic/supply_converter.lua @@ -14,8 +14,8 @@ minetest.register_node( "technic:supply_converter", { description = "Supply Converter", - tiles = {"technic_mv_down_converter_top.png", "technic_mv_down_converter_bottom.png", "technic_mv_down_converter_side.png", - "technic_mv_down_converter_side.png", "technic_mv_down_converter_side.png", "technic_mv_down_converter_side.png"}, + tiles = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png", "technic_supply_converter_side.png", + "technic_supply_converter_side.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png"}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, sounds = default.node_sound_wood_defaults(), drawtype = "nodebox", @@ -58,7 +58,7 @@ minetest.register_abm( local mv_lv_factor = 4 -- multiplication (higher is more efficient) local mv_hv_factor = 5 -- division local hv_mv_factor = 4 -- multiplication - local max_lv_demand = 2000 -- The increment size pwer supply tier. Determines how many are needed + local max_lv_demand = 2000 -- The increment size power supply tier. Determines how many are needed local max_mv_demand = 2000 -- -""- local max_hv_demand = 2000 -- -""- diff --git a/technic/switching_station.lua b/technic/switching_station.lua index 7919d5e..36133fa 100644 --- a/technic/switching_station.lua +++ b/technic/switching_station.lua @@ -43,8 +43,8 @@ minetest.register_craft( minetest.register_node( "technic:switching_station", {description = "Switching Station", - tiles = {"technic_mv_down_converter_top.png", "technic_mv_down_converter_bottom.png", "technic_mv_down_converter_side.png", - "technic_mv_down_converter_side.png", "technic_mv_down_converter_side.png", "technic_mv_down_converter_side.png"}, + tiles = {"technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png", + "technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png"}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, sounds = default.node_sound_wood_defaults(), drawtype = "nodebox", diff --git a/technic/textures/technic_hv_down_converter_bottom.png b/technic/textures/technic_hv_down_converter_bottom.png Binary files differdeleted file mode 100644 index 996b2d4..0000000 --- a/technic/textures/technic_hv_down_converter_bottom.png +++ /dev/null diff --git a/technic/textures/technic_hv_down_converter_side.png b/technic/textures/technic_hv_down_converter_side.png Binary files differdeleted file mode 100644 index ab904f1..0000000 --- a/technic/textures/technic_hv_down_converter_side.png +++ /dev/null diff --git a/technic/textures/technic_hv_down_converter_top.png b/technic/textures/technic_hv_down_converter_top.png Binary files differdeleted file mode 100644 index 996b2d4..0000000 --- a/technic/textures/technic_hv_down_converter_top.png +++ /dev/null diff --git a/technic/textures/technic_mv_down_converter_bottom.png b/technic/textures/technic_supply_converter_bottom.png Binary files differindex a610660..a610660 100644 --- a/technic/textures/technic_mv_down_converter_bottom.png +++ b/technic/textures/technic_supply_converter_bottom.png diff --git a/technic/textures/technic_mv_down_converter_side.png b/technic/textures/technic_supply_converter_side.png Binary files differindex 6492d5c..6492d5c 100644 --- a/technic/textures/technic_mv_down_converter_side.png +++ b/technic/textures/technic_supply_converter_side.png diff --git a/technic/textures/technic_mv_down_converter_top.png b/technic/textures/technic_supply_converter_top.png Binary files differindex a610660..a610660 100644 --- a/technic/textures/technic_mv_down_converter_top.png +++ b/technic/textures/technic_supply_converter_top.png |