6 posts
Location
Netherlands
Posted 13 May 2012 - 12:00 AM
Dear Minecrafters,
Can someone help me plz.
Im stuck i have some idea's for a friend of mine who is the owner of WolfOS and i help him to make new stuff with it.
But the problem is i wanne use the redpower2 bundle cables and computercraft to give a choice menu and i know how that works,
but i don't know how to use the command.
example: to enable output color red and disable output color red and that yellow stays on
Plz help me all the help is welcome.
King Regards,
KingTamotsu
1111 posts
Location
Portland OR
Posted 13 May 2012 - 12:34 AM
You need to use the colors api in conjunction with the rednet api. Here's an example
c = colors.combine ( c, colors.red )
rs.setBundledOutput("right", c ) -- turns red on
c = colors.combine ( c, colors.yellow )
rs.setBundledOutput("right", c ) -- turns on yellow leaving red on
c = colors.subtract( c, colors.red )
rs.setBundledOutput("right", c ) -- turns off red leaving yellow on
Type help redpower from the terminal for more information.
6 posts
Location
Netherlands
Posted 13 May 2012 - 01:18 AM
luanub
Thnq for the help it works.
You Rock for the nice and quick response !!!!
6 posts
Location
Netherlands
Posted 15 May 2012 - 02:35 PM
hii again,
Im sorry but i have still a question i have made a menu were i can choose to turn on and turn off the lights.
But for some reason it shuts down after minuts i don't know why everyrthing is working fine even when i clik turn on it doensn't turn of the second time i clik it it goes on.
Plz Advice
Greetz KingTamotsu
PS: here is the code
function Farm()
loop = true
tChoices = {}
tChoices[0] = "Turn Lights On"
tChoices[1] = "Turn Lights Off"
tChoices[2] = "Return"
tActions = {}
tActions[0] = function(TurnLightsOn)
term.clear()
term.setCursorPos(1,1)
print("Turning Lights On")
c = colors.combine ( c, colors.red )
rs.setBundledOutput("back", c ) – turns red on
sleep(2)
term.clear()
term.setCursorPos(1,1)
print("Lights are turned On")
sleep(1)
menuNum = 4
loop = false
end
tActions[1] = function(TurnLightsOff)
term.clear()
term.setCursorPos(1,1)
print("Turning Lights Off")
c = colors.subtract ( c, colors.red )
rs.setBundledOutput("back", c ) – turns off red leaving other colors on
sleep(2)
term.clear()
term.setCursorPos(1,1)
print("Lights are turned Off")
sleep(1)
menuNum = 4
loop = false
end
tActions[2] = function(Return)
menuNum = 2
loop = false
end
local nSelection = 0
while loop == true do
term.clear()
term.setCursorPos(1,1)
print(" Lixor " .. version)
print("")
print("Select an option:")
print("")
for nLine = 0, #tChoices do – Iterate through the possible potions, and print them, marking the chosen one
local sLine = "-"
if nSelection == nLine then
sLine = ">"
end
local sLineNum = tostring(nLine)
if #sLineNum < 2 then
sLineNum = "0" .. sLineNum – Prepend a 0 if it's too short
end
sLine = sLine .. tChoices[nLine] – Construct the string we're printing
print(sLine) – Print it
end
local sEvent, nKey = os.pullEvent("key")
if nKey == 200 then
if tChoices[nSelection - 1] then
nSelection = nSelection - 1
end
elseif nKey == 208 then
if tChoices[nSelection + 1] then
nSelection = nSelection + 1
end
elseif nKey == 28 then
if tActions[nSelection] then
tActions[nSelection]()
end
end
end
return
1111 posts
Location
Portland OR
Posted 15 May 2012 - 09:02 PM
Try adding this to the top. There is another way to do it but I cant remember it off the top of my head
c = colors.combine ( c )
1604 posts
Posted 15 May 2012 - 09:43 PM
Try adding this to the top. There is another way to do it but I cant remember it off the top of my head
c = colors.combine ( c )
local c = 0
:P/>/>
colors.combine() returns 0 if you don't give it any arguments, and when you do c = colors.combine( c), c is nil (isn't defined yet), so you give no params to the function.
Also, try to use local variables, globals can mess programs. If some program creates a variable named c with some color values, then you are setting that value to your variable also, getting unexpected results.
Example:
Program 1:
c = 0 -- set c to 0
-- some code
c = colors.combine(c, colors.red) -- add color red to c
-- exit the program
Your program:
c = colors.combine(c) -- set c to c (wich is red because of the other program)
-- some code
rs.setBundledOutput("side", c) -- red is on, if you don't wanted this to happen, there might be a problem