diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 21:00:20 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 21:10:04 -0400 |
commit | 888b0ebfec8c2eff9015163549a7e47443cb8665 (patch) | |
tree | 915080159bfaa6ba6e226087c7ce0e8d5464b518 /mesecons/mesecons_gates/init.lua | |
parent | da66780a569712c23ae4f2996cfb4608a9f9d69d (diff) | |
download | dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.tar dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.tar.gz dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.tar.bz2 dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.tar.xz dreambuilder_modpack-888b0ebfec8c2eff9015163549a7e47443cb8665.zip |
"explode" all modpacks into their individual components
(you can't have a modpack buried inside a modpack)
Diffstat (limited to 'mesecons/mesecons_gates/init.lua')
-rw-r--r-- | mesecons/mesecons_gates/init.lua | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/mesecons/mesecons_gates/init.lua b/mesecons/mesecons_gates/init.lua deleted file mode 100644 index f3d6f09..0000000 --- a/mesecons/mesecons_gates/init.lua +++ /dev/null @@ -1,134 +0,0 @@ -local nodebox = { - type = "fixed", - fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }}, -} - -local function gate_rotate_rules(node, rules) - for rotations = 0, node.param2 - 1 do - rules = mesecon.rotate_rules_left(rules) - end - return rules -end - -local function gate_get_output_rules(node) - return gate_rotate_rules(node, {{x=1, y=0, z=0}}) -end - -local function gate_get_input_rules_oneinput(node) - return gate_rotate_rules(node, {{x=-1, y=0, z=0}}) -end - -local function gate_get_input_rules_twoinputs(node) - return gate_rotate_rules(node, {{x=0, y=0, z=1, name="input1"}, - {x=0, y=0, z=-1, name="input2"}}) -end - -local function set_gate(pos, node, state) - local gate = minetest.registered_nodes[node.name] - - if mesecon.do_overheat(pos) then - minetest.remove_node(pos) - mesecon.receptor_off(pos, gate_get_output_rules(node)) - minetest.add_item(pos, gate.drop) - elseif state then - minetest.swap_node(pos, {name = gate.onstate, param2=node.param2}) - mesecon.receptor_on(pos, gate_get_output_rules(node)) - else - minetest.swap_node(pos, {name = gate.offstate, param2=node.param2}) - mesecon.receptor_off(pos, gate_get_output_rules(node)) - end -end - -local function update_gate(pos, node, link, newstate) - local gate = minetest.registered_nodes[node.name] - - if gate.inputnumber == 1 then - set_gate(pos, node, gate.assess(newstate == "on")) - elseif gate.inputnumber == 2 then - local meta = minetest.get_meta(pos) - meta:set_int(link.name, newstate == "on" and 1 or 0) - - local val1 = meta:get_int("input1") == 1 - local val2 = meta:get_int("input2") == 1 - set_gate(pos, node, gate.assess(val1, val2)) - end -end - -function register_gate(name, inputnumber, assess, recipe) - local get_inputrules = inputnumber == 2 and gate_get_input_rules_twoinputs or - gate_get_input_rules_oneinput - local description = "Mesecons Logic Gate: "..name - - local basename = "mesecons_gates:"..name - mesecon.register_node(basename, { - description = description, - inventory_image = "jeija_gate_off.png^jeija_gate_"..name..".png", - paramtype = "light", - paramtype2 = "facedir", - drawtype = "nodebox", - drop = basename.."_off", - selection_box = nodebox, - node_box = nodebox, - walkable = true, - sounds = default.node_sound_stone_defaults(), - assess = assess, - onstate = basename.."_on", - offstate = basename.."_off", - inputnumber = inputnumber - },{ - tiles = {"jeija_microcontroller_bottom.png^".."jeija_gate_off.png^".. - "jeija_gate_"..name..".png"}, - groups = {dig_immediate = 2, overheat = 1}, - mesecons = { receptor = { - state = "off", - rules = gate_get_output_rules - }, effector = { - rules = get_inputrules, - action_change = update_gate - }} - },{ - tiles = {"jeija_microcontroller_bottom.png^".."jeija_gate_on.png^".. - "jeija_gate_"..name..".png"}, - groups = {dig_immediate = 2, not_in_creative_inventory = 1, overheat = 1}, - mesecons = { receptor = { - state = "on", - rules = gate_get_output_rules - }, effector = { - rules = get_inputrules, - action_change = update_gate - }} - }) - - minetest.register_craft({output = basename.."_off", recipe = recipe}) -end - -register_gate("diode", 1, function (input) return input end, - {{"mesecons:mesecon", "mesecons_torch:mesecon_torch_on", "mesecons_torch:mesecon_torch_on"}}) - -register_gate("not", 1, function (input) return not input end, - {{"mesecons:mesecon", "mesecons_torch:mesecon_torch_on", "mesecons:mesecon"}}) - -register_gate("and", 2, function (val1, val2) return val1 and val2 end, - {{"mesecons:mesecon", "", ""}, - {"", "mesecons_materials:silicon", "mesecons:mesecon"}, - {"mesecons:mesecon", "", ""}}) - -register_gate("nand", 2, function (val1, val2) return not (val1 and val2) end, - {{"mesecons:mesecon", "", ""}, - {"", "mesecons_materials:silicon", "mesecons_torch:mesecon_torch_on"}, - {"mesecons:mesecon", "", ""}}) - -register_gate("xor", 2, function (val1, val2) return (val1 or val2) and not (val1 and val2) end, - {{"mesecons:mesecon", "", ""}, - {"", "mesecons_materials:silicon", "mesecons_materials:silicon"}, - {"mesecons:mesecon", "", ""}}) - -register_gate("nor", 2, function (val1, val2) return not (val1 or val2) end, - {{"mesecons:mesecon", "", ""}, - {"", "mesecons:mesecon", "mesecons_torch:mesecon_torch_on"}, - {"mesecons:mesecon", "", ""}}) - -register_gate("or", 2, function (val1, val2) return (val1 or val2) end, - {{"mesecons:mesecon", "", ""}, - {"", "mesecons:mesecon", "mesecons:mesecon"}, - {"mesecons:mesecon", "", ""}}) |