1522 posts
Location
The Netherlands
Posted 31 March 2013 - 05:07 AM
Hello,
Like reading the title, this is about adding an event to the turtle. I dont know any names for the event itself, but the idea behind it is:
if something happens in the inventory like putting in an item or getting it out. The params should be then the slot number. This might be
very too much asked, but you can do lots of usefull stuff with it. Like lots of programs need to wait for fuel, so the loop through the inventory and check if its fuel. Sometimes they keep checking until they have enough fuel, so lets say we had that event, we know when we should search again.
This is also for building programs, so it doesnt build without blocks. Of course you cant prevent it totally, but with this event you can.
Please leave feedback :)/>
Engineer
3790 posts
Location
Lincoln, Nebraska
Posted 31 March 2013 - 05:58 AM
for i = 1,16 do
turtle.select(i)
if turtle.refuel() then
break
else
print("No fuel in slot "..i)
end
end
This is already doable for fuel. I don't think we need a new event for it.
If you just want to check if the inventory has changed, then loop through the inventory, checking item counts.
2447 posts
Posted 31 March 2013 - 06:09 AM
I do actually like this idea - it has been on my "to consider" list for a while. I'll look into it!
1522 posts
Location
The Netherlands
Posted 31 March 2013 - 06:28 AM
for i = 1,16 do
turtle.select(i)
if turtle.refuel() then
break
else
print("No fuel in slot "..i)
end
end
This is already doable for fuel. I don't think we need a new event for it.
If you just want to check if the inventory has changed, then loop through the inventory, checking item counts.
That is just the point. If you want an user to
enter fuel, you must constantly loop through the inventory. With that event, you know if there is even placed a new item, or got out an item.
I do actually like this idea - it has been on my "to consider" list for a while. I'll look into it!
Nice! :)/>
620 posts
Location
Holland
Posted 31 March 2013 - 06:48 AM
This is a pretty good idea!
7508 posts
Location
Australia
Posted 31 March 2013 - 01:49 PM
Sounds good! Should reduce lag from turtles sitting there constantly checking for fuel and such (in those badly coded programs) :P/>
I like it! although I can think of one potential problem when coding it into the mod… but I'm sure Cloudy will figure it out :)/>
2447 posts
Posted 31 March 2013 - 02:02 PM
Caring is sharing?
7508 posts
Location
Australia
Posted 31 March 2013 - 02:30 PM
Caring is sharing?
Well last time I played around with modding it was just before 1.4 and iirc when Minecraft does anything with the TileEntity everything goes through a finite set of methods. And that includes interaction with the inventory. So that would mean if you added the event spawning on inventory interaction could spawn heaps of events.
For example:
Bob is putting 36 pieces of cobblestone into the turtle. Bob opens up the turtle and starts spamming right click to add cobblestone into the inventory, for each piece of cobblestone he adds, the turtle gets an event. He accidentally puts in a couple too many, so takes out half, the turtle gets an event. He then starts spamming the cobble back in to get 36, the turtle gets an event for each of these.
And depending on how your code works when the turtle places and sucks blocks and transfers items around the inventory there would be events every time that is done too.
So imho I think this has the potential to cause some lag in clients and potentially large event queues…
There was another problem I thought of while writing this, but I forgot it now…. dammit! :(/>
1619 posts
Posted 31 March 2013 - 03:52 PM
Caring is sharing?
Well last time I played around with modding it was just before 1.4 and iirc when Minecraft does anything with the TileEntity everything goes through a finite set of methods. And that includes interaction with the inventory. So that would mean if you added the event spawning on inventory interaction could spawn heaps of events.
For example:
Bob is putting 36 pieces of cobblestone into the turtle. Bob opens up the turtle and starts spamming right click to add cobblestone into the inventory, for each piece of cobblestone he adds, the turtle gets an event. He accidentally puts in a couple too many, so takes out half, the turtle gets an event. He then starts spamming the cobble back in to get 36, the turtle gets an event for each of these.
And depending on how your code works when the turtle places and sucks blocks and transfers items around the inventory there would be events every time that is done too.
So imho I think this has the potential to cause some lag in clients and potentially large event queues…
There was another problem I thought of while writing this, but I forgot it now…. dammit! :(/>/>
Interesting point. This could potentially deadlock the game.
2447 posts
Posted 31 March 2013 - 11:16 PM
The amount of events won't be a problem.
And you don't know what you're talking about Dlcruz.
7508 posts
Location
Australia
Posted 31 March 2013 - 11:27 PM
The amount of events won't be a problem.
how much space do queues in Java have, I've never had to use them… reason I ask is if spammed enough could it cause a queue overflow?
EDIT: nvm, just thought about it, and the turtle functions should clear the queue anyways. so it probs wouldn't have any negative effects.
2447 posts
Posted 31 March 2013 - 11:30 PM
The amount of events won't be a problem.
how much space do queues in Java have, I've never had to use them… reason I ask is if spammed enough could it cause a queue overflow?
EDIT: nvm, just thought about it, and the turtle functions should clear the queue anyways. so it probs wouldn't have any negative effects.
So you're saying someone clicking is worse than someone typing?
7508 posts
Location
Australia
Posted 31 March 2013 - 11:38 PM
So you're saying someone clicking is worse than someone typing?
In a lot of cases clicking can be done quicker than typing. but I see your point. and I also conceded mine.
1852 posts
Location
Sweden
Posted 01 April 2013 - 12:11 AM
Will be glad if this happens! :)/>
1619 posts
Posted 01 April 2013 - 04:13 AM
The amount of events won't be a problem.
how much space do queues in Java have, I've never had to use them… reason I ask is if spammed enough could it cause a queue overflow?
EDIT: nvm, just thought about it, and the turtle functions should clear the queue anyways. so it probs wouldn't have any negative effects.
So you're saying someone clicking is worse than someone typing?
Good point. I was just fearing another rednet deadlock.
724 posts
Posted 02 April 2013 - 04:40 AM
Was suggested by me as
Events for external inventory change long time ago.
I do actually like this idea - it has been on my "to consider" list for a while. I'll look into it!
I'm glad you have another opinion now.
3790 posts
Location
Lincoln, Nebraska
Posted 02 April 2013 - 06:12 AM
I think that for Cloudy, his "to consider" list is fairly extensive, but his "to implement" list is fairly devoid of CC Forums suggestions.