Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sensor = peripheral.wrap("openperipheral_sensor_0")
- local bsensor = peripheral.wrap("openperipheral_sensor_0")
- local monitor = peripheral.wrap("monitor_4")
- monitor.clear()
- monitor.setCursorPos(1,1)
- local pIn =
- {
- ["jonassvensson4"] = false
- }
- -- Get users outside the shop
- function getUserOut()
- playersb = bsensor.getPlayers()
- if playersb[1] == nil then
- -- No one is outside
- else
- usernameOut = playersb[1].name
- for name, status in pairs(pIn) do
- if pIn[usernameOut] == true then
- monitor.setTextColor(colors.red)
- monitor.setCursorPos(1,1)
- monitor.write("Please come again!")
- monitor.setTextColor(colors.white)
- monitor.setCursorPos(1,2)
- monitor.write(" " .. usernameOut)
- sleep(1)
- monitor.clear()
- pIn[usernameOut] = false
- end
- end
- end
- end
- -- Get user who enters the shop
- function getUser()
- players = sensor.getPlayers()
- -- Checks if there's a player inside the shop
- if players[1] == nil then
- username = "null"
- else
- -- Player found
- username = players[1].name
- for name, status in pairs(pIn) do
- if pIn[username] == true then
- -- Player has already been in the shop
- playersb = bsensor.getPlayers()
- if playersb[1] == nil then
- -- No one is outside
- else
- usernameOut = playersb[1].name
- if pIn[usernameOut] == true then
- pIn[usernameOut] = false
- break
- end
- end
- elseif pIn[username] == false then
- pIn[username] = true
- -- Welcome message:
- monitor.setTextColor(colors.green)
- monitor.setCursorPos(1,1)
- monitor.write(" Welcome!")
- monitor.setCursorPos(1,2)
- monitor.setTextColor(colors.white)
- monitor.write(" " .. username)
- sleep(2)
- monitor.clear()
- end
- end
- end
- end
- while true do
- monitor.setCursorPos(1,1)
- getUser()
- sleep(0.75)
- end
Advertisement
Add Comment
Please, Sign In to add comment