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

Turtle Pickaxes/Tools Detection & Refuel Detection-ish

Started by theoriginalbit, 13 June 2013 - 10:25 PM
theoriginalbit #1
Posted 14 June 2013 - 12:25 AM
Firstly I did a quick search and couldn't see anything like this, so I'm sorry if there is…

Idea #1:

Description

I was thinking before, while helping in Ask a Pro, about the blocks a turtle can dig, and how when RedPower2 is installed we can use the gem pickaxes on the turtle which effects the blocks that it can dig. So I was thinking that it could be helpful/useful/beneficial if we had some way to detect which material type of pickaxe/tool was attached to the turtle.

Extension

Also when durability is implemented this could allow the turtles to have a rough guess at how long they can dig for and/or it wouldn't return "none" when there is no tool attached, meaning for example the excavate program could send the turtle to the surface so the player can attach a new pickaxe… That is of course if you don't put in something that can return the actual durability.

Idea #2:

Description

On use of turtle.refuel(0) instead of returning a boolean based on if the item is a fuel item, it would be nice if it returned the fuel value, so for example turtle.refuel(0) on coal would return 80, or maybe it could return 2 values, so it could return true, 80.

Why

This would allow for some more complex and accurate refuelling scripts or functions in programs while not breaking existing scripts.
if turtle.refuel(0) then print("Still evaluates to true") end
If it returned the second version (return true, 80) then it definitely would not break even scripts that are made by those who like to do manual evaluations, like so
if turtle.refuel(0) == true then print("It is fuel") end

Thanks for reading,

— BIT

EDIT: Oh another thought, added Idea #2.
Edited on 14 June 2013 - 12:44 AM
superaxander #2
Posted 14 June 2013 - 01:14 AM
This would be really nice maybe wrap the pickaxe as a peripheral?
theoriginalbit #3
Posted 14 June 2013 - 03:30 AM
The tool being a peripheral would allow people to make more sense of not being able to use peripherals on that side, just like the modem being in the way of using peripherals such as disk drives.
ChunLing #4
Posted 14 June 2013 - 04:53 AM
Second idea is just an enhancement, you can already write a function that uses turtle.getFuelLevel() before and after refueling (if it succeeds) and returns the difference rather than true. It's not a bad enhancement, but it would definitely break some programs because a lot of people use "var = true" style conditionals (they shouldn't, but they do).

As for the first idea, I think that when durability is added it would be useful for a turtle to check whether the block in front of it can be harvested by the tool it has, or perhaps to have a dig function and a harvest function, where the dig function would dig the block if it was breakable and the harvest function would only dig if the block could be collected. The normal tools typically take much longer to dig blocks that can't be harvested with that tool, so I don't feel that this would be require any explanation other than "turtle has an internal clock". Or you could make the native version of turtle.dig take the amount of time it takes to break a block and let people write their own dig/harvest functions from that, but this would probably be a pain.

Being able to directly check the material of the tool seems a little unnecessary (presumably something or someone crafted the tool to the turtle and should know), but I wouldn't regard it as necessarily bad myself. Figuring out the same information from what the turtle could and couldn't harvest would be more "fun" in the sense of requiring you to have a working inventory system (and maybe a highly coordinated swarm) so the turtle (or the system as a whole) could know the identity of the blocks. On the flip-side, having a harvest function would be a much more reliable way of tracking the durability left on your tool, notwithstanding that there are common blocks which can be harvested by any tool but do double damage to most.
theoriginalbit #5
Posted 14 June 2013 - 06:40 AM
Second idea is just an enhancement, you can already write a function that uses turtle.getFuelLevel() before and after refueling (if it succeeds) and returns the difference rather than true. It's not a bad enhancement, but it would definitely break some programs because a lot of people use "var = true" style conditionals (they shouldn't, but they do).
Well yes and no. Yes it is possible to write a function that does it, BUT said function also consumes the fuel item in the process of doing so, rather than the fuel value being returned from the fuel check function (turtle.refuel(0))… I did think about when people use the "== true" and that is why I thought a format such as "return true, 80" could be better since if they did "if turtle.refuel(0) == true then" that would not be broken as true is the first value returned, thus the one that would be compared with.

I do actually agree with what you state for the first idea.
Tiin57 #6
Posted 14 June 2013 - 08:26 AM
Perhaps, when durability is implemented (or in general) you could have a turtle.attach(slotid) which attempts to equip the item in slotid as a peripheral, instead of requiring crafting.
ChunLing #7
Posted 14 June 2013 - 08:38 AM
Oh, I guess I didn't read the refuel idea closely enough. So…I'm having a bit of trouble seeing the utility of not refueling. Is this just a way to figure out what kind of item it is without using it? The big case would be lava, but if it's in a bucket then lava it is. I guess you can distinguish a few things that you might have collected without destroying any of them. But being able to tell the exact fuel value of things without burning any of them seems a bit strange. Just being able to tell if a material is usable as fuel without using a significant quantity of it is more believable.

I'm not opposed to being able to tell more about blocks (without going all the way to block ID detection–okay I'm not really opposed to that either but it's a non-issue). But I think the intention is probably to limit the amount you can figure out to things that would be "obvious" without any advanced sensors (which I consider to be the case for whether a tool is working on a block). I'd guess that, supposing there is a controlled ignition system, it can tell whether something is returning more heat than the igniter puts in without full combustion. But I don't know that such a system would obviously be able to detect the exact quantity of energy it could extract from a piece of fuel without burning it. Maybe just the general category of fuel, like wooden, coal/charcoal, lava (sundry IC/other fuels).
Sebra #8
Posted 14 June 2013 - 10:18 AM
1. I do not like implementing tools durability for turtles, but tools as a peripheral is good idea. As for detection of tool and material, each peripheral have it's name to read. Different tools can have different sets of methods. For example IC2 laser can have methods to set/get mode, to shoot at pointed direction and others. It would be nice if tool would be able to tell, can it harvest block (up/down). And last, but not least, it would be great if turtle would be able to use most (if not all) tools/peripherals on any side left or right.

2. It is hard to believe we can know item is fuel, but cannot know how effective is it.
theoriginalbit #9
Posted 14 June 2013 - 11:36 AM
1. I do not like implementing tools durability for turtles
Well it is going to happen, eventually. So you may as well get used to it now.

For example IC2 laser can have methods to set/get mode, to shoot at pointed direction and others.
Things such as this are not done with vanilla, and I'm not sure will ever be given misc peripherals.
Sebra #10
Posted 15 June 2013 - 03:05 AM
1. I do not like implementing tools durability for turtles
Well it is going to happen, eventually. So you may as well get used to it now.
I would not say it should not be done, but hope it will be configurable.
For example IC2 laser can have methods to set/get mode, to shoot at pointed direction and others.
Things such as this are not done with vanilla, and I'm not sure will ever be given misc peripherals.
Standard Bow can be aimed. It is not implemented yet, but it will need aim to implement. Imagine Turtle with Sword and Bow.
Using tools as Peripherals would open the possibility to add such ability.
Jappards #11
Posted 15 June 2013 - 06:59 AM
the aim could be done with using Y and X axis and some strength parameters, it would be really cool if tools are turtle peripherals.
ChunLing #12
Posted 16 June 2013 - 02:29 AM
Hopefully durability will be optional, like fuel use. I think that it would be very good to have enchanted tools available (particularly silk touch) to keep well-programmed turtles ahead of the game as a use for diamonds (but even just the ability to mine in a + pattern yields a 4:1 ratio of blocks checked to tool used compared with 3:1 for the very best pattern possible for a player…but the player can use stone tools rather than diamond for just clearing stone/dirt/gravel, which totally shifts the balance of efficiency the other way). They also can be a big time-saver…though honestly I tend to use them as a time-waster ^_^/>
aaa #13
Posted 22 June 2013 - 06:35 AM
Methink, usefull, but not necessary.
I don't like much the first idea because it's like tell_me_something_I_am_to_lazy_to_remember. Durability can also be calculate, if you're sure of whath tools it was how damaged it was and how many times you used it, but it beginns to be boring. Also (I don't know if that's the use you wamted of it) that yoou can more easily identify ores (for remotly turtles) ; but if playing with mods and dozens of ores, many useless, you may ask for more sensitivity (maybe not to add in cc but in these mods?).

For the second idea, its like know_something_without_using_items. We should add somewhere all of these functions and the can_I_do_without_actually_doing_it (can I place, craft, move (ie bolck + mob detection), suck, drop (ie is there inventory) …).

EDIT : can I craft already exists.
Jarle212 #14
Posted 24 June 2013 - 07:46 AM
Methink, usefull, but not necessary.
I don't like much the first idea because it's like tell_me_something_I_am_to_lazy_to_remember. Durability can also be calculate, if you're sure of whath tools it was how damaged it was and how many times you used it, but it beginns to be boring. Also (I don't know if that's the use you wamted of it) that yoou can more easily identify ores (for remotly turtles) ; but if playing with mods and dozens of ores, many useless, you may ask for more sensitivity (maybe not to add in cc but in these mods?).

For the second idea, its like know_something_without_using_items. We should add somewhere all of these functions and the can_I_do_without_actually_doing_it (can I place, craft, move (ie bolck + mob detection), suck, drop (ie is there inventory) …).

EDIT : can I craft already exists.

You missed the point of the first idea. It is stated in the OP, read it :P/>

About the suggestion:
Would allow for more advanced turtle programs, Luve it!