Advertisement
Tatantyler

Simple Server Starter

Jan 30th, 2013
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. -- RunServer Program:
  2. -- By KillaVanilla
  3.  
  4. local servers = {}
  5.  
  6. -- Check and load servers in "servers/" (and load parameters):
  7. for i=1, #fs.list("servers/") do
  8.     local paramListFile = io.open("parameters/"..fs.list("servers/")[i], "r")
  9.     local paramList = {}
  10.     for line in paramListFile:lines() do
  11.         for parameter in string.gmatch(line, "([%w%p%S]+)%s+") do
  12.             table.insert(paramList, parameter)
  13.         end
  14.     end
  15.     local fn = function() shell.run("servers/"..fs.list("servers/")[i], unpack(parameters)) end
  16.     table.insert(servers, fn)
  17. end
  18.  
  19. -- actually run the servers and CraftOS / whatever OS the end-user happens to be using:
  20. if not _G["startupRun"] then
  21.     _G["startupRun"] = true
  22.     if fs.exists("servers/startup") then
  23.         parallel.waitForAll(function() shell.run("servers/startup") end, unpack(servers))
  24.     else
  25.         parallel.waitForAll(function() shell.run("shell") end, unpack(servers))
  26.     end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement