-Star
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
How to make a player detector logging system using MiscPeripherals?
Started by StarburstDude, 14 May 2013 - 09:12 PMPosted 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
-Star
Posted 15 May 2013 - 12:22 AM
Split into new topic.
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.
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
Posted 15 May 2013 - 11:42 AM
where did you get the player variable…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
should be something like this
event, user = os.pullEvent("player")
if user == "StarburstDude" then
-- do something
end
Posted 15 May 2013 - 12:39 PM
should be something like thisevent, 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 ;)/>
Posted 16 May 2013 - 04:39 AM
yeah it should sorry :)/>where did you get the player variable…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
should be something like thisevent, user = os.pullEvent("player") if user == "StarburstDude" then -- do something end
Posted 16 May 2013 - 04:42 AM
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:should be something like thisevent, 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 usingpDetector = 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 ;)/>
while true do
event, user = os.pullEvent("player")
if user then
print(user)
rs.setOutput("back", true)
print("user: " .. user)
end
end
Posted 16 May 2013 - 06:37 PM
Thank you so much this really helpedshould be something like thisevent, 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 usingpDetector = 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 ;)/>
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
Star
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 :)/>
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.
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() .
Posted 07 June 2013 - 09:46 AM
Would only work if the Minecraft world was running 24/7 with no down time ever…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.
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.
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.