Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- MC 1.20.1
- Fabric 0.15.11; Create fabric 0.5.1; CC: Tweaked 1.110.3; CC:C Bridge; Wired Redstone 0.7.8.
- This program is her to symplify the management of the IO betwen cc tweaked and wired redstone.
- This program only support DIGITAL IO.
- WRITE YOUR CODE IN THE MAIN FUNCTION test
- To declare a INPUT :
- 1. Write inputUpdt("color of your wire" String,"the side where you plug in your Bundled Cables" String)
- To declare a OUTPUT :
- 1. Create a variable with a name that match with the preactuator. ( in this exemple the preactuator is the Gearshift)
- 2. use : outputUpdt("color of your wire" String, "the side where you plug in your Bundled Cables" String, "the variable you want to link at the output" Bool) to update your output
- Warning ! you can't (for the moment) define INPUT and OUTPUT on the same side.
- In this example, we are constantly moving a mechanical piston in and out.
- The operative part :
- [ Motor ] (warning, supply mecanical energy in the right way round)
- [Gearshift]
- ----[M Piston ]-----------]
- [C1] [C2]
- "Output" The Gearshift connected on White Wire on Left Bundled cable
- "Input" C1 orange Wire connected on right Bundled cable
- "Input" C2 pink Wire connected on right Bundled cable
- ]]
- -- Dont touch here >:|
- shell.run("rm /startup.lua")
- shell.run("pastebin get aD3dF3CA /startup.lua")
- -- input update
- function inputUpdt(color,side)
- local inputState = false
- local colorString = "String"
- local sideString = "String"
- sideString = side
- colorString = color
- case =
- {
- ["white"] = function ()
- if (bit.band(rs.getBundledInput(sideString), colors.white) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["orange"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.orange), 1) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["magenta"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.magenta), 2) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["lightBlue"] = function ()
- if bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.lightBlue), 3) == 1 then
- inputState = true
- else
- inputState = false
- end
- end,
- ["yellow"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.yellow), 4) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["lime"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.lime), 5) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["pink"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.pink), 6) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["gray"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.gray), 7) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["lightGray"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.lightGray), 8) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["cyan"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.cyan), 9) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["purple"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.purple), 10) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["blue"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.blue), 11) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["brown"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.brown), 12) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["green"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.green), 13) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["red"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.red), 14) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["black"] = function ()
- if (bit.blogic_rshift(bit.band(rs.getBundledInput(sideString), colors.black), 15) == 1) then
- inputState = true
- else
- inputState = false
- end
- end,
- ["default"] = function ()
- return "error"
- end
- }
- if case[colorString] then
- case[colorString]()
- else
- case["default"]()
- end
- return inputState
- end
- --Inilisation of the table of Output
- OutputTable = {Bottom = 0, top = 0, back = 0, front = 0, right = 0, left = 0}
- --output update
- function outputUpdt(color, side, var)
- local outputState = false
- local colorString = "String"
- local sideString = "String"
- outputState = var
- sideString = side
- colorString = color
- case =
- {
- ["white"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.white
- end
- end,
- ["orange"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.orange
- end
- end,
- ["magenta"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.magenta
- end
- end,
- ["lightBlue"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.lightBlue
- end
- end,
- ["yellow"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.yellow
- end
- end,
- ["lime"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.lime
- end
- end,
- ["pink"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.pink
- end
- end,
- ["gray"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.gray
- end
- end,
- ["lightGray"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.lightGray
- end
- end,
- ["cyan"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.cyan
- end
- end,
- ["purple"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.purple
- end
- end,
- ["blue"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.blue
- end
- end,
- ["brown"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.brown
- end
- end,
- ["green"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.green
- end
- end,
- ["red"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.red
- end
- end,
- ["black"] = function ()
- if var then
- OutputTable[sideString] = OutputTable[sideString] + colors.black
- end
- end,
- ["default"] = function ()
- return "error"
- end
- }
- if case[colorString] then
- case[colorString]()
- else
- case["default"]()
- end
- end
- -- init
- --système
- firstScan = true
- main = require("main")
- --digital Output "memento", name your outputs here (don't forget to initialise at false).
- pistonRetract = false
- light = false
- -- Memory Variables, feel free to add some Memory variables.
- G7State_0Actual = 0
- G7State_0Future = 0
- -- Loopy-Loop
- while 0 do
- -- Main "OB1" here put your code. (if you can, write your program in another file and link it here)
- main()
- --physical Output Update, don't touch here you little bastard >=]
- for k,v in pairs(OutputTable) do
- rs.setBundledOutput(k, v)
- end
- OutputTable = {Bottom = 0, top = 0, back = 0, front = 0, right = 0, left = 0}
- -- système
- os.sleep(1)
- firstScan = false
- end
- -- CMF = {Stick, INCH's, Goune} --
Add Comment
Please, Sign In to add comment