mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 19:56:17 -04:00
Update refuel.lua
I hope this works.
This commit is contained in:
parent
8c0c808037
commit
70e02e657e
@ -1 +1,38 @@
|
||||
-- TODO Vexatos
|
||||
--[[ Makes the robot refuel itself using fuel from the inventory and lets you get the current fuel count.
|
||||
Author: Vexatos]]
|
||||
local component = require("component")
|
||||
local shell = require("shell")
|
||||
|
||||
local args = shell.parse(...)
|
||||
|
||||
local function printUsage()
|
||||
print("Usages:")
|
||||
print("'refuel' to get the current fuel count")
|
||||
print("'refuel <slot>' to refuel from that specific slot")
|
||||
print("'refuel all' to refuel from all slots")
|
||||
end
|
||||
|
||||
if component.isAvailable("generator") then
|
||||
local g = component.generator
|
||||
if args[1] = nil then
|
||||
print("Current Number of items in generator: "..g.count())
|
||||
elseif string.match(args[1],"%d") ~= nil then
|
||||
print("Refuelling from slot"..args[1].."...")
|
||||
local success, msg = g.insert(tonumber(args[1]))
|
||||
if success then
|
||||
print("Success.")
|
||||
else
|
||||
print("Error: "..msg)
|
||||
end
|
||||
elseif string.lower(args[1]) = "all" then
|
||||
io.write("Refuelling from all slots...")
|
||||
for i = 1, 16 do
|
||||
g.insert(i)
|
||||
end
|
||||
print("Done.")
|
||||
else
|
||||
printUsage()
|
||||
end
|
||||
else
|
||||
print("This program requires the generator upgrade to be installed.")
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user