Advertisement
NanoBob

SpawnerControl

Mar 24th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. os.loadAPI("button")
  2. button.setMonitorSide("monitor_0")
  3. local monitor=peripheral.wrap("monitor_0")
  4.  
  5. local screenx,screeny=monitor.getSize()
  6. local descriptionBox={["x"]=screenx*0.05,["y"]=screeny*0.55,["width"]=screenx*0.93,["height"]=screeny*0.45}
  7.  
  8. function writeDescription(desc)
  9.     for y=descriptionBox.y,descriptionBox.y+descriptionBox.height do
  10.         monitor.setCursorPos(1,y)
  11.         for i=descriptionBox.x,descriptionBox.x+descriptionBox.width do
  12.             local x,y=monitor.getCursorPos()
  13.             monitor.setCursorPos(math.floor(i),y)
  14.             monitor.setBackgroundColor(256)
  15.             monitor.write(" ")
  16.         end
  17.     end
  18.    
  19.     local yIndex=1
  20.     for y=descriptionBox.y,descriptionBox.y+descriptionBox.height do
  21.         local line=desc[yIndex]
  22.         yIndex=yIndex+1
  23.         if line~=nil then
  24.             monitor.setCursorPos(math.floor(descriptionBox.x),y)
  25.             local line=string.sub(line,0,math.floor(descriptionBox.width+0.5))
  26.             monitor.write(line)
  27.         end
  28.     end
  29.    
  30. end
  31.  
  32. local spawners={}
  33. spawners[1]={
  34.     ["type"]="Skeleton",
  35.     ["side"]="front",
  36.     ["description"]={
  37.         "ID : A101",
  38.         "Technical name : space skeleton",
  39.         "Drops : arrows & bones.",
  40.         "Rare Drops : bows, various armor sets",
  41.         "Abilites : can fire 2 bows ",
  42.         "Habitat : dark areas on the moon",
  43.         "Notes : This create seems to have intelligence",
  44.         "        as it found a way to wear oxygen gear",
  45.     }, 
  46.     }
  47. spawners[1]["func"]=
  48. function(bool)
  49.     redstone.setOutput(spawners[1].side,bool)
  50.     if bool==false then return end
  51.     writeDescription(spawners[1].description)
  52. end
  53.  
  54. spawners[2]={
  55.     ["type"]="Enderman",
  56.     ["side"]="left",
  57.     ["description"]={
  58.         "ID : A102",
  59.         "Technical name : screaming shadow",
  60.         "Drops : ender pearls",
  61.         "Rare Drops : N/A",
  62.         "Abilites : can teleport with limited range ",
  63.         "Habitat : the end",
  64.         "Notes : We believe this creature may have found",
  65.         "        a way to teleport between dimensions",
  66.     },
  67.     }
  68. spawners[2]["func"]=
  69. function(bool)
  70.     redstone.setOutput(spawners[2].side,bool)
  71.     if bool==false then return end
  72.     writeDescription(spawners[2].description)
  73. end
  74.  
  75. function setup()   
  76.     for id,spawner in ipairs(spawners) do
  77.         redstone.setOutput(spawner.side,false)
  78.         if id<=2 then
  79.             button.addButton(0.05+0.5*(id-1),0.08,0.4,0.15,spawner.type,spawner.func,true,true,16384,32,1)
  80.         else
  81.             button.addButton(0.05+0.5*(id-1),0.33,0.4,0.15,spawner.type,spawner.func,true,true,16384,32,1)         
  82.         end
  83.     end
  84.     button.addButton(0.95,0.95,0.05,0.08,"  ",function() os.reboot() end,true,true,16384,32,1)
  85. end
  86.  
  87. setup()
  88.  
  89. while true do
  90.     button.run()
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement