Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --constants
- input = "north"
- output = "south"
- pi = util.open("front")
- po = util.open("back")
- --functions
- ADD_A_Im = function()
- return false,false,false,true,true,true
- end
- MOV_A_Im = function()
- return true,true,false,true,true,true
- end
- MOV_A_B = function()
- return true,false,false,true,true,true
- end
- IN_A = function()
- return false,true,false,true,true,true
- end
- MOV_A_Im = function()
- return true,true,false,true,true,true
- end
- MOV_B_A = function()
- return false,false,true,false,true,true
- end
- ADD_B_Im = function()
- return true,false,true,false,true,true
- end
- IN_B = function()
- return false,true,true,false,true,true
- end
- MOV_B_Im = function()
- return true,true,true,false,true,true
- end
- OUT_B = function()
- return true,false,true,true,false,true
- end
- OUT_Im = function()
- return true,true,true,true,false,true
- end
- JNC = function()
- if not rs.getInput("left") then
- return true,true,true,true,true,false
- end
- return true,true,true,true,true,true
- end
- JMP = function()
- return true,true,true,true,true,false
- end
- NOP = function()
- return true,true,true,true,true,true
- end
- decode = function(a,b,c,d)
- ret = 0
- if a then
- ret = 8
- end
- if b then
- ret = ret + 4
- end
- if c then
- ret = ret + 2
- end
- if d then
- ret = ret + 1
- end
- return ret
- end
- --table
- op_table = {ADD_A_Im,MOV_A_B,IN_A,MOV_A_Im,MOV_B_A,ADD_B_Im,IN_B,MOV_B_Im,NOP,OUT_B,NOP,OUT_Im,NOP,NOP,JNC,JMP}
- --main
- while not rs.getInput("top") do
- out = 0
- selA,selB,loadA,loadB,loadO,loadPC = op_table[decode(pi.testBundledInput(input,colors.white),pi.testBundledInput(input,colors.orange),pi.testBundledInput(input,colors.magenta),pi.testBundledInput(input,colors.lightBlue)) + 1]()
- if selA then
- out = colors.white
- end
- if selB then
- out = out + colors.orange
- end
- if loadA then
- out = out + colors.magenta
- end
- if loadB then
- out = out + colors.lightBlue
- end
- if loadO then
- out = out + colors.yellow
- end
- if loadPC then
- out = out + colors.lime
- end
- po.setBundledOutput(output,out)
- os.pullEvent("redstone")
- end
- po.setBundledOutput(output,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement