2019-06-01 11:48:33 +00:00
|
|
|
if not turtle then
|
2020-04-18 09:09:40 +00:00
|
|
|
printError("Requires a Turtle")
|
2019-06-01 11:48:33 +00:00
|
|
|
return
|
|
|
|
end
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
if not turtle.craft then
|
2020-04-18 09:09:40 +00:00
|
|
|
print("Requires a Crafty Turtle")
|
2017-05-01 13:32:39 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local tArgs = { ... }
|
2021-06-06 05:52:01 +00:00
|
|
|
local nLimit = tonumber(tArgs[1])
|
|
|
|
|
|
|
|
if not nLimit and tArgs[1] ~= "all" then
|
2020-11-04 14:03:08 +00:00
|
|
|
local programName = arg[0] or fs.getName(shell.getRunningProgram())
|
2021-06-06 05:52:01 +00:00
|
|
|
print("Usage: " .. programName .. " all|<number>")
|
2017-05-17 18:32:21 +00:00
|
|
|
return
|
2017-05-01 13:32:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local nCrafted = 0
|
2020-04-18 09:09:40 +00:00
|
|
|
local nOldCount = turtle.getItemCount(turtle.getSelectedSlot())
|
|
|
|
if turtle.craft(nLimit) then
|
|
|
|
local nNewCount = turtle.getItemCount(turtle.getSelectedSlot())
|
2021-06-06 05:52:01 +00:00
|
|
|
if not nLimit or nOldCount <= nLimit then
|
2017-05-01 13:32:39 +00:00
|
|
|
nCrafted = nNewCount
|
|
|
|
else
|
|
|
|
nCrafted = nOldCount - nNewCount
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if nCrafted > 1 then
|
2020-04-18 09:09:40 +00:00
|
|
|
print(nCrafted .. " items crafted")
|
2017-05-01 13:32:39 +00:00
|
|
|
elseif nCrafted == 1 then
|
2020-04-18 09:09:40 +00:00
|
|
|
print("1 item crafted")
|
2017-05-01 13:32:39 +00:00
|
|
|
else
|
2020-04-18 09:09:40 +00:00
|
|
|
print("No items crafted")
|
2017-05-01 13:32:39 +00:00
|
|
|
end
|