I am trying to get a system to work through a bundle output to turn on a section of lights when done, but when I try to get through the arithmetic part the darn thing does not work.
I am trying to do this
WH = 1
OR = 2
MA = 4
LB = 8
finalinput = WH + OR + MA + LB
rs.setBundledOutput("back", finalinput)
if you need the whole code comment soon.
Attempt to preform Arithmetic __add error
Started by SNWLeader, Oct 14 2012 04:08 PM
7 replies to this topic
#1
Posted 14 October 2012 - 04:08 PM
#2
Posted 14 October 2012 - 04:12 PM
whole code would be nice
#3
Posted 14 October 2012 - 04:18 PM
Doyle3694, on 14 October 2012 - 04:12 PM, said:
whole code would be nice
here it is. This is just a test experiment on me making a very long working system through one wire.
repeat
term.clear()
term.setCursorPos(1,1)
print("Colors: white, orange, magenta, lightblue")
print("When done type 'done' and press enter key.")
write("Lighting Colors: ")
input = read()
if input == "white" then
WH = 1
elseif input == "orange" then
OR = 2
elseif input == "magenta" then
MA = 4
elseif input == "lightblue" then
LB = 8
else
print("Sorry no such color")
end
until input == "done"
term.clear()
term.setCursorPos(1,1)
print("Turning On input")
textutils.slowPrint(".......")
sleep(1)
finalinput = WH + OR + MA + LB
rs.setBundledOutput("back", finalinput )
#4
Posted 14 October 2012 - 04:33 PM
The problem is, if you enter a color, one of the four variables gets declared, the others NOT.
So your code has to be something like that:
So your code has to be something like that:
repeat
term.clear()
term.setCursorPos(1,1)
print("Colors: white, orange, magenta, lightblue")
print("When done type 'done' and press enter key.")
write("Lighting Colors: ")
input = read()
choosen=0
if input == "white" then
choosen=1
elseif input == "orange" then
choosen=2
elseif input == "magenta" then
choosen=4
elseif input == "lightblue" then
choosen=8
else
print("Sorry no such color")
end
until input == "done"
term.clear()
term.setCursorPos(1,1)
print("Turning On input")
textutils.slowPrint(".......")
sleep(1)
finalinput = choosen
rs.setBundledOutput("back", finalinput )
#5
Posted 14 October 2012 - 05:14 PM
The only thing is I am trying to get it were I type in the colors I want on then I type enter so the lights I typed in turn on.
#6
Posted 14 October 2012 - 05:18 PM
Just add:
local WH = 0 local OR = 0 local MA = 0 local LB = 0at the top
#7
Posted 14 October 2012 - 05:31 PM
I fixed what I was doing. I did a little recoding.
/>
#8
Posted 14 October 2012 - 05:34 PM
Wanna post your code? interested to see how you did it
/>
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











