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

[1.7] turtle.refuel: expected number

Started by HDeffo, 10 February 2016 - 06:46 PM
HDeffo #1
Posted 10 February 2016 - 07:46 PM
VERSION:


1.73

(I cant currently test this on current CC versions if anyone else can for me it would be nice of you)

DESCRIPTION:


calling
turtle.refuel(nil)
returns an error "expected number"

EXPECTED RESULT:


turtle to refuel using all items in slot without an error as if i called
turtle.refuel()

REPRODUCTION STEPS:


simply call
turtle.refuel(nil)
Edited on 10 February 2016 - 06:56 PM
Creator #2
Posted 10 February 2016 - 07:54 PM
It wants to know how much.
Do something of the likes of


turtle.refuel(anArgumentPassedToTheFunctionOrProgram or 1)
HDeffo #3
Posted 10 February 2016 - 07:55 PM
It wants to know how much.
Do something of the likes of


turtle.refuel(anArgumentPassedToTheFunctionOrProgram or 1)

the amount in turtle.refuel is optional if no amount is passed its suppose to use all fuel in that slot
Edited on 10 February 2016 - 06:55 PM
SquidDev #4
Posted 10 February 2016 - 08:34 PM
This is the case for many functions. The Java side only checks if x arguments were passed, but should also check that that argument is not null.
HDeffo #5
Posted 10 February 2016 - 08:37 PM
This is the case for many functions. The Java side only checks if x arguments were passed, but should also check that that argument is not null.

surprised ive never noticed this bug before….it makes it really difficult to wrap any functions with optional arguments that are passed java side
Wojbie #6
Posted 11 February 2016 - 08:24 AM
It wants to know how much.
Do something of the likes of


turtle.refuel(anArgumentPassedToTheFunctionOrProgram or 1)

the amount in turtle.refuel is optional if no amount is passed its suppose to use all fuel in that slot

Then just use

turtle.refuel(anArgumentPassedToTheFunctionOrProgram or 64)

That way if nothing is passed it will ate all in selected slot (cause its never more than 64). Or choose like 1000 if you want to be safe. Cause you can always overstate for turtle.refuel()

surprised ive never noticed this bug before….it makes it really difficult to wrap any functions with optional arguments that are passed java side
It just means you have to add some extra logic here and there. Its not that big problem truthfully. You just have to play with stuff a bit.
Edited on 11 February 2016 - 07:36 AM
HDeffo #7
Posted 11 February 2016 - 10:43 AM
no its not a big issue persay but still an inconvenience i just switched the code to

local ok = iAmount and turtle.refuel(iAmount) or turtle.refuel()