-
As the title says. I was trying to be fancy when making this program, but now i keep getting a (added a comment next to where i think the error occurs) -- Prepare Housekeeping Variables
local height = 0
local blockSlot = 0
local ladderSlot = 0
local fuelSlot = 0
local setup = false
local confirmation = ""
-- Fill Housekeeping Variables
while setup ~= true do
term.write("How high would you like to go? ")
height = read()
tonumber(height)
print("What slot contains my fuel?")
fuelSlot = read()
tonumber(fuelSlot)
term.write("What slot contains the ladders? ")
ladderSlot = read()
tonumber(ladderSlot)
term.write("What slot contains my Fodder Blocks? ")
blockSlot = read()
tonumber(blockSlot)
-- Print Housekeeping Variables for verification
print("Ok.")
print("Just to be sure, please review your input.")
print("")
print("Target Block Height: "..height)
print("Fuel Source in slot: "..fuelSlot)
print("Ladders in slot: "..ladderSlot)
print("Fodder Blocks in slot: "..blockSlot)
print("")
print("Is this all correct?")
print("Type 'Yes'(case sensitive) to confirm")
confirmation = read()
if confirmation == "Yes" then
setup = true
print("Alright!")
textutils.slowPrint("Getting Ready...", 10)
textutils.slowPrint("... ", 5)
term.clear()
else
print("Understood.")
textutils.slowPrint("Restarting...", 10)
textutils.slowPrint("... ", 5)
term.clear()
end
end
-- Do the Laddering
for i = 1, height do
turtle.select(blockSlot) -- < (Error Occurs here i think)
turtle.place()
if turtle.up() == false then
turtle.digUp()
end
turtle.select(ladderSlot)
turtle.placeDown()
if turtle.getFuelLevel()<200 then -- Need to Refuel
print("Low Fuel!")
turtle.select(fuelSlot)
if turtle.refuel() ~= true then
print("NO FUEL!!") -- Out of fuel
else
print("Refueled!")
print("New fuel level: "..turtle.getFuelLevel()) -- Print new fuel level after refueling.
end
end
print("Loop complete! "..height.." Blocks left.")
end
print("All Ladders Placed!")``` |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
height = tonumber(height)
if not height then
-- failed to convert to a number.
end |
Beta Was this translation helpful? Give feedback.
-
While using my turtle to run local times = 0
term.write("How many times? ")
times = read()
for i = 1, times do
---rest of functional program goes here. Even after removing the |
Beta Was this translation helpful? Give feedback.
If you need read a number, just do
tonumber(read())