259 posts
Posted 29 September 2013 - 03:55 PM
I'm pretty sure the answer is no, but it's worth asking. I can't find anything about it online.
To make a turtle know what slot is selected, I am going to make it write it's current slot to a file. But if that turtle had a slot other than 1 selected, that file will be wrong if it's broken and replaced. So I would like to find a way to help ensure that file will be correct.
Edit: I could just make it select that slot…… Hmmm I'm thinking I didn't think this question through as well as I should have… lol Ooops
259 posts
Posted 29 September 2013 - 03:58 PM
I suppose I could have it check if there is no items in any slot and compare it to the number of items it had before.
8543 posts
Posted 29 September 2013 - 04:37 PM
Select whatever slot needs to be selected when you need a certain slot to be selected. Always assume the wrong slot is selected if it matters. If it doesn't matter, select the slot at the beginning of your program and assume whatever slot you selected is still selected.
8 posts
Location
Missouri
Posted 07 November 2013 - 02:27 AM
I'm a bit late to this, but this is one of the specific items I was looking for.
Is there a "get slotNum" sort of program anywhere? From what I'm gathering here, I think the answer is "no"?
I have a program in the works, but I needed a function which returned the currently selected slot. I can get around this problem by writing my own get/set function for slot number, but I thought for sure there would be something built in.
8543 posts
Posted 07 November 2013 - 10:43 AM
The answer is indeed no.
259 posts
Posted 07 November 2013 - 02:21 PM
I'm a bit late to this, but this is one of the specific items I was looking for.
Is there a "get slotNum" sort of program anywhere? From what I'm gathering here, I think the answer is "no"?
I have a program in the works, but I needed a function which returned the currently selected slot. I can get around this problem by writing my own get/set function for slot number, but I thought for sure there would be something built in.
Lyqyd had it right when he said just always select the last slot at the start of the program.
8 posts
Location
Missouri
Posted 10 November 2013 - 03:28 AM
Unfortunately, CCJJSax, that can only take you so far.
For example, with something simple, like a turtle building a cactus farm, it's just different blocks placed at positions along the same interval. (Cobble, sand, cactus, and more cobble to the right.) If you already had a platform to place sand on, you can skip the first cobble stage, or, if you were starting in the desert, you could skip the sand stage as well. Given that, turtle.select(slot_number + 1) would be a more elegant and straightforward way to go through the needed block types.
Or, to take it further, when it comes to chaining programs together with shell.run or os.run, it might be necessary for the subroutine to know which slot is currently selected, and it's not as simple as looking at the variables that you're using in the main program to figure out which slot is supposed to be selected.
… granted, both of these can be easily solved by defining your own get/set function for slot_number, only changing the selected slot with THAT function, but again, it just seems like the sort of thing that would already be programmed in. At the very least, it's an easily solvable problem.