Posted 31 May 2014 - 01:04 AM
Background Knowledge:
I'm 100% new to Lua, and relatively new to the practical side of programming. I basically just threw myself into CC a few hours ago, and threw together this script as a test-run.
The script's purpose is to detect how much fuel a turtle requires, and then to fill it up with the appropriate number of Coal Blocks (800 units of fuel)
The Script:
My Problem:
I like debugging. And I've already had to debug a few little errors I made because of my inexperience with Lua. BUT, when I run this script, I get no response from the console. It seems to run, but nothing happens…which seems impossible, because as I see it, every possible route the program could have taken would have resulted in SOME sort of output to the console.
What I've Done:
I've looked it over a couple dozen times and swapped some stuff around and tried commenting out a few things, but I always end up back here. I can google and backtrack if I've got an error, but I'm kind of at a loss with this one, since it looks perfectly fine to me. I figured with a program this simple, it's most likely blatantly obvious for someone more experienced (either in Lua or in CC ), so I figured I'd ask here for help.
Anyways, thanks in advance.
P.S. Oh, and on an unrelated note, how does one make a spoiler? This site seems to be using unconventional bbcode for the spoiler tag (or it just doesn't show up in the 'Preview Post'…which is possible too).
I'm 100% new to Lua, and relatively new to the practical side of programming. I basically just threw myself into CC a few hours ago, and threw together this script as a test-run.
The script's purpose is to detect how much fuel a turtle requires, and then to fill it up with the appropriate number of Coal Blocks (800 units of fuel)
The Script:
local y = turtle.getFuelLevel()
local totalFuelCap = 100000
local a = True
local slot = 1
y = (totalFuelCap - y)
--[[ COAL BLOCKS ]]--
remainder = y % 800
y = (y - remainder) / 800
if y ~= 0 then
turtle.select(slot)
while a do
if y <= 64 and y > 0 then
turtle.refuel(y)
print("All filled up!")
a = False
elseif y > 64 then
turtle.refuel()
else
print("Left your zipper open.")
a = False
end
slot = slot + 1
turtle.select(slot)
end
else
print("The tank's already full!")
end
turtle.select(1)
My Problem:
I like debugging. And I've already had to debug a few little errors I made because of my inexperience with Lua. BUT, when I run this script, I get no response from the console. It seems to run, but nothing happens…which seems impossible, because as I see it, every possible route the program could have taken would have resulted in SOME sort of output to the console.
What I've Done:
I've looked it over a couple dozen times and swapped some stuff around and tried commenting out a few things, but I always end up back here. I can google and backtrack if I've got an error, but I'm kind of at a loss with this one, since it looks perfectly fine to me. I figured with a program this simple, it's most likely blatantly obvious for someone more experienced (either in Lua or in CC ), so I figured I'd ask here for help.
Anyways, thanks in advance.
P.S. Oh, and on an unrelated note, how does one make a spoiler? This site seems to be using unconventional bbcode for the spoiler tag (or it just doesn't show up in the 'Preview Post'…which is possible too).