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

[Lua][Error]Bad argument: int expected, got nil

Started by sebbeviper, 27 June 2012 - 07:50 PM
sebbeviper #1
Posted 27 June 2012 - 09:50 PM
Hello there! I'm currently trying to work out a program that is playing The Edge of Glory(from NBS) on noteblocks. I have set everything up with noteblocks and bundled cables and it works fine for like 5 sec(havent coded more than maybe 6-7 seconds of the song).

After that 5 second mark I get "edge:72:Bad argument: int expected, got nil"

here is my code, I'm sorry if its "messy" or hard to understand, this is one of my first programs and I'm very new to programing overall.


term.clear()
term.setCursorPos(1,1)
print("would you like to hear Edge of glory?")
print("yes")
print("no")
input = read()
answer = "yes"
term.clear()
if input == answer then
print("Enjoy!")
sleep(.2)
rs.setBundledOutput("right", colors.orange)
sleep(.2)
rs.setBundledOutput("right", colors.cyan)
sleep(.1)
rs.setBundledOutput("right", colors.black)
sleep(.1)
rs.setBundledOutput("right", colors.cyan)
sleep(.1)
rs.setBundledOutput("right", colors.black)
sleep(.1)
rs.setBundledOutput("right", colors.cyan)
sleep(.05)
rs.setBundledOutput("right", colors.black)
sleep(.05)
rs.setBundledOutput("right", colors.cyan)
sleep(.3)
rs.setBundledOutput("right", colors.magenta)
sleep(.1)
rs.setBundledOutput("right", colors.black)
sleep(.1)
rs.setBundledOutput("right", colors.magenta)
sleep(.2)
rs.setBundledOutput("right", colors.lightGray)
sleep(.2)
rs.setBundledOutput("right", colors.magenta)
sleep(.2)
rs.setBundledOutput("right", colors.lightGray)
sleep(.2)
rs.setBundledOutput("right", colors.magenta)
sleep(.2)
rs.setBundledOutput("right", colors.lightGray)
sleep(.2)
rs.setBundledOutput("right", colors.white)
sleep(.4)
rs.setBundledOutput("right", colors.magenta)
sleep(.2)
rs.setBundledOutput("right", colors.cyan)
sleep(.2)
rs.setBundledOutput("right", colors.purple)
sleep(.4)
rs.setBundledOutput("right", colors.lime)
sleep(.2)
rs.setBundledOutput("right", colors.purple)
sleep(.2)
rs.setBundledOutput("right", colors.white)
sleep(.2)
rs.setBundledOutput("right", colors.magenta)
sleep(.2)
rs.setBundledOutput("right", colors.yellow)
sleep(.2)
rs.setBundledOutput("right", colors.cyan)
sleep(.2)
rs.setBundledOutput("right", colors.purple)
sleep(.4)
rs.setBundledOutput("right", colors.lime)
sleep(.2)
rs.setBundledOutput("right", colors.lightgray)
sleep(.2)
rs.setBundledOutput("right", colors.magenta)
sleep(.2)
rs.setBundledOutput("right", colors.purple)
sleep(.4)
rs.setBundledOutput("right", colors.blue)
sleep(.2)
rs.setBundledOutput("right", colors.cyan)
sleep(.1)
rs.setBundledOutput("right", colors.black)
sleep(.1)
rs.setBundledOutput("right", colors.cyan)
sleep(.1)
rs.setBundledOutput("right", colors.black)
sleep(.1)
rs.setBundledOutput("right", colors.cyan)
sleep(.05)
rs.setBundledOutput("right", colors.black)
sleep(.05)
rs.setBundledOutput("right", colors.cyan)
sleep(2)

shell.run("reboot")
else
print ("Fine, then fuck you...")
sleep(2)
end
shell.run("reboot")

I know that line 72 is

rs.setBundledOutput("right", colors.magenta)
but i cant figure out what is wrong with it. any help and maybe suggestions on how to make the coding easier would be appreciated
MysticT #2
Posted 27 June 2012 - 09:58 PM
Did you typed it here from your code, or copied it (Ctrl-C and Ctrl-V)?
I'm pretty sure the error is because there's a typo in one of the color names, but I don't see any. So, if you typed it, check your code and see if there's a typo.

Edit:
Just found it:

rs.setBundledOutput("right", colors.lightgray)
should be:

rs.setBundledOutput("right", colors.lightGray)
sebbeviper #3
Posted 27 June 2012 - 10:06 PM
I copied it from my script, and thanks for the fast answer, it was that single capital G that was the problem :P/>/>