This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Mimifan2's profile picture

HELP Power Status Bar

Started by Mimifan2, 02 July 2014 - 12:43 AM
Mimifan2 #1
Posted 02 July 2014 - 02:43 AM
I'm new to computercraft, but have a good amount of knowledge of other programming languages and I don't understand why I am getting this error.
I'm writing a program to read the energy level from an energy cell ( using a comparator). The signal is then being broken down into three groups, Green, Red, Yellow, then sent by rednet to another computer. This computer is where the problem lies. I'm getting an error "bios:366: [string "startup"]:13: syntax error"

http://pastebin.com/1i3Z3yLx

Any help would be greatly appreciated and if you are interested in the other part I can pastebin that as well, just comment.
  • rednet.open("left")
  • while true do
  • local level = rednet.receive()
  • if level == "Green" then
  • rs.setOutput("top" , true)
  • rs.setOutput("front", true)
  • rs.setOutput("right", true)
  • end
  • if level == "Yellow" then
  • rs,setOutput("front", true)
  • rs.setOutput("right", true)
  • rs.setOutput("top", false)
  • end
  • if level == "Red" then
  • rs.setOutput("right", true)
  • rs.setOutput("top", false)
  • rs.setOutput("front", false)
  • end
  • os.sleep(600)
  • end
joebodo #2
Posted 02 July 2014 - 04:03 AM
Line 12 has a comma instead of a period. rs<comma>setOutput
Mimifan2 #3
Posted 02 July 2014 - 03:43 PM
Thanks, that fixed the problem however now i am getting an error "bios : 366:[string "startup"]:6: ')' expected" Thanks again
KingofGamesYami #4
Posted 02 July 2014 - 05:07 PM
there is no reason that error should occur in the script given. Let's take apart your error:
bios : 336:[string "startup"] This means the error is an error in your typing, in the program "startup"
:6: The error occured on line 6
: ')' expected It wanted a ) to close a previous (.

I'm guessing you are missing ) on line 5 of the script you are running, but not the one you posted.
Mimifan2 #5
Posted 02 July 2014 - 07:27 PM
Here is the new code, still have the same error.
http://pastebin.com/PtDyUVJg
  • rednet.open("left")
  • while true do
  • local level = rednet.receive()
  • if level =="G" then
  • rs.setOutput("top". true)
  • rs.setOutput("front". true)
  • rs.setOutput("right". true)
  • end
  • if level == "Y" then
  • rs,setOutput("front". true)
  • rs.setOutput("right". true)
  • rs.setOutput("top". false)
  • end
  • if level == "R" then
  • rs.setOutput("right". true)
  • rs.setOutput("top". false)
  • rs.setOutput("front". false)
  • end
  • os.sleep(60)
  • end

Thanks for explaining the debugging i was not 100% sure that's how it worked. There is no ( on line 5 so I'm not sure why that error would occur.
KingofGamesYami #6
Posted 02 July 2014 - 07:53 PM
Yeah, the only thing I can see out of place is

if level =="G" then
try changing to

if level == "G" then

Are you sure this is the exact script?
Cranium #7
Posted 02 July 2014 - 07:54 PM
On a side note, I'd recommend you put your code in
 tags. There's a button for it in the editor, that looks like this: <>
It looks so much better if you do.
Lyqyd #8
Posted 02 July 2014 - 07:56 PM
You can't use periods to separate your function call arguments. Change them to commas.
Mimifan2 #9
Posted 03 July 2014 - 02:44 AM
Got it to work after some final teeks, if your interested let me know and i will put it on pastebin