Posted 02 October 2012 - 05:53 AM
I'm working on a program that will toggle on and off a color from any specified side.
Right now I'm trying to work out kinks and tidying up as much as possible.
Only problem on my side is that I have no access to MC to test the code.
If there are any kinks can you write in notes so I can figure it out.(keep it simple, still not good at coding)
I'm also going to make it wait for signals in an indefinite loop to toggle all sides for the same color
or as a router to multiple cabling. (I'll get to that later :3)
Here's the code
Right now I'm trying to work out kinks and tidying up as much as possible.
Only problem on my side is that I have no access to MC to test the code.
If there are any kinks can you write in notes so I can figure it out.(keep it simple, still not good at coding)
I'm also going to make it wait for signals in an indefinite loop to toggle all sides for the same color
or as a router to multiple cabling. (I'll get to that later :3)
Here's the code
Spoiler
local tArgs = {...} --reads the inputs and puts them in a table
local side = tArgs[1]
local color = tArgs[2]
local tColors = { --Table containing all the colors
['white'] = 1, --unknown if this is really needed
['orange'] = 2,
['magenta'] = 4,
['lightBlue'] = 8,
['yellow'] = 16,
['lime'] = 32,
['pink'] = 64,
['gray'] = 128,
['lightGray'] = 256,
['cyan'] = 512,
['purple'] = 1024,
['blue'] = 2048,
['brown'] = 4096,
['green'] = 8192,
['red'] = 16384,
['black'] = 32768}
local tSides = { --table containing all vaild sides
['top'] = top --unknown if this is really needed
['bottom'] = bottom
['left'] = left
['right'] = right
['front'] = front
['back'] = back
}
local function toggle(tSides or side, tColors or color)
--uses the input from the arguments or the input after the program
--runs.
if rs.testBundledOutput(side, color) == true then
colors.subtract(side, color)
else
colors.combine(side, color)
end
end
if not tArgs then --this runs if you just start the program
while true do
term.clear()
setCursor(1,1)
print('This is a redstone toggle system. Please enter a valid side')
print('and color. If a you only put a side, then it will activate')
print('either all the cable signals or the default redstone.')
print('NOTE~ all inputs must be in ALL LOWER CASE!!!')
print('Valid side please: ')
local side = read()
print('Valid color please:')
local color = read()
end
end
toogle()--runs the function normaly with either the table method or
--the input method