mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 05:33:00 +00:00 
			
		
		
		
	Allow craft program to craft unlimited items (#807)
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| craft is a program for Crafty Turtles. Craft will craft a stack of items using the current inventory. | ||||
|  | ||||
| ex: | ||||
| "craft" will craft as many items as possible | ||||
| "craft all" will craft as many items as possible | ||||
| "craft 5" will craft at most 5 times | ||||
|   | ||||
| @@ -9,20 +9,19 @@ if not turtle.craft then | ||||
| end | ||||
|  | ||||
| local tArgs = { ... } | ||||
| local nLimit = nil | ||||
| if #tArgs < 1 then | ||||
| local nLimit = tonumber(tArgs[1]) | ||||
|  | ||||
| if not nLimit and tArgs[1] ~= "all" then | ||||
|     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||
|     print("Usage: " .. programName .. " [number]") | ||||
|     print("Usage: " .. programName .. " all|<number>") | ||||
|     return | ||||
| else | ||||
|     nLimit = tonumber(tArgs[1]) | ||||
| end | ||||
|  | ||||
| local nCrafted = 0 | ||||
| local nOldCount = turtle.getItemCount(turtle.getSelectedSlot()) | ||||
| if turtle.craft(nLimit) then | ||||
|     local nNewCount = turtle.getItemCount(turtle.getSelectedSlot()) | ||||
|     if nOldCount <= nLimit then | ||||
|     if not nLimit or nOldCount <= nLimit then | ||||
|         nCrafted = nNewCount | ||||
|     else | ||||
|         nCrafted = nOldCount - nNewCount | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Matthew Wilbern
					Matthew Wilbern