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

Whitelisted Redstone Signal

Started by JeroenOnline, 04 July 2014 - 07:47 AM
JeroenOnline #1
Posted 04 July 2014 - 09:47 AM
Hello,

I'm very new on ComputerCraft, but w're playing CrackPack with some friends. And I wan't to protect my door, but not that old password door. I prefer having a whitelist, and if a player does right click that (via ps.Pullevent) their name wil be checked against a list.

If tried thistopic, but it's seems outdated and I can't get it to work.

I realy hope you guys can help me out!


Best Wishes,


Jeroen!
Obnoxious_Ninja #2
Posted 04 July 2014 - 05:05 PM
Perhaps something like:


local playerDetector = peripheral.wrap("side") --Change "side" to whatever side it is on

while true do
  local event, player = os.pullEvent("player")

  if player == "Some player, or maybe a table for multiple players" then
	print("Valid player.  Opening door.")
	redstone.setOutput("side", true)
	sleep(2)
	redstone.setOutput("same_side", false)
  else
	print("You have not been whitelisted!")
    os.shutdown()
  end
end

Though I haven't used Misc. Peripherals before, I think that would be the basic idea that you want.
Edited on 04 July 2014 - 03:13 PM
KingofGamesYami #3
Posted 04 July 2014 - 05:27 PM
Just a suggestion, for whitelist use tables.

local whitelist = {}
whitelist[ "player" ] = true
whitelist[ "otherplayer" ] = true

if whitelist[ player ] then
 --#other code
else
 --#more code
end
JeroenOnline #4
Posted 11 July 2014 - 06:12 PM
Perhaps something like:


local playerDetector = peripheral.wrap("side") --Change "side" to whatever side it is on

while true do
  local event, player = os.pullEvent("player")

  if player == "Some player, or maybe a table for multiple players" then
	print("Valid player.  Opening door.")
	redstone.setOutput("side", true)
	sleep(2)
	redstone.setOutput("same_side", false)
  else
	print("You have not been whitelisted!")
	os.shutdown()
  end
end

Though I haven't used Misc. Peripherals before, I think that would be the basic idea that you want.
I used your code but it didn't work, gave no errors but shows just a black screen.
BaRF #5
Posted 22 July 2014 - 07:40 PM
Perhaps something like:
 local playerDetector = peripheral.wrap("side") --Change "side" to whatever side it is on while true do local event, player = os.pullEvent("player") if player == "Some player, or maybe a table for multiple players" then print("Valid player. Opening door.") redstone.setOutput("side", true) sleep(2) redstone.setOutput("same_side", false) else print("You have not been whitelisted!") os.shutdown() end end 
Though I haven't used Misc. Peripherals before, I think that would be the basic idea that you want.
I used your code but it didn't work, gave no errors but shows just a black screen.

Well, if you just copied the code then it checks if your name is "Some player, or maybe a table for multiple players" - So I guess you'll have to change that to your own name for example ;)/>