I am actually suprised no one else has said this yet...
The function you posted could be better written as this:
function getbtn()
for i = 1, 4 do
request(81, requestG[i])
id, message = rednet.receive(5)
if(id==81) then
if(message=="true") then
can=false
if(i==1) then
bt1ac()
elseif(i==2) then
bt2ac()
elseif(i==3) then
bt3ac()
elseif(i==4) then
bt4ac()
end
else
can=false
if(i==1) then
bt1inac()
elseif(i==2) then
bt2inac()
elseif(i==3) then
bt3inac()
elseif(i==4) then
bt4inac()
end
end
end
if(i==4) then
print(can)
print(i)
end
end
end -- end function getbtn
This will do the exact same thing, but without the need to keep track of the variable yourself, or to use recursion.
This will utilize a for loop. The i=1 is defining i as the counter variable. Each iteration it will increase by one until it reaches the second number in this case 4, and it will run all code between the start of the for loop and the end associated with it until then.
As KaiKaku said, this code will only run 4 times. There is no reason it wouldn't end after the 4th itteration.
Edited by valithor, 21 May 2015 - 06:30 PM.