When a computer is placed it increments the number in the lastid text file. If that computer is destroyed before a directory for it is needed this number stays the same. This means that as an end result I have one folder in the 'computers' folder and its got the id 12. Obviously this shouldn't effect anything staying as it is, but I think maybe that 'lastid' should be incremented only when the computer creates its directory.
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[1.481][SMP] Computer ID Consumption
Started by theoriginalbit, 15 January 2013 - 09:05 PMPosted 15 January 2013 - 10:05 PM
Not too sure if this is a bug… But its something I noticed that happens which may not be intended…
When a computer is placed it increments the number in the lastid text file. If that computer is destroyed before a directory for it is needed this number stays the same. This means that as an end result I have one folder in the 'computers' folder and its got the id 12. Obviously this shouldn't effect anything staying as it is, but I think maybe that 'lastid' should be incremented only when the computer creates its directory.
When a computer is placed it increments the number in the lastid text file. If that computer is destroyed before a directory for it is needed this number stays the same. This means that as an end result I have one folder in the 'computers' folder and its got the id 12. Obviously this shouldn't effect anything staying as it is, but I think maybe that 'lastid' should be incremented only when the computer creates its directory.
Posted 15 January 2013 - 10:52 PM
Computers need unique IDs even if there's nothing in their directory. What about rednet?Not too sure if this is a bug… But its something I noticed that happens which may not be intended…
When a computer is placed it increments the number in the lastid text file. If that computer is destroyed before a directory for it is needed this number stays the same. This means that as an end result I have one folder in the 'computers' folder and its got the id 12. Obviously this shouldn't effect anything staying as it is, but I think maybe that 'lastid' should be incremented only when the computer creates its directory.
Posted 15 January 2013 - 11:13 PM
Does rednet require a directory?
Maybe then, have it so that if a computer is destroyed, and it doesn't have a directory, decrement the file? Idk, like I said not a big issue, just seemed weird when I saw it.
Maybe then, have it so that if a computer is destroyed, and it doesn't have a directory, decrement the file? Idk, like I said not a big issue, just seemed weird when I saw it.
Posted 16 January 2013 - 12:15 AM
There's no foolproof way to be sure that a computer has been destroyed. And even if there was - what if another computer is created afterwards? What then?
Anyway, this is 100% intended and exactly how it is supposed to work. The whole point is to be able to assign a unique ID even if no folder is created, and to avoid folders being created if not neccesary.
Anyway, this is 100% intended and exactly how it is supposed to work. The whole point is to be able to assign a unique ID even if no folder is created, and to avoid folders being created if not neccesary.
Posted 16 January 2013 - 12:43 AM
There's no foolproof way to be sure that a computer has been destroyed. And even if there was - what if another computer is created afterwards? What then?
Anyway, this is 100% intended and exactly how it is supposed to work. The whole point is to be able to assign a unique ID even if no folder is created, and to avoid folders being created if not neccesary.
Ok that's fine. Thought I'd just let you know incase. On a side note though, isn't there an onBlockDestroyed method?
Posted 16 January 2013 - 12:58 AM
Yes. But that's only guaranteed to be called by vanilla Minecraft. A mod could easily just set the block ID to 0 without calling that.
Posted 16 January 2013 - 01:10 AM
The breakBlock method is called whenever the block ID is changed.
It used to be called onBlockDestroyed or something similar.
It used to be called onBlockDestroyed or something similar.
Posted 16 January 2013 - 01:14 AM
Interesting, I'll have to verify that - but for above reasons it would still be unreliable and messy.
Posted 16 January 2013 - 02:48 AM
here it is… i knew I had seen it, and that it would be there, its what would be called to drop the block.Interesting, I'll have to verify that
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
and
public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4) {}
Yeh I understand that now… :)/>but for above reasons it would still be unreliable and messy.
Posted 16 January 2013 - 10:57 AM
breakBlock is called right after setting the new block ID, but before destroying the tile entity (which is done in BlockContainer.breakBlock for server worlds) in Chunk.setBlockIDWithMetadata.