191 posts
Posted 01 June 2013 - 01:55 PM
Hi! i have written a turtle program and while improving it i got the following error :'in expexted' in this function:
function drop(fslot,lslot)
for fslot,lslot do
turtle.select(i)
while turtle.drop() == false and turtle.getItemCount(fslot) ~= 0 do
print("Can't drop items- full?")
end
end
end
Any ideas? Thanks
82 posts
Posted 01 June 2013 - 01:58 PM
turtle.select(i)
i is not declared anywhere in this.
1190 posts
Location
RHIT
Posted 01 June 2013 - 01:59 PM
turtle.select(i)
i is not declared anywhere in this.
You didn't even read the error did you?
———-
@op: You really should provide the whole code.
As for your issue, you are using an invalid for loop.
A for loop can be written in one of two ways:
1) for i=1, 100 do
2) for a, b in iterator(stuff) do
You are using neither. My guess is that you are trying to do the former. If so, try this instead:
function drop(fslot,lslot)
for i=fslot,lslot do --# It looks like you just forgot to set i=fslot
turtle.select(i)
while turtle.drop() == false and turtle.getItemCount(i) ~= 0 do
print("Can't drop items- full?")
end
end
end
191 posts
Posted 01 June 2013 - 02:14 PM
turtle.select(i)
i is not declared anywhere in this.
You didn't even read the error did you?
———-
@op: You really should provide the whole code.
As for your issue, you are using an invalid for loop.
A for loop can be written in one of two ways:
1) for i=1, 100 do
2) for a, b in iterator(stuff) do
You are using neither. My guess is that you are trying to do the former. If so, try this instead:
function drop(fslot,lslot)
for i=fslot,lslot do --# It looks like you just forgot to set i=fslot
turtle.select(i)
while turtle.drop() == false and turtle.getItemCount(i) ~= 0 do
print("Can't drop items- full?")
end
end
end
Oh! i thought that i could just use another variable for that, Thanks!
7083 posts
Location
Tasmania (AU)
Posted 01 June 2013 - 07:16 PM
i is not declared anywhere in this.
You didn't even read the error did you?
Given that your suggested fix is to declare i, I think it's pretty clear that he
did read it, yes? ;)/>