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

[Error] Bad Argument

Started by Calacene, 09 August 2012 - 06:16 AM
Calacene #1
Posted 09 August 2012 - 08:16 AM
Any help is very appreciated.

I have fairly little experience with programming, but am trying to create an "elevator" with redpower and CC.

The exact bug I'm receiving is:

bit:40: bad argument: double expected, got nil


Now, because of my low level of experience, the code is probably much longer than it needs to be/should be.

I've included it here, on pastebin - http://pastebin.com/cF02sGQf

Thanks,
sjele #2
Posted 09 August 2012 - 09:32 AM
Probebly caused by
I think you can use 0 as what line to turn of/on.


local function up()
rs.setBundledOutput("right", colors.white)
sleep(1)
rs.setBundledOutput("right", 0)
end


If you want to turn it of, just use, there is probebly a line to turn it off, but i just turn on another line, witch them turnes white off.

rs.setBundledOutput ("back", colors.red)


Change it too

local function up()
rs.setBundledOutput("right", colors.white)
sleep(1)
rs.setBundledOutput("right", colors.red)   --Change red to a unsued color.
end


Do the same with down() function
Calacene #3
Posted 09 August 2012 - 09:42 AM
On the wiki it says : rs.setBundledOutput(string side, int colors) Sets one or multiple colored signals in a redpower bundled wire connected to Side. In order to set multiple signals, add the color values of the colors you want to activate. To turn off all of the values, use 0 for the integer.


I did try your suggestion, though, but got the same error.
Pharap #4
Posted 09 August 2012 - 10:40 AM
On lines 39 and 41, you haven't got your arguments touching the function name eg:

if colors.test (updown, colors.white) == true then
should be

if colors.test(updown, colors.white) == true then

Try removing those spaces (all all the others, line the ones on lines 24 and 26)
Luanub #5
Posted 09 August 2012 - 12:03 PM
Rather then using colors.test() and rs.getBundledInput() like you are I would just use rs.testBundledInput() it does the same thing but is much cleaner and less error prone as well.

So you can replace stuff like this:

local updown = rs.getBundledInput("left")
if colors.test (updown, colors.white) == true then
 up()
elseif colors.test (updown, colors.orange) == true then
 down()
end

With:

if rs.testBundledInput("left", colors.white) then
  up()
elseif rs.testBundledInput("left", colors.orange) then
  down()
end
Calacene #6
Posted 09 August 2012 - 07:46 PM
I went through and removed all of the false spaces (as far as I can see), and changed the colors.test to rs.testBundle…etc.
However, now I'm getting a different error:

Elevator:591: bad argument: int expected, got nil

I've included the updated code, as well.

http://pastebin.com/BmAd9diJ
Luanub #7
Posted 09 August 2012 - 09:37 PM
So there are two different colors API. colors for American's, and colours for the British. In the colors API the color grey is spelt gray, and in the colours API it is spelt grey.

Since you are using colors, you will need to change it from grey to gray. Same thing with lightGray.
Cranium #8
Posted 09 August 2012 - 09:49 PM
So there are two different colors API. colors for American's, and colours for the British. In the colors API the color grey is spelt gray, and in the colours API it is spelt grey.

Since you are using colors, you will need to change it from grey to gray. Same thing with lightGray.
I did not know that…. WHy would that be such a problem? Why not use either interchangeably?
Calacene #9
Posted 09 August 2012 - 10:06 PM
Ahhh, thank you ;)/>/>
Not getting any errors, any more.

However… none of the call buttons are working (though the up/down buttons work great) … hmm


*edit*

Okay, I figured out that problem, which was just something about the wiring, but for some reason, if the elevator is on floor one, and I call to the basement, it goes to floor 2, or if I call from floor 2, it goes to the basement, etc.

*edit (again)*

I ended up swapping the up() and down() functions, and then swapping the used function in the two up/down bits of code, and it works.

still, if anyone could tell me why it did that, that would be nice.
Pharap #10
Posted 10 August 2012 - 01:51 AM
So there are two different colors API. colors for American's, and colours for the British. In the colors API the color grey is spelt gray, and in the colours API it is spelt grey.

Since you are using colors, you will need to change it from grey to gray. Same thing with lightGray.
I did not know that…. WHy would that be such a problem? Why not use either interchangeably?
It's probably because people constantly argue over which spellings are correct and why, and for the following reason:

Get your self an Englishman and an American, tell each of them to use the colours API to do something with the grey cable. The american will instinctively drop the u, typing colors and type grey as gray. The Englishman will do the opposite, retain the u and write grey as opposed to gray.

By having two different APIs doing pretty much the same thing, it means that when the Englishman and the American have finished, both of them will have done things correctly since neither of them technically made a spelling mistake (at least in the eyes of lua).

Also, if someone writes colors, they are unlikely to use the spelling grey and vice versa since these things go hand in hand.
Pharap #11
Posted 10 August 2012 - 01:54 AM
Ahhh, thank you ;)/>/>
Not getting any errors, any more.

However… none of the call buttons are working (though the up/down buttons work great) … hmm


*edit*

Okay, I figured out that problem, which was just something about the wiring, but for some reason, if the elevator is on floor one, and I call to the basement, it goes to floor 2, or if I call from floor 2, it goes to the basement, etc.

*edit (again)*

I ended up swapping the up() and down() functions, and then swapping the used function in the two up/down bits of code, and it works.

still, if anyone could tell me why it did that, that would be nice.

Probably related to how you had things wired up. You probably got your wires crossed (so to speak) meaning the process for up caused output for the down circuit, and vice versa.
It's good that someone's actually been able to do a working CC elevator though. It's still on my list, but I want to get other stuff out the way first.
Cranium #12
Posted 10 August 2012 - 01:58 AM
It's probably because people constantly argue over which spellings are correct and why, and for the following reason:

Get your self an Englishman and an American, tell each of them to use the colours API to do something with the grey cable. The american will instinctively drop the u, typing colors and type grey as gray. The Englishman will do the opposite, retain the u and write grey as opposed to gray.

By having two different APIs doing pretty much the same thing, it means that when the Englishman and the American have finished, both of them will have done things correctly since neither of them technically made a spelling mistake (at least in the eyes of lua).

Also, if someone writes colors, they are unlikely to use the spelling grey and vice versa since these things go hand in hand.
What I mean is being able to have both do the same thing, in the same api, and being able to use both sides interchangeably. I am an american, so I use color of course, but I was raised to write grey. Not gray. It has been hard to get used to when I'm coding, and I just wish they would get along already!
Calacene #13
Posted 10 August 2012 - 02:54 AM
Ahhh, thank you ;)/>/>
Not getting any errors, any more.

However… none of the call buttons are working (though the up/down buttons work great) … hmm


*edit*

Okay, I figured out that problem, which was just something about the wiring, but for some reason, if the elevator is on floor one, and I call to the basement, it goes to floor 2, or if I call from floor 2, it goes to the basement, etc.

*edit (again)*

I ended up swapping the up() and down() functions, and then swapping the used function in the two up/down bits of code, and it works.

still, if anyone could tell me why it did that, that would be nice.

Probably related to how you had things wired up. You probably got your wires crossed (so to speak) meaning the process for up caused output for the down circuit, and vice versa.
It's good that someone's actually been able to do a working CC elevator though. It's still on my list, but I want to get other stuff out the way first.

Well I suppose it doesn't really matter, as long as it works. Thanks though :(/>/>
Pharap #14
Posted 11 August 2012 - 02:41 AM
It's probably because people constantly argue over which spellings are correct and why, and for the following reason:

Get your self an Englishman and an American, tell each of them to use the colours API to do something with the grey cable. The american will instinctively drop the u, typing colors and type grey as gray. The Englishman will do the opposite, retain the u and write grey as opposed to gray.

By having two different APIs doing pretty much the same thing, it means that when the Englishman and the American have finished, both of them will have done things correctly since neither of them technically made a spelling mistake (at least in the eyes of lua).

Also, if someone writes colors, they are unlikely to use the spelling grey and vice versa since these things go hand in hand.
What I mean is being able to have both do the same thing, in the same api, and being able to use both sides interchangeably. I am an american, so I use color of course, but I was raised to write grey. Not gray. It has been hard to get used to when I'm coding, and I just wish they would get along already!

I get what you're saying, but I must admit, you are one very rare American. You could edit the api yourself (which would only work for single-player or a server you're running ofc) but I'll be fair, so long as there is one American who uses the English spelling, I say they should allow grey in colors.

The argument will never go away. The American spelling variation is born from the want to have independance, but ultimately they didn't create the language, they inherited it. Like Belgium and Canada with French (I like Belgium and Canada ;)/>/>), technically they inherited it from France.
But yeah, in short it comes down to one country's want for independence and another country's pride/love for its language. It's kind of like a copyright argument, which almost never end particularly nicely.

I've rambled enough. If we get me arguing over this, there will be no end to it. Frankly I'm just thankful CC bothered to make one for each country :(/>/>
Lyqyd #15
Posted 11 August 2012 - 02:55 AM
It's probably because people constantly argue over which spellings are correct and why, and for the following reason:

Get your self an Englishman and an American, tell each of them to use the colours API to do something with the grey cable. The american will instinctively drop the u, typing colors and type grey as gray. The Englishman will do the opposite, retain the u and write grey as opposed to gray.

By having two different APIs doing pretty much the same thing, it means that when the Englishman and the American have finished, both of them will have done things correctly since neither of them technically made a spelling mistake (at least in the eyes of lua).

Also, if someone writes colors, they are unlikely to use the spelling grey and vice versa since these things go hand in hand.
What I mean is being able to have both do the same thing, in the same api, and being able to use both sides interchangeably. I am an american, so I use color of course, but I was raised to write grey. Not gray. It has been hard to get used to when I'm coding, and I just wish they would get along already!

I get what you're saying, but I must admit, you are one very rare American. You could edit the api yourself (which would only work for single-player or a server you're running ofc) but I'll be fair, so long as there is one American who uses the English spelling, I say they should allow grey in colors.

The argument will never go away. The American spelling variation is born from the want to have independance, but ultimately they didn't create the language, they inherited it. Like Belgium and Canada with French (I like Belgium and Canada ;)/>/>), technically they inherited it from France.
But yeah, in short it comes down to one country's want for independence and another country's pride/love for its language. It's kind of like a copyright argument, which almost never end particularly nicely.

I've rambled enough. If we get me arguing over this, there will be no end to it. Frankly I'm just thankful CC bothered to make one for each country :(/>/>

Um, no. Standardized spelling is somewhat recent. For instance, "shown" was spelled "shewn" in the Declaration of Independence. It's more likely to be a case of different spellings becoming standard than an act of defiance or similar silliness.
Pharap #16
Posted 11 August 2012 - 03:03 AM
It's probably because people constantly argue over which spellings are correct and why, and for the following reason:

Get your self an Englishman and an American, tell each of them to use the colours API to do something with the grey cable. The american will instinctively drop the u, typing colors and type grey as gray. The Englishman will do the opposite, retain the u and write grey as opposed to gray.

By having two different APIs doing pretty much the same thing, it means that when the Englishman and the American have finished, both of them will have done things correctly since neither of them technically made a spelling mistake (at least in the eyes of lua).

Also, if someone writes colors, they are unlikely to use the spelling grey and vice versa since these things go hand in hand.
What I mean is being able to have both do the same thing, in the same api, and being able to use both sides interchangeably. I am an american, so I use color of course, but I was raised to write grey. Not gray. It has been hard to get used to when I'm coding, and I just wish they would get along already!

I get what you're saying, but I must admit, you are one very rare American. You could edit the api yourself (which would only work for single-player or a server you're running ofc) but I'll be fair, so long as there is one American who uses the English spelling, I say they should allow grey in colors.

The argument will never go away. The American spelling variation is born from the want to have independance, but ultimately they didn't create the language, they inherited it. Like Belgium and Canada with French (I like Belgium and Canada ;)/>/>), technically they inherited it from France.
But yeah, in short it comes down to one country's want for independence and another country's pride/love for its language. It's kind of like a copyright argument, which almost never end particularly nicely.

I've rambled enough. If we get me arguing over this, there will be no end to it. Frankly I'm just thankful CC bothered to make one for each country :(/>/>

Um, no. Standardized spelling is somewhat recent. For instance, "shown" was spelled "shewn" in the Declaration of Independence. It's more likely to be a case of different spellings becoming standard than an act of defiance or similar silliness.

I said I'm not arguing over this. You can have your theories, I'll have mine, arguing won't change that, so there's no point even going there.
Lyqyd #17
Posted 11 August 2012 - 03:39 AM
It's probably because people constantly argue over which spellings are correct and why, and for the following reason:

Get your self an Englishman and an American, tell each of them to use the colours API to do something with the grey cable. The american will instinctively drop the u, typing colors and type grey as gray. The Englishman will do the opposite, retain the u and write grey as opposed to gray.

By having two different APIs doing pretty much the same thing, it means that when the Englishman and the American have finished, both of them will have done things correctly since neither of them technically made a spelling mistake (at least in the eyes of lua).

Also, if someone writes colors, they are unlikely to use the spelling grey and vice versa since these things go hand in hand.
What I mean is being able to have both do the same thing, in the same api, and being able to use both sides interchangeably. I am an american, so I use color of course, but I was raised to write grey. Not gray. It has been hard to get used to when I'm coding, and I just wish they would get along already!

I get what you're saying, but I must admit, you are one very rare American. You could edit the api yourself (which would only work for single-player or a server you're running ofc) but I'll be fair, so long as there is one American who uses the English spelling, I say they should allow grey in colors.

The argument will never go away. The American spelling variation is born from the want to have independance, but ultimately they didn't create the language, they inherited it. Like Belgium and Canada with French (I like Belgium and Canada ;)/>/>), technically they inherited it from France.
But yeah, in short it comes down to one country's want for independence and another country's pride/love for its language. It's kind of like a copyright argument, which almost never end particularly nicely.

I've rambled enough. If we get me arguing over this, there will be no end to it. Frankly I'm just thankful CC bothered to make one for each country :(/>/>

Um, no. Standardized spelling is somewhat recent. For instance, "shown" was spelled "shewn" in the Declaration of Independence. It's more likely to be a case of different spellings becoming standard than an act of defiance or similar silliness.

I said I'm not arguing over this. You can have your theories, I'll have mine, arguing won't change that, so there's no point even going there.

You have a theory, I stated the accepted facts of the origin and etymology. There's no argument, but you're welcome to your delusions.
Pharap #18
Posted 11 August 2012 - 03:58 AM
It's probably because people constantly argue over which spellings are correct and why, and for the following reason:

Get your self an Englishman and an American, tell each of them to use the colours API to do something with the grey cable. The american will instinctively drop the u, typing colors and type grey as gray. The Englishman will do the opposite, retain the u and write grey as opposed to gray.

By having two different APIs doing pretty much the same thing, it means that when the Englishman and the American have finished, both of them will have done things correctly since neither of them technically made a spelling mistake (at least in the eyes of lua).

Also, if someone writes colors, they are unlikely to use the spelling grey and vice versa since these things go hand in hand.
What I mean is being able to have both do the same thing, in the same api, and being able to use both sides interchangeably. I am an american, so I use color of course, but I was raised to write grey. Not gray. It has been hard to get used to when I'm coding, and I just wish they would get along already!

I get what you're saying, but I must admit, you are one very rare American. You could edit the api yourself (which would only work for single-player or a server you're running ofc) but I'll be fair, so long as there is one American who uses the English spelling, I say they should allow grey in colors.

The argument will never go away. The American spelling variation is born from the want to have independance, but ultimately they didn't create the language, they inherited it. Like Belgium and Canada with French (I like Belgium and Canada ;)/>/>), technically they inherited it from France.
But yeah, in short it comes down to one country's want for independence and another country's pride/love for its language. It's kind of like a copyright argument, which almost never end particularly nicely.

I've rambled enough. If we get me arguing over this, there will be no end to it. Frankly I'm just thankful CC bothered to make one for each country :(/>/>

Um, no. Standardized spelling is somewhat recent. For instance, "shown" was spelled "shewn" in the Declaration of Independence. It's more likely to be a case of different spellings becoming standard than an act of defiance or similar silliness.

I said I'm not arguing over this. You can have your theories, I'll have mine, arguing won't change that, so there's no point even going there.

You have a theory, I stated the accepted facts of the origin and etymology. There's no argument, but you're welcome to your delusions.
The 'delusions' rubbish was just plain uncalled for. I said, I'm not going to debate it, if you want to troll, go troll someone else, but I'm not going to sit here and argue with you.
FuzzyPurp #19
Posted 11 August 2012 - 11:08 AM
Ironically a thread about 'bad arguments' leads you guys into a bad argument.

THREAD LOCKED.