Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turtles should be able to detect Equipped Pickaxes #964

Open
kaseyawolf2 opened this issue Nov 25, 2021 · 13 comments · May be fixed by #1692
Open

Turtles should be able to detect Equipped Pickaxes #964

kaseyawolf2 opened this issue Nov 25, 2021 · 13 comments · May be fixed by #1692
Labels
area-Minecraft This affects CC's Minecraft-specific content. enhancement An extension of a feature or a new feature. feedback wanted Tell me what you want, what you really really want.

Comments

@kaseyawolf2
Copy link

Turtles currently have no way of know if they have pickaxe equipped.

My current workaround is unequipping and detecting if anything appeared in the turtles inventory

It would be nice if turtles, could use the peripheral.Find to detect if theres a pickaxe.

would save me like 2 headaches.

@kaseyawolf2 kaseyawolf2 added the enhancement An extension of a feature or a new feature. label Nov 25, 2021
@SquidDev SquidDev added area-Minecraft This affects CC's Minecraft-specific content. feedback wanted Tell me what you want, what you really really want. labels Nov 25, 2021
@SquidDev
Copy link
Member

I'm curious as to what you need this for? Is this just to ensure that the turtle has a valid tool?

I'm not opposed to this in principle, but I do want to ensure people don't end up writing code like if turtle.getLeftUpgrade() ~= "minecraft:diamond_pickaxe" then error("Need a pick") end. Otherwise it's just going to be incompatible with people using other pick upgrades (such as those from other mods or added via CraftTweaker).

@kaseyawolf2
Copy link
Author

Im working on a Turtle Command and control System that assigns Turtles jobs, and one of those jobs will be mining, it would be nice to be able to quickly verify that the turtle has a digging tool equipped. i don't need to explicitly detect if it has a Diamond Pick i was just wanting an easy wait to see if the turtle can dig with out 1. accidently breaking a important block by calling turtle.dig() and checking the results or 2. unequipping checking inventory, and reequipping.

@Lupus590
Copy link
Contributor

Maybe turtle.getLeftUpgrade() should return a table that contains information about the tool and not (just) the name of the tool.

Something like this may be:

{
  type = "pickaxe",
  miningLevel = 5
}

Also, currently one could check that turtle.dig is defined, but that doesn't tell you if the turtle has a pickaxe or a shovel which can be an important distinction for a miner.

@kaseyawolf2
Copy link
Author

That would work and it gives more info on what's equipped and its ability.

Also, I was under the impression that turtle.dig was always defined. as far as i know it returns false and a string on why it failed to dig, such as No tool, No block, or unbreakable block, or true when it does break.

@Wojbie
Copy link
Contributor

Wojbie commented Nov 25, 2021

As alternative instead of adding new functions how about making tools and crafting table report their existence as peripherals?

They would be stub peripherals without any methods but having tools report at pickaxe, axe, shovel & craftingtable type peripherals would also give information to user that there is peripheral there that provides pickaxe functionality to turtle same way that they check if there is a modem installed.

This would also get around the if turtle.getLeftUpgrade() ~= "minecraft:diamond_pickaxe" then error("Need a pick") end issue cause pickaxe from some other mod would still report as pickaxe ?

@SquidDev
Copy link
Member

Turtles can have a block peripheral (e.g. disk drive, chest) and tool upgrade (pick, sword) at the same time, so creating phantom peripherals doesn't feel very nice.

@kaseyawolf2
Copy link
Author

That was my original suggestion that they report back with the find function. Either way works, i just think that there needs to be some way for it to be known to the turtle.

Also crafting tables report under the workbench peripheral

@Wojbie
Copy link
Contributor

Wojbie commented Nov 25, 2021

Can they? I was under impression that tool or crafting table upgrade was blocking the side.. Must have misremembered.
obraz
Hmm.. I guess they do. Nevermind my suggestion of using the peripheral system..

But still having turtle.getLeftUpgrade() report generic types of pickaxe, axe or shovel would get around the issue of someone making it check for diamond pickaxe. After all pickaxe from other mod would still be a pickaxe ?

@Lupus590
Copy link
Contributor

Lupus590 commented Nov 25, 2021

If tools do become full peripherals then being able to interrogate their mining level would be nice and help justify their classification as a peripheral.

I'm now trying to think of some other peripheral/peripheral-like methods that could be placed on tools. Maybe the ability to strip logs with axes via a peripheral method. Making paths with shovels, which turtle might already be able to do from a block away. Using a hoe to till farmland, which I already know that turtles can do by digging one block away.

@kaseyawolf2
Copy link
Author

kaseyawolf2 commented Nov 25, 2021

The only issue with making them peripherals is it would completely break compatibly with almost every turtle script since digging would become a peripheral call instead of a turtle call.

we would have to make turtle.dig use the pickaxe peripheral which i imagine isnt impossible but may be annoying idk im lua newbie

@Lupus590
Copy link
Contributor

turtle.craft already does that kind of thing.

@7eggert
Copy link

7eggert commented Dec 15, 2021

If the hand is (hands are) a peripheral, the turtle can call it's dig function which would left-click the item it contains. advanced programs could query the item stack. The last problem would be querying the tool capabilities ["pickaxe", "shovel", …] and maybe a convenience function hasCapability("pickaxe").

@IRONDOGKILLER
Copy link

Advanced peripherals has digBlock(). You can use labels for identification and also everything mentioned can be coded.

@ToxicGLaDOS ToxicGLaDOS linked a pull request Jan 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Minecraft This affects CC's Minecraft-specific content. enhancement An extension of a feature or a new feature. feedback wanted Tell me what you want, what you really really want.
Projects
None yet
6 participants