SHOW:
|
|
- or go back to the newest paste.
| 1 | {
| |
| 2 | NOT = "local args = {...}\
| |
| 3 | local input = args[1]\ | |
| 4 | local n = nil\ | |
| 5 | local on = false\ | |
| 6 | if args[2] then\ | |
| 7 | n = args[2]\ | |
| 8 | if n ~= \"1\" or n ~= \"0\" then\ | |
| 9 | n = \"1\"\ | |
| 10 | end\ | |
| 11 | else\ | |
| 12 | n = \"1\"\ | |
| 13 | end\ | |
| 14 | while true do\ | |
| 15 | sleep(0)\ | |
| 16 | for k,v in pairs(rs.getSides()) do\ | |
| 17 | if v ~= input then\ | |
| 18 | rs.setOutput(v,on)\ | |
| 19 | end\ | |
| 20 | end\ | |
| 21 | if rs.getInput(input) then\ | |
| 22 | if n == \"1\" then\ | |
| 23 | on = true\ | |
| 24 | elseif n == \"0\" then\ | |
| 25 | on = false\ | |
| 26 | end\ | |
| 27 | else\ | |
| 28 | if n == \"1\" then\ | |
| 29 | on = false\ | |
| 30 | elseif n == \"0\" then\ | |
| 31 | on = true\ | |
| 32 | end\ | |
| 33 | end\ | |
| 34 | end\ | |
| 35 | ", | |
| 36 | rep = "local args = {...}\
| |
| 37 | local inp = args[1]\ | |
| 38 | local out = args[2]\ | |
| 39 | local delay = args[3]\ | |
| 40 | while true do\ | |
| 41 | sleep(0)\ | |
| 42 | if rs.getInput(inp) then\ | |
| 43 | sleep(tonumber(delay))\ | |
| 44 | rs.setOutput(out,true)\ | |
| 45 | else\ | |
| 46 | sleep(tonumber(delay))\ | |
| 47 | rs.setOutput(out,false)\ | |
| 48 | end\ | |
| 49 | end\ | |
| 50 | ", | |
| 51 | inverter = "local args = {...}\
| |
| 52 | local input = args[1]\ | |
| 53 | local output = args[2]\ | |
| 54 | \ | |
| 55 | local sleep = function()\ | |
| 56 | os.queueEvent(\"hi\")\ | |
| 57 | coroutine.yield()\ | |
| 58 | end\ | |
| 59 | \ | |
| 60 | while true do\ | |
| 61 | sleep(0)\ | |
| 62 | if rs.getInput(input) then\ | |
| 63 | rs.setOutput(output,false)\ | |
| 64 | elseif not rs.getInput(input) then\ | |
| 65 | rs.setOutput(output,true)\ | |
| 66 | end\ | |
| 67 | end\ | |
| 68 | ", | |
| 69 | OR = "local args = {...}\
| |
| 70 | local out = args[1]\ | |
| 71 | local n = \"test\"\ | |
| 72 | if args[2] then\ | |
| 73 | n = args[2]\ | |
| 74 | else\ | |
| 75 | n = \"1\"\ | |
| 76 | end\ | |
| 77 | local on = false\ | |
| 78 | while true do\ | |
| 79 | sleep(0)\ | |
| 80 | rs.setOutput(out,on)\ | |
| 81 | if n == \"1\" then\ | |
| 82 | on = false\ | |
| 83 | elseif n == \"0\" then\ | |
| 84 | on = true\ | |
| 85 | end\ | |
| 86 | for k,v in pairs(rs.getSides()) do\ | |
| 87 | if v ~= out then\ | |
| 88 | if n == \"1\" then\ | |
| 89 | if on ~= true then\ | |
| 90 | if rs.getInput(v) then\ | |
| 91 | on = true\ | |
| 92 | end\ | |
| 93 | end\ | |
| 94 | elseif n == \"0\" then\ | |
| 95 | if on ~= false then\ | |
| 96 | if rs.getInput(v) then\ | |
| 97 | on = false\ | |
| 98 | end\ | |
| 99 | end\ | |
| 100 | end\ | |
| 101 | end\ | |
| 102 | end\ | |
| 103 | end\ | |
| 104 | ", | |
| 105 | AND = "local args = {...}\
| |
| 106 | local s1 = args[1]\ | |
| 107 | local s2 = args[2]\ | |
| 108 | local out = args[3]\ | |
| 109 | if args[4] then\ | |
| 110 | local n = args[4]\ | |
| 111 | else\ | |
| 112 | n = \"1\"\ | |
| 113 | end\ | |
| 114 | if n == \"1\" then\ | |
| 115 | while true do\ | |
| 116 | if rs.getInput(s1) and rs.getInput(s2) then\ | |
| 117 | rs.setOutput(out,true)\ | |
| 118 | else\ | |
| 119 | rs.setOutput(out,false)\ | |
| 120 | end\ | |
| 121 | sleep(0)\ | |
| 122 | end\ | |
| 123 | elseif n == \"0\" then\ | |
| 124 | while true do\ | |
| 125 | if rs.getInput(s1) and rs.getInput(s2) then\ | |
| 126 | rs.setOutput(out,false)\ | |
| 127 | else\ | |
| 128 | rs.setOutput(out,true)\ | |
| 129 | end\ | |
| 130 | sleep(0)\ | |
| 131 | end\ | |
| 132 | end\ | |
| 133 | ", | |
| 134 | } |