Jump to content




How to make a player detector logging system using MiscPeripherals?


14 replies to this topic

#1 StarburstDude

  • Members
  • 6 posts

Posted 14 May 2013 - 10: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

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 May 2013 - 11:22 PM

Split into new topic.

#3 panicmore

  • Members
  • 26 posts
  • LocationEssex, UK

Posted 15 May 2013 - 05: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.

#4 panicmore

  • Members
  • 26 posts
  • LocationEssex, UK

Posted 15 May 2013 - 05:43 AM

View Postjllllloyd, on 15 May 2013 - 05:41 AM, said:

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


#5 sasaa_86

  • Members
  • 6 posts

Posted 15 May 2013 - 10:42 AM

View Postjllllloyd, on 15 May 2013 - 05:43 AM, said:

View Postjllllloyd, on 15 May 2013 - 05:41 AM, said:

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


#6 W00dyR

  • Members
  • 135 posts

Posted 15 May 2013 - 11:39 AM

View Postsasaa_86, on 15 May 2013 - 10:42 AM, said:

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 ;)

#7 panicmore

  • Members
  • 26 posts
  • LocationEssex, UK

Posted 16 May 2013 - 03:39 AM

View Postsasaa_86, on 15 May 2013 - 10:42 AM, said:

View Postjllllloyd, on 15 May 2013 - 05:43 AM, said:

View Postjllllloyd, on 15 May 2013 - 05:41 AM, said:

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 :)

#8 panicmore

  • Members
  • 26 posts
  • LocationEssex, UK

Posted 16 May 2013 - 03:42 AM

View PostW00dyR, on 15 May 2013 - 11:39 AM, said:

View Postsasaa_86, on 15 May 2013 - 10:42 AM, said:

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


#9 StarburstDude

  • Members
  • 6 posts

Posted 16 May 2013 - 05:37 PM

View PostW00dyR, on 15 May 2013 - 11:39 AM, said:

View Postsasaa_86, on 15 May 2013 - 10:42 AM, said:

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

#10 StarburstDude

  • Members
  • 6 posts

Posted 06 June 2013 - 07: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

#11 W00dyR

  • Members
  • 135 posts

Posted 07 June 2013 - 07:00 AM

View PostStarburstDude, on 06 June 2013 - 07:16 PM, said:

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 :)

#12 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 07 June 2013 - 07: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.

#13 W00dyR

  • Members
  • 135 posts

Posted 07 June 2013 - 08:34 AM

View Posttheoriginalbit, on 07 June 2013 - 07:04 AM, said:

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() .

#14 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 07 June 2013 - 08:46 AM

View PostW00dyR, on 07 June 2013 - 08:34 AM, said:

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...

#15 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 07 June 2013 - 11:51 AM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users