This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Zivel's profile picture

is there a way to get the current slot number?

Started by Zivel, 04 October 2012 - 06:54 AM
Zivel #1
Posted 04 October 2012 - 08:54 AM
Is there a way to get the number of the current slot that is selected in a turtle? I am trying to tell my turtle when he runs out of dirt then to go and find some more dirt. I am very new to this (a week and have just been using the wiki) and have looked everywhere.


local x=2
function com()
for i = 1, x do
   while not turtle.compareTo(x) do
	  x=x+1
	  end
   turtle.select(x)
   end
end
com()

I think it will work if I can change local x=2 to local x=thecurrentslot+1 but I cant work out how to get the current slot number. At the moment it works if I start at 1. No idea what it does if it gets to 17 lol but we will fix that when I get there, this will not work as it stands and I know that… I need to add a part where it doesn't use the last dirt so it has something to compare it to, but that is also something I will fix when I get there. All I want at the moment is to make this start at the current slot and not slot 2….

Also, is there a way to edit my codes that I write in minecraft with notepad++? I cannot seem to find them anywhere in my minecraft file.

Sorry if this is the wrong place to ask or it is not the right level, I am a complete noob and have spent three nights trying to solve this problem.
Doyle3694 #2
Posted 04 October 2012 - 08:58 AM
just do turtle.select(1) at the beginning. Then every time you select another slot just increment a int.
Zivel #3
Posted 04 October 2012 - 09:02 AM
SOAB!… was it really that simple?!?!? in front of my bloody face all this time…. thank you so much for your quick reply and elegant answer.
CCJJSax #4
Posted 28 March 2013 - 05:36 AM
I'm a bit late to the party here. You can edit your computercraft programs with Notepad++ by going into your minecraft directory\saves\(world name)\computer\file the file doesn't have an extension, but you can easily open them with Notepad and notepad++