Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --//Declarar variables // Nivel de combustible actual y anterior
- fuelLevel = 0
- fuelLevel2 = 0
- --//Funciones que se usarán en el menú (última instrucctión escrita)
- local function PressAnyKey()
- print("")
- print("press any key to continue...")
- os.pullEvent("key")
- end
- local function Clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local function DropItem(i)
- --//Si queda algún item en el espacio seleccionado, lo transfiere al último espacio o bien lo suelta/tira/droppea.
- if turtle.getItemCount(i) ~= 0 then
- if not(turtle.transferTo(16)) then
- Clear()
- print("I can't move this item from slot ".. i .." to slot 16.")
- print("Should i drop it?")
- print("1.- KEEP IT ...please...")
- print("2.- DROP IT")
- dropIt = read()
- if dropIt == "2" then
- turtle.dropUp()
- Clear()
- elseif dropIt == "1" then
- print("Ok, i'll keep it where it is.")
- PressAnyKey()
- Clear()
- else
- print("That's not one of the options, but ok, i'll drop it.")
- PressAnyKey()
- Clear()
- turtle.drop()
- end
- end
- end
- end
- local function Consume(i)
- if turtle.refuel() then
- fuelLevel2 = turtle.getFuelLevel()
- DropItem(i)
- else
- DropItem(i)
- end
- end
- --//Bucle de acciones, Selecciona el espacio especificado en "i" y si es válido, lo consume como combustible.
- --// "i" hace referencia al espacio en el inventario de la tortuga
- local function Refuel()
- fuelLevel = turtle.getFuelLevel()
- for i = 1, 15, 1 do
- turtle.select(i)
- Consume(i)
- end
- fuelLevel2 = turtle.getFuelLevel()
- --//Imprime el nivel de combustible si ya ha cambiado respecto a la última vez.
- if fuelLevel ~= fuelLevel2 then
- print("I'm done...")
- print("")
- print("My fuel level is now: ".. fuelLevel2 ..".")
- else
- print("There was no fuel available for me to use, and my fuel level stayed at: " .. fuelLevel2 .. ".")
- end
- end
- --//MainMenu
- while true do
- Clear()
- print("Do you want to give me some fuel?")
- print("1.- YES")
- print("2.- MAYBE LATER")
- selection = read()
- if selection == "1" then
- Clear()
- print("Please place fuel in my inventory, except for the bottom right slot, that's for me to use.")
- PressAnyKey()
- Clear()
- Refuel()
- PressAnyKey()
- elseif selection == "2" then
- print("See you later then.")
- PressAnyKey()
- break
- else
- print("Please enter the number 1 or 2 depending on what you want to do.")
- PressAnyKey()
- end
- end
- --//pastebin run HYa4eY5t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement