CC: Tweaked

CC: Tweaked

57M Downloads

turtle_inventory return value.

CitizenFoffie opened this issue ยท 5 comments

commented

Hello, I was wondering if you guys could add a return value to the turtle_inventory event.

With that return value being slot effected.
Imagine this scenario, a turtle is mining and picks up cobble, the event would return the slot that the cobble went into.
I was making a item sorting system and it was slow going through all slots, and it would just be faster in general to have a return value for the event.

commented

If we do this then it would be nice to have the redstone event to have a side too. There are probably similar events that could do with extra information as well.

commented

The way I have my sorting system, is whenever the robot digs, it sorts the inventory.
The sort function cycles through all slots doing turtle.getItemDetail() I think it would be a good quality of life addition, so instead I can use turtle_inventory, and then it will return me the slot that a item was picked up in, and then I can sort that slot.
like this.
image

commented

The issue in both these cases is that it's a set of sides/slots, rather than a single one. We can return a table, but it's not especially nice.

it was slow going through all slots

This is surprising to me - turtle.getItemDetail should be pretty much instantaneous, as it doesn't need to run on the server thread.

commented

Ahh right cause multiple things can change at same time from turtle/computer point of view.

Not sure it would be cleaner then returning table but how about just multiple returns something like
turtle_inventory 1 3 6 7
or
redstone top left back

In the end it is still just a sugar cause someone would have to check all of the returned to react appropriately and only difference is they would check 3 instead of 6 redstone sides and 4 out of 16 turtle slots. I am not sure if that is really something that would help in long run?

commented

I definitely don't want to start queuing at event for every sort which changes. It probably wouldn't break existing programs, but I guess it'd slow a number of them down.

I guess the alternative would be a new event, but that's not great either. I agree that the current situation is not great, but I think finding a solution which isn't gross is going to require more willpower than I'm willing to devote right now.