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

make pocket computers stay on while in non-player entities (such as minecarts)

Started by electrodude512, 19 June 2014 - 01:53 AM
electrodude512 #1
Posted 19 June 2014 - 03:53 AM
Can you please make it so pocket computers don't turn off when in the inventory of a non-player entity such as a minecart?

For a while now, I've been trying to make an automatic train routing system. I was going to just make a rule that the first cart of every train has to be a chest cart, and there has to be a floppy in the first slot with routing information, but I've found this to be nearly impractical. When pocket computers were added, I realized that they were the perfect solution to my problem - I wouldn't have to stop the train so a turtle could unload the floppy, put it in a disk drive, read it, and put it back - the switches could be set up while the train was still far away, and the train could just run right through without stopping (supposing there was no congestion, but that shouldn't be a problem since it's a small server). Unfortunately, my plans were ruined when I realized that pocket computers turn off when in any inventory other than a player inventory.

I can understand why it might not be possible to keep them on while in tile entities, but it would seem that since EntityPlayer is (indirectly) a subclass of Entity, it should be possible to keep the position of a pocket computer updated by just keeping a reference to its containing Entity. The only problem I can see with this is that, while player names never change, entity IDs change (or used to change) across world reloads, so they wouldn't be able to automatically start up again on world load, but still, from the little I know, it should be possible to make pocket computers stay on while in chest minecarts.

electrodude
Edited on 19 June 2014 - 01:55 AM
Xfel #2
Posted 21 June 2014 - 05:07 PM
The problem is: how to get a reference to the containing entity in the first place? For items in player inventory, there is a callback getting called every tick, but that does not happen even in other vanilla inventories. To find out where it is, the mod would have to constantly scan all entities and tile entities, and that would kill the performance totally.
misson20000 #3
Posted 24 June 2014 - 06:52 PM
Maybe ComputerCraft could keep a list of loaded pdas?
apemanzilla #4
Posted 25 June 2014 - 01:51 AM
Maybe ComputerCraft could keep a list of loaded pdas?
Then problems arise when other mods move items around in inventories without notifying CC properly - the PDA is "lost" according to CC.
electrodude512 #5
Posted 26 June 2014 - 09:19 PM
So if I make a special chest minecart that notifies items it contains about location changes and such, then my pocket computer will stay on and GPS will work?
Edited on 26 June 2014 - 07:20 PM
Sebra #6
Posted 26 June 2014 - 09:57 PM
You would need Dan200's support for it.
electrodude512 #7
Posted 30 June 2014 - 04:08 AM
But if I lied properly to the pocket computer, it would work without Dan200 having to do anything?
Wojbie #8
Posted 30 June 2014 - 08:32 AM
So a fakeplayer minecart?
Sebra #9
Posted 30 June 2014 - 02:37 PM
But if I lied properly to the pocket computer, it would work without Dan200 having to do anything?
Try it ;)/>
Bomb Bloke #10
Posted 30 June 2014 - 03:57 PM
If implementing your cart doesn't involve modifying any of ComputerCraft's code, then it's not a problem.

If it does, then you'd need Dan's permission - which, as far as I'm aware, he's never given to anyone for any reason.