From 6281dc744dc3951234931a9f44c3bdd353f79df7 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 27 Oct 2017 15:13:31 -0400 Subject: updated boost cart, homedecor modpack, castles modpack, currency, farming-redo, maptools, mesecons, moreblocks, moreores, pipeworks, quartz --- mesecons_fpga/depends.txt | 1 + mesecons_fpga/init.lua | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'mesecons_fpga') diff --git a/mesecons_fpga/depends.txt b/mesecons_fpga/depends.txt index acaa924..a0ba1ef 100644 --- a/mesecons_fpga/depends.txt +++ b/mesecons_fpga/depends.txt @@ -1 +1,2 @@ mesecons +screwdriver? diff --git a/mesecons_fpga/init.lua b/mesecons_fpga/init.lua index 6c462e6..0c56d7d 100644 --- a/mesecons_fpga/init.lua +++ b/mesecons_fpga/init.lua @@ -116,6 +116,45 @@ plg.register_nodes({ after_dig_node = function(pos, node) mesecon.receptor_off(pos, plg.rules[node.name]) end, + on_blast = mesecon.on_blastnode, + on_rotate = function(pos, node, user, mode) + local abcd1 = {"A", "B", "C", "D"} + local abcd2 = {A = 1, B = 2, C = 3, D = 4} + local ops = {"op1", "op2", "dst"} + local dir = 0 + if mode == screwdriver.ROTATE_FACE then -- clock-wise + dir = 1 + if user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), + "FPGA ports have been rotated clockwise.") + end + elseif mode == screwdriver.ROTATE_AXIS then -- counter-clockwise + dir = -1 + if user and user:is_player() then + minetest.chat_send_player(user:get_player_name(), + "FPGA ports have been rotated counter-clockwise.") + end + end + + local meta = minetest.get_meta(pos) + local instr = lcore.deserialize(meta:get_string("instr")) + for i = 1, #instr do + for _, op in ipairs(ops) do + local o = instr[i][op] + if o and o.type == "io" then + local num = abcd2[o.port] + num = num + dir + if num > 4 then num = 1 + elseif num < 1 then num = 4 end + instr[i][op].port = abcd1[num] + end + end + end + + meta:set_string("instr", lcore.serialize(instr)) + plg.update_formspec(pos, instr) + return true + end, }) -- cgit v1.2.3