diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-04-05 00:23:23 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-04-05 00:23:23 -0400 |
commit | 4c9e8e6bf06b09b3a015bd7d76ea2a8966e0336f (patch) | |
tree | da4748ec4655a0fc2dc40e777cc8cab88c863caa /technic/machines/HV | |
parent | 8958d6176121ecdf4f6786f4adddf194e7abe9e9 (diff) | |
download | dreambuilder_modpack-4c9e8e6bf06b09b3a015bd7d76ea2a8966e0336f.tar dreambuilder_modpack-4c9e8e6bf06b09b3a015bd7d76ea2a8966e0336f.tar.gz dreambuilder_modpack-4c9e8e6bf06b09b3a015bd7d76ea2a8966e0336f.tar.bz2 dreambuilder_modpack-4c9e8e6bf06b09b3a015bd7d76ea2a8966e0336f.tar.xz dreambuilder_modpack-4c9e8e6bf06b09b3a015bd7d76ea2a8966e0336f.zip |
update areasprotector mod, pipeworks, technic
Diffstat (limited to 'technic/machines/HV')
-rw-r--r-- | technic/machines/HV/battery_box.lua | 1 | ||||
-rw-r--r-- | technic/machines/HV/forcefield.lua | 77 |
2 files changed, 74 insertions, 4 deletions
diff --git a/technic/machines/HV/battery_box.lua b/technic/machines/HV/battery_box.lua index 9093ba9..89c65da 100644 --- a/technic/machines/HV/battery_box.lua +++ b/technic/machines/HV/battery_box.lua @@ -1,4 +1,5 @@ -- HV battery box + minetest.register_craft({ output = 'technic:hv_battery_box0', recipe = { diff --git a/technic/machines/HV/forcefield.lua b/technic/machines/HV/forcefield.lua index 3bf93b0..1d46bcf 100644 --- a/technic/machines/HV/forcefield.lua +++ b/technic/machines/HV/forcefield.lua @@ -6,6 +6,8 @@ -- How expensive is the generator? -- Leaves room for upgrades lowering the power drain? +local digilines_path = minetest.get_modpath("digilines") + local forcefield_power_drain = 10 local S = technic.getter @@ -90,7 +92,14 @@ local function update_forcefield(pos, meta, active, first) end local function set_forcefield_formspec(meta) - local formspec = "size[5,2.25]".. + local formspec + if digilines_path then + formspec = "size[5,3.25]".. + "field[0.3,3;5,1;channel;Digiline Channel;"..meta:get_string("channel").."]" + else + formspec = "size[5,2.25]" + end + formspec = formspec.. "field[0.3,0.5;2,1;range;"..S("Range")..";"..meta:get_int("range").."]" -- The names for these toggle buttons are explicit about which -- state they'll switch to, so that multiple presses (arising @@ -130,9 +139,10 @@ local forcefield_receive_fields = function(pos, formname, fields, sender) update_forcefield(pos, meta, false) end if range then meta:set_int("range", range) end - if fields.shape0 then meta:set_int("shape", 0) end - if fields.shape1 then meta:set_int("shape", 1) end - if fields.enable then meta:set_int("enabled", 1) end + if fields.channel then meta:set_string("channel", fields.channel) end + if fields.shape0 then meta:set_int("shape", 0) end + if fields.shape1 then meta:set_int("shape", 1) 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 @@ -150,6 +160,60 @@ local mesecons = { } } +local digiline_def = { + receptor = {action = function() end}, + effector = { + action = function(pos, node, channel, msg) + local meta = minetest.get_meta(pos) + if channel ~= meta:get_string("channel") then + return + end + msg = msg:lower() + if msg == "get" then + digilines.receptor_send(pos, digilines.rules.default, channel, { + enabled = meta:get_int("enabled"), + range = meta:get_int("range"), + shape = meta:get_int("shape") + }) + return + elseif msg == "off" then + meta:set_int("enabled", 0) + elseif msg == "on" then + meta:set_int("enabled", 1) + elseif msg == "toggle" then + local onn = meta:get_int("enabled") + onn = 1-onn -- Mirror onn with pivot 0.5, so switch between 1 and 0. + meta:set_int("enabled", onn) + elseif msg:sub(1, 5) == "range" then + local range = tonumber(msg:sub(7)) + if not range then + return + end + range = math.max(range, 5) + range = math.min(range, 20) + update_forcefield(pos, meta, false) + meta:set_int("range", range) + elseif msg:sub(1, 5) == "shape" then + local shape = msg:sub(7):lower() + if shape == "sphere" then + shape = 0 + elseif shape == "cube" then + shape = 1 + end + shape = tonumber(shape) + if not shape then + return + end + update_forcefield(pos, meta, false) + meta:set_int("shape", shape) + else + return + end + set_forcefield_formspec(meta) + end + }, +} + local function run(pos, node) local meta = minetest.get_meta(pos) local eu_input = meta:get_int("HV_EU_input") @@ -205,10 +269,14 @@ minetest.register_node("technic:forcefield_emitter_off", { meta:set_int("enabled", 0) meta:set_int("mesecon_mode", 0) meta:set_int("mesecon_effect", 0) + if digilines_path then + meta:set_string("channel", "forcefield"..minetest.pos_to_string(pos)) + end meta:set_string("infotext", S("%s Forcefield Emitter"):format("HV")) set_forcefield_formspec(meta) end, mesecons = mesecons, + digiline = digiline_def, technic_run = run, }) @@ -224,6 +292,7 @@ minetest.register_node("technic:forcefield_emitter_on", { update_forcefield(pos, meta, false) end, mesecons = mesecons, + digiline = digiline_def, technic_run = run, technic_on_disable = function (pos, node) local meta = minetest.get_meta(pos) |