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

Error: Bad Argument

Started by LuckyLuke, 23 July 2015 - 01:41 PM
LuckyLuke #1
Posted 23 July 2015 - 03:41 PM
Hi,

i got a problem with that script: pastebin.com/YeR0qrBj

if i run it, i get this errior:

window:247: bad argument, expacted number, got string


I cannot find the error, maybe im blind for now, cause ive been looking for the hole day on that screen :(/>
KingofGamesYami #2
Posted 23 July 2015 - 03:48 PM
Line 23:

        term.setCursorPos(Language.CursorStart)

Language.CursorStart is "1,1", which is a string. The actual error you received should be:


window:247: bad argument, expected number, number, got string

You need to pass it two arguments, and both arguments must be numbers. If you only want a single variable, you could do this:

local myVar = {1,1}
term.setCursorPos( unapck( myVar ) )
LuckyLuke #3
Posted 23 July 2015 - 04:05 PM
Thanks! Now i got it! :)/>

Next Error: windws:247: bad argument: double expected, got nil :(/>
Edited on 23 July 2015 - 02:12 PM
KingofGamesYami #4
Posted 23 July 2015 - 05:10 PM
Check for where you are calling a term. function, and make sure the correct variables are being passed.
LuckyLuke #5
Posted 23 July 2015 - 07:17 PM
Ah, so only infunctional term-funtions gives windows-Error ? :D/>
KingofGamesYami #6
Posted 23 July 2015 - 07:44 PM
Window is actually an API, that is used by multishell. Multishell is automatically launched on all advanced computers in newer versions of CC.

The way window works, it acts as a 'go between' for your program and term. Normally, you're program would error if you called a term function incorrectly, but because window called it instead, the error is generated there.
LuckyLuke #7
Posted 24 July 2015 - 08:35 AM
Thanks, Pro :)/>
Dragon53535 #8
Posted 24 July 2015 - 09:06 AM
We're all just normal users, I severely doubt that many of us do it professionally (Help people on this forums as a job or code specifically with Lua). That being said, if you will post your updated code we can help narrow down the problem further. If the pastebin mentioned at the top is the updated code, then the problem remains the same. But given the nature of the error I will assume not since you're passing nil to a term function that expects a number, a double is a number. Given that, the only thing we've got to go on is that it's a term function erroring, however we do not know which one or where.

tl;dr: Please post your updated code for further assistance.
LuckyLuke #9
Posted 24 July 2015 - 09:32 AM
I'm still working on the Programm, i'v updated the pastebin link above :)/>
Dragon53535 #10
Posted 24 July 2015 - 05:32 PM
As far as I can see, that program shouldn't error. Btw, you can shorten your checkRedstone function to just a single line, or well 3 if you count the header and end lines

local fuction checkRedstone(side)
  rs.setOutput(side,not rs.getOutput(side))
end
LuckyLuke #11
Posted 27 July 2015 - 07:04 AM
Nice :)/>
Thanks for those lines, i'll implement them as soon as possible