local function center(monitor, text)
  local x, y = monitor.getSize()
  monitor.setCursorPos((x-text:len())/2+1, (y-1)/2+1)
end 
redstone.setOutput("bottom", false)
m = peripheral.wrap("top")
m.setTextScale(1)
m.clear()
m.setCursorPos(1, 1)
term.redirect(m)
print("Rules")
print("Complete all objectives to finish")
print("Don't interfere with turtles or golems")
print("Don't destroy blocks on the temple or spawn")
print("Right click to begin")
print()
print()
print("[Hint - To open door drop a gold and iron ingot at the front of the temple")
term.restore()
os.pullEvent("monitor_touch")
m.setTextScale(4)
m.clear()
m.setTextColor(colors.yellow)
for i = 5, 1, -1 do
  local text = string.format("%i", i)
  center(m, text)
  m.write(text)
  os.sleep(1)
end
m.clear()
center(m, "GO!")
m.setTextColor(colors.green)
m.write("GO!")
os.sleep(.5)
redstone.setOutput("bottom", true)
os.loadAPI("ocs/apis/sensor")
local s = sensor.wrap("left")
local name = next(s.getTargets())
rednet.open("right")
rednet.send(5, name)
rednet.close("right")
m.clear()
m.setTextColor(colors.white)
