r/ComputerCraft • • Apr 04 '20

Expected number, got number error

I get this strange error: .temp5: bad arguement #2 (expected number, got number)

here is the code: https://imgur.com/a/eadU48o

I cant see what is causing the issue. any help would be great. There are no numbers involved in the second line, how can it not be happy with a number if it expected one?

2 Upvotes

7 comments sorted by

3

u/CommendableCalamari Apr 04 '20

What version of ComputerCraft are you running? If I remember, this is a bug with the 1.12 version of CC - you might be better off switching to CC: Tweaked.

2

u/cursed_yeet Apr 05 '20

I'm running 12.2. convincing the server owner to update everything would be pretty painful. It seems that I put the wrong stuff in some brackets (as explained in a comment below), causing the error. It's just a poorly worded error message ie expected a number as a string but instead just got a (number)

2

u/CommendableCalamari Apr 05 '20

CC should handle both. rednet.receive([timeout]) stems from an older version of CC, but should still be supported today. However, both signatures are broken due to the aforementioned bug.

If you're unable to update your CC version, your only other option is to roll your own receive function, by pulling the rednet_message event.

2

u/dragon53535 Apr 05 '20

rednet.receive([ [string protocolFilter, ] number timeout])

You're trying to set the protocol filter by number and not the timeout. rednet.receive("",10) would fix your issue

1

u/cursed_yeet Apr 05 '20

When changing the lime to that, I still get the same error.

1

u/MyNameIsTrez Apr 04 '20

Could you tell me why there are two end statements and a single break statement when you only need one end statement to close the if statement? Is it part of some code off-screen?

2

u/CommendableCalamari Apr 05 '20

There's a while loop starting on line 3. It's not indented, so it's less obvious.