Jump to content




Attempt to preform Arithmetic __add error


  • You cannot reply to this topic
7 replies to this topic

#1 SNWLeader

  • Members
  • 71 posts
  • LocationTampa Bay, Florida

Posted 14 October 2012 - 04:08 PM

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.

#2 Doyle3694

  • Members
  • 815 posts

Posted 14 October 2012 - 04:12 PM

whole code would be nice

#3 SNWLeader

  • Members
  • 71 posts
  • LocationTampa Bay, Florida

Posted 14 October 2012 - 04:18 PM

View PostDoyle3694, 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 ardera

  • Members
  • 503 posts
  • LocationGermany

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:
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 SNWLeader

  • Members
  • 71 posts
  • LocationTampa Bay, Florida

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 Doyle3694

  • Members
  • 815 posts

Posted 14 October 2012 - 05:18 PM

Just add:
local WH = 0
local OR = 0
local MA = 0
local LB = 0

at the top

#7 SNWLeader

  • Members
  • 71 posts
  • LocationTampa Bay, Florida

Posted 14 October 2012 - 05:31 PM

I fixed what I was doing. I did a little recoding. :)/>

#8 Doyle3694

  • Members
  • 815 posts

Posted 14 October 2012 - 05:34 PM

Wanna post your code? interested to see how you did it :)/>





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users