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

[Modding] Get name of who uses the computer.

Started by K-dence, 12 March 2013 - 01:50 PM
K-dence #1
Posted 12 March 2013 - 02:50 PM
Hi!
I create a peripheral and i need to get the username of who uses the computer. It's possible? If yes, how?

Sorry for my bad english :P/>
Lyqyd #2
Posted 12 March 2013 - 04:27 PM
Split into new topic.

Which user? A computer can be interacted with by multiple people.

Perhaps this topic would be better suited to the peripheral help section. I think I shall move it in a while.
theoriginalbit #3
Posted 12 March 2013 - 04:38 PM
You could poll Minecraft for the players within a 1 block radius of the peripheral block. But I am unaware of a method to find out what they are interacting with, so you wouldn't know if they were using the computer or just standing near it. Also another problem would be if they were interacting with a monitor as that can be done 3 blocks away from it.
SuicidalSTDz #4
Posted 12 March 2013 - 04:51 PM
I was thinking about this the other day (Someone was screwing with my computer when I was coding), why not make private computers? However, i'm not entirely sure you can do this. What if two users click in at once? What if a user crafts a private computer but another user clicked into it first? Should it detect the owner upon crafting? Can you detect owners upon crafting? Like I said, i'm not even sure if you can detect who is using the computer at the current time. Maybe through a new event? Although that would call for serious background coding.
theoriginalbit #5
Posted 12 March 2013 - 05:13 PM
You cannot get the owner on crafting. It would have to be done on first open like IC2 personal safe.
ChunLing #6
Posted 12 March 2013 - 06:26 PM
PDA's (whenever they arrive) will probably only be usable by the player holding the item. So that solves that problem. But not the OP's question.
SuicidalSTDz #7
Posted 12 March 2013 - 06:30 PM
You cannot get the owner on crafting. It would have to be done on first open like IC2 personal safe.
There lies the problem…
theoriginalbit #8
Posted 12 March 2013 - 06:50 PM
There lies the problem…
It's minecrafts fault.

the crafting container is what 'crafts' the item, not the player, the player supplies the items, the recipe manager for the crafting container checks the item and puts it in the output. so code base wise the player is never involved in the process. so if you could get the entity that crafted the item it would always be the 'crafting bench' entity.
ScruffyRules #9
Posted 12 March 2013 - 09:35 PM
for the block you could ask RichardG how he did his player detector and for the crafting there might be a way because mystcraft uses the coords of the player surely you could get the name aswel.
theoriginalbit #10
Posted 12 March 2013 - 11:15 PM
Mystcraft is different. On crafting it uses the crafting bench coord, or the player coord when using the internal crafting bench, which is different than getting the player name on crafting.
K-dence #11
Posted 12 March 2013 - 11:55 PM
Thanks!
Finally, i save the owner of my peripheral with onBlockPlacedBy()