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

How to make a player detector logging system using MiscPeripherals?

Started by StarburstDude, 14 May 2013 - 09:12 PM
StarburstDude #1
Posted 14 May 2013 - 11:12 PM
I just recently got my own FTB server running,with ComputerCraft and MiscPeripherals installed.I would like to know how to log a player,like have its username "printed" on the computer screen,and then,at the same time,have it emit a redstone signal,to open a door.I really do need help,as i've been looking for a solution for this for ages. Thank you for your kindness :)/>

-Star
Lyqyd #2
Posted 15 May 2013 - 12:22 AM
Split into new topic.
panicmore #3
Posted 15 May 2013 - 06:41 AM
when a player right-clicks the block an os.pullEvent() is triggered. all you have to do is assign a variable to the player() event and check that against a list of names.
panicmore #4
Posted 15 May 2013 - 06:43 AM
when a player right-clicks the block an os.pullEvent() is triggered. all you have to do is assign a variable to the player() event and check that against a list of names.

while true do
event, user = os.pullEvent("player")
  if player == "StarburstDude" then
   rs.setOutput("nack", true)
  end
end
sasaa_86 #5
Posted 15 May 2013 - 11:42 AM
when a player right-clicks the block an os.pullEvent() is triggered. all you have to do is assign a variable to the player() event and check that against a list of names.

while true do
event, user = os.pullEvent("player")
  if player == "StarburstDude" then
   rs.setOutput("nack", true)
  end
end
where did you get the player variable…
should be something like this


event, user = os.pullEvent("player")
if user == "StarburstDude" then
-- do something
end
W00dyR #6
Posted 15 May 2013 - 12:39 PM
should be something like this


event, user = os.pullEvent("player")
if user == "StarburstDude" then
-- do something
end

This would check if it's only for the username "StarburstDude", if you want it to print it on the screen + send out a redstone signal no matter who it is:


while true do
  event, user = os.pullEvent("player")
  if user then
	print(user)
	rs.setOutput("back", true) -- change back to whatever side you want the redstone signal to be emitted
  end
end

Also, I'm not sure if this is required for the player detector, but make sure you wrap the player detector as a peripheral using


pDetector = peripheral.wrap("left") -- change left to whatever side its on

Again, I'm not familiar with it so I'm not sure if it's required ;)/>
panicmore #7
Posted 16 May 2013 - 04:39 AM
when a player right-clicks the block an os.pullEvent() is triggered. all you have to do is assign a variable to the player() event and check that against a list of names.

while true do
event, user = os.pullEvent("player")
  if player == "StarburstDude" then
   rs.setOutput("nack", true)
  end
end
where did you get the player variable…
should be something like this


event, user = os.pullEvent("player")
if user == "StarburstDude" then
-- do something
end
yeah it should sorry :)/>
panicmore #8
Posted 16 May 2013 - 04:42 AM
should be something like this


event, user = os.pullEvent("player")
if user == "StarburstDude" then
-- do something
end

This would check if it's only for the username "StarburstDude", if you want it to print it on the screen + send out a redstone signal no matter who it is:


while true do
  event, user = os.pullEvent("player")
  if user then
	print(user)
	rs.setOutput("back", true) -- change back to whatever side you want the redstone signal to be emitted
  end
end

Also, I'm not sure if this is required for the player detector, but make sure you wrap the player detector as a peripheral using


pDetector = peripheral.wrap("left") -- change left to whatever side its on

Again, I'm not familiar with it so I'm not sure if it's required ;)/>
I wasn't sure so i left it out, my code was an example hence why it only emits redstone when starbustDude clicks it. printing it to the screen would change the code to this:

while true do
  event, user = os.pullEvent("player")
  if user then
    print(user)
    rs.setOutput("back", true)
    print("user: " .. user)
  end
end
StarburstDude #9
Posted 16 May 2013 - 06:37 PM
should be something like this


event, user = os.pullEvent("player")
if user == "StarburstDude" then
-- do something
end

This would check if it's only for the username "StarburstDude", if you want it to print it on the screen + send out a redstone signal no matter who it is:


while true do
  event, user = os.pullEvent("player")
  if user then
	print(user)
	rs.setOutput("back", true) -- change back to whatever side you want the redstone signal to be emitted
  end
end

Also, I'm not sure if this is required for the player detector, but make sure you wrap the player detector as a peripheral using


pDetector = peripheral.wrap("left") -- change left to whatever side its on

Again, I'm not familiar with it so I'm not sure if it's required ;)/>
Thank you so much this really helped
StarburstDude #10
Posted 06 June 2013 - 08:16 PM
Also,is it possible to have the usernames logged onto a program?What I mean is like the usernames are saved a "log program" which is just a list of the usernames and the time they joined. It'd be great If I could know,
Star
W00dyR #11
Posted 07 June 2013 - 08:00 AM
Also,is it possible to have the usernames logged onto a program?What I mean is like the usernames are saved a "log program" which is just a list of the usernames and the time they joined. It'd be great If I could know,
Star

Yes, it was explained not to long ago, read up on this topic to get started on that part :)/>
theoriginalbit #12
Posted 07 June 2013 - 08:04 AM
Just to expand on what W00dyR stated, you cannot get the real time, only the Minecraft world time. So use os.day() as well as os.time() so that you know when and on what day.
W00dyR #13
Posted 07 June 2013 - 09:34 AM
Just to expand on what W00dyR stated, you cannot get the real time, only the Minecraft world time. So use os.day() as well as os.time() so that you know when and on what day.

Yes, I overread that. My bad :P/>

To expand even more: I think you should even be able to use those two functions, do some math and calculate the real time. Seeing as every minecraft day lasts a certain amount of time, by adding a initial "zero" point (like, todays date) you should be able to calculate it.

This would make things a lot harder though and it would be way easier to just use os.day() and os.time() .
theoriginalbit #14
Posted 07 June 2013 - 09:46 AM
To expand even more: I think you should even be able to use those two functions, do some math and calculate the real time. Seeing as every minecraft day lasts a certain amount of time, by adding a initial "zero" point (like, todays date) you should be able to calculate it.
Would only work if the Minecraft world was running 24/7 with no down time ever…
Lyqyd #15
Posted 07 June 2013 - 12:51 PM
And only if the tick rate was always 20t/s.

By the way, you do not need to wrap the peripheral in order to receive the events. You don't need to do this for any other peripherals, plus it doesn't even have any way of knowing if it's been wrapped or not.