Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
local detector = peripheral.find("environment_detector") local gearshift = peripheral.find("Create_SequencedGearshift") if not detector then error("No environment detector found") end if not gearshift then error("No Create Sequenced Gearshift found") end local isDoorOpen = false -- Initial state of the door local minYLevel = -1 -- Minimym Y level to consider user valid (relative to detector) local doorStateFile = fs.open(".door_state", "r") if doorStateFile then isDoorOpen = doorStateFile.readLine() == "1" doorStateFile.close() end local allowedUsers = { "f48e6371-3ed0-4738-a5e0-0f29bc2da9d4", -- LunaFolf "442b1cce-8356-450d-9a5d-d1a040ee15ac", -- lifeline4603 "9c4b7608-6411-45d7-b0ab-e13587c81074", -- PrinceOfCookies "fbd30864-b8d8-431e-83d6-a86d68281f7d", -- AdventurousMR "d94e1d90-c8db-4b98-8958-af7a57a99266", -- beLLecolond "dd91707a-b7a0-4ab7-9bbd-498a4f35e8b2", -- NoxxyTheStars } --[[ Table Structure for detector.scanEntities(): { { canFreeze = true, health = 20, id = 1, isGlowing = false, isInWall = false, maxHealth = 20, name = "LunaFolf", tags = {}, uuid = "f48e6371-3ed0-4738-a5e0-0f29bc2da9d4", x = 3.4389338271924, y = 0, z = -0.18627323016072 }, ... } --]] function toggleDoor(open) if isDoorOpen == open then print("Door is already ", open and "open" or "closed") print("Skipping toggle.") return end gearshift.rotate(90, open and -1 or 1) isDoorOpen = open local doorStateFile = fs.open(".door_state", "w") if doorStateFile then doorStateFile.writeLine(open and "1" or "0") doorStateFile.close() end end -- Main loop while true do local detectedEntities = nil if not gearshift.isRunning() then detectedEntities = detector.scanEntities(4) -- Scan within 4 blocks end local userDetected = false if detectedEntities ~= nil then for _, entity in ipairs(detectedEntities) do for _, allowedUUID in ipairs(allowedUsers) do if entity.uuid == allowedUUID and entity.y >= minYLevel then userDetected = true break end end if userDetected then break end end if userDetected and not isDoorOpen then toggleDoor(true) elseif not userDetected and isDoorOpen then toggleDoor(false) end end end
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)