mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-30 21:23:00 +00:00 
			
		
		
		
	Make refuelling a little more flexible
This removes the link between item size and refuel limit, meaning working with other items (such as FE items) is a little easier.
This commit is contained in:
		| @@ -303,7 +303,8 @@ public class TurtleAPI implements ILuaAPI | |||||||
|             case 31: |             case 31: | ||||||
|             { |             { | ||||||
|                 // refuel |                 // refuel | ||||||
|                 int count = parseCount( args, 0 ); |                 int count = optInt( args, 0, Integer.MAX_VALUE ); | ||||||
|  |                 if( count < 0 ) throw new LuaException( "Refuel count " + count + " out of range" ); | ||||||
|                 return tryCommand( context, new TurtleRefuelCommand( count ) ); |                 return tryCommand( context, new TurtleRefuelCommand( count ) ); | ||||||
|             } |             } | ||||||
|             case 32: |             case 32: | ||||||
|   | |||||||
| @@ -6,19 +6,27 @@ if #tArgs > 1 then | |||||||
|     return |     return | ||||||
| elseif #tArgs > 0 then | elseif #tArgs > 0 then | ||||||
|     if tArgs[1] == "all" then |     if tArgs[1] == "all" then | ||||||
|         nLimit = 64 * 16 |         nLimit = nil | ||||||
|     else |     else | ||||||
|         nLimit = tonumber( tArgs[1] ) |         nLimit = tonumber( tArgs[1] ) | ||||||
|  |         if not nLimit then | ||||||
|  |             print("Invalid limit, expected a number or \"all\"") | ||||||
|  |             return | ||||||
|  |         end | ||||||
|     end |     end | ||||||
| end | end | ||||||
|  |  | ||||||
| if turtle.getFuelLevel() ~= "unlimited" then | if turtle.getFuelLevel() ~= "unlimited" then | ||||||
|     for n = 1, 16 do |     for n = 1, 16 do | ||||||
|  |         -- Stop if we've reached the limit, or are fully refuelled. | ||||||
|  |         if (nLimit and nLimit <= 0) or turtle.getFuelLevel() >= turtle.getFuelLimit() then | ||||||
|  |             break | ||||||
|  |         end | ||||||
|  |  | ||||||
|         local nCount = turtle.getItemCount(n) |         local nCount = turtle.getItemCount(n) | ||||||
|         if nLimit > 0 and nCount > 0 and turtle.getFuelLevel() < turtle.getFuelLimit() then |         if nCount > 0 then | ||||||
|             local nBurn = math.min( nLimit, nCount ) |  | ||||||
|             turtle.select( n ) |             turtle.select( n ) | ||||||
|             if turtle.refuel( nBurn ) then |             if turtle.refuel( nLimit ) and nLimit then | ||||||
|                 local nNewCount = turtle.getItemCount(n) |                 local nNewCount = turtle.getItemCount(n) | ||||||
|                 nLimit = nLimit - (nCount - nNewCount) |                 nLimit = nLimit - (nCount - nNewCount) | ||||||
|             end |             end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 SquidDev
					SquidDev