Posted 28 June 2013 - 02:15 PM
Im writing a code for a banking system using turtles and I am using the minefactory reloaded deep storage unit as the accounts so i can only pull out stacks of 64 at a time(this storage unit can hold nearly 2 billion blocks). I was wondering if there was a way to loop the program to pull out the correct number of stacks in order to fulfill the request for money out of the account. ie. lets say i wanted to pull out 300 dollars then i would have to pull out 5 stacks and then drop 300 then put the remainder back in the account. right now i have it set up so that it checks the number they want and if its with in a certain range then it pulls out the right number of stacks but it is a quite lengthy process the code goes
is there anyway to make this into a loop?
rednet.open("right")
repeat
turtle.turnLeft()
until turtle.compareTo(16) == true
local senderId, message, distance = rednet.receive()
if message <= 64 then
turtle.suck()
elseif message > 64 and <=128 then
turtle.suck()
turtle.suck()
elseif message >128 and <=192 then
turtle.suck()
turtle.suck()
turtle.suck()
elseif message >192 and <=256 then
for i = 1,4 do
turtle.suck()
end
elseif message >256 and <=320 then
for i = 1,5 do
turtle.suck()
end
elseif message >320 and <= 384 then
for i = 1,6 do
turtle.suck()
end
elseif message >384 and <=448 then
for i = 1,7 do
turtle.suck()
end
elseif message >448 and <= 512 then
for i= 1,8 do
turtle.suck()
end
elseif message >512 and <= 576 then
for i= 1,9 do
turtle.suck()
end
elseif message >576 and <= 640 then
for i = 1,10 do
turtle.suck()
end
end
is there anyway to make this into a loop?
Edited by