Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- API --------------------------------------------------
- local w, h = term.getSize()
- function printCentered(y, str)
- local x = math.floor((w - string.len(str)) / 2)
- term.setCursorPos(x, y)
- term.clearLine()
- term.write(str)
- end
- function printThird(y, third, str)
- local third_width = w / 3
- -- Centre position of the requested third
- local centre_x = (third - 0.5) * third_width
- local x = math.floor(centre_x - (#str / 2))
- term.setCursorPos(x, y)
- term.write(str)
- end
- function hasValue (tab, val)
- for index, value in ipairs(tab) do
- if value == val then
- return true
- end
- end
- return false
- end
- function printKeys(tab)
- -- Source - https://stackoverflow.com/a/12674376
- -- Posted by lhf
- -- Retrieved 2026-06-11, License - CC BY-SA 3.0
- local keyset={}
- local n=0
- for k,v in pairs(tab) do
- n=n+1
- keyset[n]=k
- end
- print(textutils.serialise(keyset))
- end
- function printTable(tab)
- for key, val in pairs(tab) do
- print(tostring(key) .. ": " .. tostring(val))
- end
- end
- ---------------------------------------------------------
- -- State here is defined as false=closed,true=open
- -- The Airlock door that transitions from planet to airlock
- local airlock_enter_state = false
- -- The Airlock door that transitions from airlock to inside
- local airlock_exit_state = false
- function main()
- local airlock_enter_state_reader = peripheral.find("blockReader")
- printTable(airlock_enter_state_reader.getBlockStates())
- airlock_enter_state = airlock_enter_state_reader.getBlockStates()["open"]
- print(airlock_enter_state)
- while true do
- if redstone.getInput("back") == true then
- print("Button Pressed!")
- break
- end
- os.sleep(0.1)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment