Advertisement
sanovskiy

Warp_Summon

Nov 12th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. Side = { "bottom", "top", "back", "left", "right" }
  2. for i = 1,5 do
  3.   print(Side[i].." : "..tostring(peripheral.getType(Side[i])))
  4.   if peripheral.getType(Side[i]) == "warpcore" then
  5.     warp = peripheral.wrap(Side[i])
  6.     print("Warp found at "..Side[i])
  7.     break
  8.   else
  9.     print("No core at "..Side[i])
  10.   end
  11. end
  12. if warp==nil then
  13.   error("Can't find warp core!")
  14. end
  15.  
  16.  
  17.     Style = {
  18.      CDeflt = colors.white,
  19.      BGDeflt = colors.blue,
  20.      CTitle = colors.black,
  21.      BGTitle = colors.cyan,
  22.      CWarn = colors.white,
  23.      BGWarn = colors.red
  24.     }
  25.      
  26.     function SetColorDeflt()
  27.      term.setBackgroundColor(Style.BGDeflt)
  28.      term.setTextColor(Style.CDeflt)
  29.     end
  30.      
  31.     function SetColorTitle()
  32.      term.setBackgroundColor(Style.BGTitle)
  33.      term.setTextColor(Style.CTitle)
  34.     end
  35.      
  36.     function SetColorWarn()
  37.      term.setBackgroundColor(Style.BGWarn)
  38.      term.setTextColor(Style.CWarn)
  39.     end
  40.      
  41.     function Clear()
  42.      term.clear()
  43.      term.setCursorPos(1,1)
  44.     end
  45.      
  46.     function Show(Text)
  47.      term.write(Text)
  48.      local xt,yt = term.getCursorPos()
  49.      term.setCursorPos(1, yt+1)
  50.     end
  51.      
  52.     function ShowTitle(Text)
  53.      SetColorTitle()
  54.      term.setCursorPos(12, 1)
  55.      Show(Text)
  56.      SetColorDeflt()
  57.     end
  58.      
  59.     function ShowMenu(Text)
  60.      term.write(Text)
  61.      local xt, yt = term.getCursorPos()
  62.      for i = xt, 51 do
  63.       term.write(" ")
  64.      end
  65.      term.setCursorPos(1, yt+1)
  66.     end
  67.      
  68.     function ShowWarning(Text)
  69.       SetColorWarn()
  70.       term.setCursorPos(10, 19)
  71.       term.write(" "..Text.." ")
  72.       SetColorDeflt()
  73.     end
  74.    
  75.    function Summon()
  76.      Clear()
  77.      ShowTitle("<==== Summon players ====>")
  78.      local players = Explode(",", warp.get_attached_players())
  79.      for i = 1, #players do
  80.       Show(i..". "..players[i])
  81.      end
  82.      SetColorTitle()
  83.      ShowMenu("Enter player number")
  84.      ShowMenu("or press enter to summon everyone")
  85.      SetColorDeflt()
  86.      sleep(0.3)
  87.      term.write(":")
  88.      local input = read()
  89.      if input == "" then
  90.       warp.summon_all()
  91.      else
  92.       input = tonumber(input)
  93.       warp.summon(input - 1)
  94.      end
  95.    end
  96.  
  97. Summon()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement