cc-tweaked / CC-Tweaked

Just another ComputerCraft fork
https://tweaked.cc
932 stars 211 forks source link

Getting device ID in disk drive regardless of item type #1699

Open Ale32bit opened 9 months ago

Ale32bit commented 9 months ago

As of now the function disk.getDiskID returns the ID of the item in the drive, but only if the item is a disk.

What this feature request suggests is returning the ID of the drive-compatible item regardless of the type (disk, computer, turtle, pocket computer). In addition to this, to avoid ID collisions, a new function can be introduced to return the type of the item, I.E. disk.getItemType.

SquidDev commented 9 months ago

Some rationale/use case for a feature. My general approach to designing new features is to ask yourself "what issue are we trying to solve" and then "is this the best way to solve this issue?".

I think it would perhaps be useful to have some additional context here. One of the struggles I have with both this issue and #634 is that I'm not sure what you're really trying to solve here - is this just for display purposes, or something else?

Personally I kinda feel getDiskID (or indeed exposing them user-side at all) was a bit of a mistake. For computers it makes sense - ids are needed for rednet - but less so for anything else.

GStefanowich commented 6 months ago

Commenting on this issue while looking for a possible solution to an issue.

I'm working on writing a music disc player with a monitor that can select discs, and the monitor needs to know the name of the disc.

One problem I'm having is with minecrafts vanilla music disc, "5", which is by Samuel Åberg. The Å is giving me a bit of trouble, but I thought I'd just look at the ID of the disc currently present in the drive and write the name out myself.

Unfortunately drives don't seem to have a getItemDetail(slot) like inventory types do. I can't get back {["item"] = "minecraft:music_disc_5"}, the only thing available through the disc player is getDiskID() which seems to be blank for music discs, or the drive.getAudioTitle()

And then I had an issue with a mod that adds a few music discs where the drive.getAudioTitle() just returns a translation key due to some missing translations. I'd also like that to read using the item id of the disc, but can't access it while within the player.

I could use an inventory to pullItems() the disc out of the player to read the id, but it'd stop the music disc that way

SquidDev commented 6 months ago

@GStefanowich I'm going to pull this out in to a separate issue (https://github.com/cc-tweaked/CC-Tweaked/discussions/1828), as I think it's probably off-topic here.

PatriikPlays commented 4 months ago

I thought I sent a comment yesterday, but maybe not...

Getting computer IDs from a disk drive could be useful for labeling backups. Additionally, even though this is barely an argument, I needed to get the IDs of computers to index them and filter out 'nice' IDs.