Guest User

Broadcast server messages part 2

a guest
Oct 10th, 2013
49
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Call this program 'startup'
  2. -- This program needs a second program called 'Broadcast'
  3. -- This program will send server messages and needs command blocks enabled in both CC and server.properties
  4.  
  5. local function CheckVariables()
  6.   if fs.exists("Variables") then
  7.     readData = fs.open("Variables", "r")
  8.     Side = readData.readLine()
  9.     Amount = readData.readLine()
  10.     Repeat = readData.readLine()
  11.     for i = 1, Amount do
  12.       Message[i] = readData.readLine()
  13.     end
  14.     readData.close()
  15.   else
  16.     term.setTextColor(colors.red)
  17.     print("File Variables not found!")
  18.     sleep(5)
  19.     shell.run("Broadcast")
  20.   end
  21. end
  22.  
  23. local function Broadcast()
  24.   Interval = Repeat*60
  25.   commandBlock = peripheral.wrap(Side)
  26.   for i = 1, Amount do
  27.     commandBlock.setCommand("/say "..Message[i])
  28.     commandBlock.runCommand()
  29.     sleep(Interval)
  30.   end
  31.   Broadcast()
  32. end
  33.  
  34. term.clear()
  35. term.setCursorPos(1,1)
  36. term.setTextColor(colors.white)
  37. Message = {}
  38. CheckVariables()
  39. print("Now broadcasting messages to the server!")
  40. Broadcast()
RAW Paste Data