#1
Posted 13 December 2014 - 11:55 AM
#2
Posted 13 December 2014 - 11:57 AM
local slot = turtle.getSelectedSlot()
#3
Posted 13 December 2014 - 12:14 PM
What am I doing wrong now?
local slot = turtle.getSelectedSlot()
write ("Do sir want some drinks? ")
variable = read()
if variable == ("yes") then
if turtle.getItemCount(turtle.getSelectedSlot())>0 then
turtle.drop()
else
turtle.select(local slot+1) then
turtle.drop()
end
elseif variable == ("no") then
print ("Very well")
end
I just try to get it use next inventory slot when current one is empty
Edited by lare290, 13 December 2014 - 12:15 PM.
#4
Posted 13 December 2014 - 12:27 PM
When you're using said variable, do not attach local to it. So you're code for that would be
turtle.select(slot+1)
Edited by Pseudonymous, 13 December 2014 - 12:29 PM.
#5
Posted 13 December 2014 - 12:28 PM
#6
Posted 13 December 2014 - 12:29 PM
Pseudonymous, on 13 December 2014 - 12:27 PM, said:
When you're using said variable, do not attach local to it. So you're code for that would be
turtle.select(slot+1)
Edited by lare290, 13 December 2014 - 12:46 PM.
#7
Posted 13 December 2014 - 12:51 PM
lare290, on 13 December 2014 - 12:29 PM, said:
I just realized, you have a then attached on to the end of that line. You can't have that there.
I'll rewrite your code:
local slot = turtle.getSelectedSlot()
write("Does sir want some drink?")
local variable = read() --#I suggest using a different variable name
if variable == "Yes" then
if turtle.getItemCount(turtle.getSelectedSlot))>0 then
turtle.drop()
else
turtle.select(slot + 1)
turtle.drop()
end
elseif variable == "no" then
print("Very well.")
end
Edited by Pseudonymous, 13 December 2014 - 12:52 PM.
#8
Posted 13 December 2014 - 01:10 PM
#9
Posted 13 December 2014 - 02:09 PM
lare290, on 13 December 2014 - 01:10 PM, said:
#10
Posted 13 December 2014 - 03:04 PM
function checkForDrinks() --#Function to check if any of the slots have any items in it
for i = 1,16 do --#For Loop
turtle.select(i)
if i == 16 then --#When then for loop reaches 16 it will go in to this if statement
if turtle.getItemCount() == 0 then --#Then it will see if the item count is equal to 0 if so it will break out of loop
print("No drinks in Inventory.")
end
end
if turtle.getItemCount(turtle.getSelectedSlot())>0 then -- You wrote this
turtle.drop()
print("Here you go sir.")
break --#Break means that it will break out of the loop as soon as it has enterd this if statement
end
end
end
write ("Do sir want some drinks? ")
variable = read()
if variable == ("yes") then
checkForDrinks() --#Put the function here so when the variable is read as yes it will run it
elseif variable == ("no") then
print ("Very well")
end
Edited by The_Cat, 13 December 2014 - 03:05 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











