Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pkg = {["car"]="run = true!@#&local GameRate = 0.10!@#&local grID = os.startTimer(GameRate)!@#&local w,h = term.getSize()!@#&score = 5!@#&player = {!@#&xpos = math.floor(w/2);!@#&ypos = h-4;!@#&!@#& updatePlayer = function(self,key)!@#& if key == keys.left and self.xpos >=20 then -- max20!@#& self.xpos = self.xpos - 1 !@#& elseif key == keys.right and self.xpos <=27 then -- max32!@#& self.xpos = self.xpos + 1 !@#& end!@#&end;!@#& !@#& drawPlayer = function(self)!@#& !@#& ch = paintutils.loadImage(\"sprites/playercar\")!@#& paintutils.drawImage(ch,self.xpos,self.ypos)!@#& end!@#&!@#&}!@#&!@#&enemy = {!@#&xpos = math.max(math.random(20,27),0);!@#&ypos = 1;!@#&carnum = math.max(math.random(1,3),0);!@#&!@#&drawEnemy = function(self)!@#&c = paintutils.loadImage(\"sprites/1\")!@#&paintutils.drawImage(c,self.xpos,self.ypos)!@#&end;!@#&!@#&updateEnemy = function(self,speed)!@#&if self.ypos == 18 then!@#&self.ypos = 1 !@#&self.xpos = math.max(math.random(20,27),0);!@#&else!@#&self.ypos = self.ypos+1!@#&enemy:drawEnemy()!@#& end!@#&end;!@#&!@#&!@#&!@#&}!@#&function updateGame()!@#& if player.xpos <= enemy.xpos-1 and player.xpos >= enemy.xpos-3 and player.ypos == enemy.ypos+4 or player.xpos >= enemy.xpos and player.xpos <= enemy.xpos+4 and player.ypos == enemy.ypos+4 then!@#& run = false!@#& end!@#&local event, button = os.pullEvent()!@#&if event == \"key\" then!@#&if button == keys.backspace then run = false end!@#&player:updatePlayer(button)!@#&elseif event == \"timer\" and button == grID then!@#&score = score + 5!@#&enemy:updateEnemy()!@#&grID = os.startTimer(GameRate)!@#&end !@#&end!@#&!@#&!@#&function drawGame()!@#&term.setBackgroundColor(colors.gray)!@#&term.clear()!@#&bk = paintutils.loadImage(\"sprites/world/carbk\")!@#&paintutils.drawImage(bk,1,1)!@#&term.setCursorPos(1,1)!@#&print(\"Score: \"..score)!@#&player:drawPlayer()!@#&enemy:drawEnemy()!@#&end!@#&!@#&!@#&function loopGame()!@#&while run do!@#&drawGame()!@#&updateGame()!@#&end!@#&while run == false do!@#&term.setTextColor(colors.yellow)!@#&term.setCursorPos(math.floor(w/2 -8),math.floor(h/2))!@#&term.setBackgroundColor(colors.black)!@#&term.clear()!@#&term.setTextColor(colors.yellow)!@#&print \"G A M E O V E R \"!@#&term.setCursorPos(math.floor(w/2 -6),math.floor(h/2+1))!@#&print(\"Final Score: \"..score)!@#&sleep(1)!@#&break!@#&end!@#&end!@#&loopGame()",["Mechwarrior"]="!@#&!@#&!@#&run = true!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&p = paintutils.loadImage(\"sprites/cockpits/player\")!@#&bg = paintutils.loadImage(\"sprites/maps/map1\")!@#&en = paintutils.loadImage(\"sprites/models/enemy\")!@#&boom = paintutils.loadImage(\"sprites/models/bomb\")!@#&paintutils.drawImage(bg,1,1)!@#&sleep(0.1)!@#&paintutils.drawImage(p,1,1)!@#&movetime = 0.8!@#&etID = os.startTimer(movetime)!@#&fire = true!@#&firerate = 0.5!@#&health = 10!@#&ehealh = 3!@#&emax = 3!@#&dest = 5!@#&down = 0!@#&todest = 5!@#&score = 0!@#&mecha = {!@#&xpos = 23;!@#&ypos = 8;!@#&hit = function(self)!@#&term.setBackgroundColor(colors.red)!@#&if health <= 1 then!@#&term.setBackgroundColor(colors.black)!@#&term.clear()!@#&term.setTextColour(colors.yellow)!@#&term.setCursorPos(16,5)!@#&print \" G A M E O V E R\"!@#&term.setCursorPos(16,6)!@#&print (\" Score: \"..score)!@#&sleep(0.5)!@#&term.setCursorPos(18,8)!@#&print \" PRESS ANY KEY\"!@#&event = os.pullEvent(\"key\")!@#&run = false!@#&else!@#&health = health - 1!@#&term.clear()!@#&sleep(0.4)!@#&etID = os.startTimer(movetime)!@#&frID = os.startTimer(firerate)!@#&end!@#&end;!@#&!@#&fire = function(self)!@#&term.setCursorPos(mecha.xpos+1,mecha.ypos+1)!@#&term.setBackgroundColor(colors.black)!@#&print \"X\"!@#&sleep(0.02)!@#&if self.xpos+1 >= enemy.xpos+3 and self.xpos <= enemy.xpos+8 and self.ypos >=enemy.ypos and self.ypos <= enemy.ypos+4 then!@#&ehealh = ehealh - 1!@#&enemy:update()!@#&movetime = 0.8!@#&etID = os.startTimer(movetime)!@#&else!@#&enemy:update()!@#&movetime = 0.8!@#&etID = os.startTimer(movetime)!@#&end!@#&end;!@#&!@#&update = function(self, button)!@#&if button == keys.w and self.ypos >=3 then!@#&self.ypos = self.ypos - 1!@#&elseif button == keys.s and self.ypos+2 <=12 then!@#&self.ypos = self.ypos + 1!@#&elseif button == keys.a and self.xpos > 3 then!@#&self.xpos = self.xpos - 1!@#&elseif button == keys.d and self.xpos < 45 then!@#&self.xpos = self.xpos + 1!@#&end!@#&end;!@#&!@#&draw = function(self)!@#&term.setCursorPos(self.xpos,self.ypos)!@#&term.setBackgroundColor(colors.red)!@#&print \" \"!@#&term.setCursorPos(self.xpos,self.ypos+1)!@#&print \" \"!@#&term.setCursorPos(self.xpos+2,self.ypos+1)!@#&print \" \"!@#&term.setCursorPos(self.xpos,self.ypos+2)!@#&print \" \"!@#&end!@#&!@#&}!@#&!@#&enemy = {!@#&xpos = math.random(4,40);!@#&ypos = math.random(5,6);!@#&!@#& update = function(self)!@#& if ehealh <=0 then!@#& self.xpos = math.random(4,40)!@#& self.ypos = math.random(5,6)!@#& health = health + 2!@#& term.clear()!@#& paintutils.drawImage(bg,1,1)!@#&paintutils.drawImage(p,1,1)!@#& paintutils.drawImage(boom, self.xpos, self.ypos)!@#& dest = dest - 1!@#& down = down + 1!@#& score = score + 200!@#&sleep(1.5)!@#&ehealh = 3!@#&else !@#& choose = math.max(math.random(1,4),0)!@#& if choose == 1 or choose == 2 or choose == 3 then!@#& self.xpos = math.random(4,40)!@#& self.ypos = math.random(5,6)!@#& paintutils.drawImage(en,self.xpos,self.ypos)!@#& elseif choose == 4 then!@#& term.setCursorPos(self.xpos+5,self.ypos+2)!@#& print \"*\"!@#& sleep(0.1)!@#& mecha:hit()!@#& end!@#& end!@#& end;!@#&!@#&draw = function(self)!@#&paintutils.drawImage(en,self.xpos,self.ypos)!@#&term.setBackgroundColor(colors.gray)!@#&term.setCursorPos(self.xpos+1,self.ypos-1)!@#&print(ehealh..\"/\"..emax)!@#&end!@#&!@#&}!@#&!@#&function drawGame()!@#&term.setBackgroundColor(colors.black)!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&p = paintutils.loadImage(\"sprites/cockpits/player\")!@#&bg = paintutils.loadImage(\"sprites/maps/map1\")!@#&paintutils.drawImage(bg,1,1)!@#&paintutils.drawImage(p,1,1)!@#&enemy:draw()!@#&mecha:draw()!@#&!@#&term.setBackgroundColor(colors.gray)!@#&term.setCursorPos(4,17)!@#&print(\"Health: \")!@#&term.setCursorPos(11,17)!@#&!@#&if health == 11 or health == 10 or health == 9 or health == 8 or health == 7 or health == 6 then!@#&term.setBackgroundColor(colors.green)!@#&term.write(string.rep(\" \", health))!@#&!@#&elseif health == 5 then!@#&term.setBackgroundColor(colors.orange)!@#&term.write(string.rep(\" \", health))!@#&!@#&elseif health == 4 or health == 3 or health == 2 or health == 1 then!@#&term.setBackgroundColor(colors.red)!@#& term.write(string.rep(\" \", health))!@#&end!@#&end!@#&!@#&!@#&function updateGame()!@#&local event, info = os.pullEvent()!@#& !@#& if event == \"key\" then!@#& if info == keys.backspace then run = false end!@#& mecha:update(info)!@#& end!@#& !@#&if event == \"key\" and info == keys.space and fire == true then!@#&mecha:fire()!@#&frID = os.startTimer(firerate)!@#&fire = false!@#&end!@#& !@#&if event == \"timer\" and info == frID then!@#&fire = true!@#&!@#&elseif info == etID then!@#&enemy:update()!@#&etID = os.startTimer(movetime)!@#&score = score + 30!@#&end!@#&!@#&end!@#&!@#&function loop()!@#&while run do!@#&drawGame()!@#&updateGame()!@#&end!@#&end!@#&loop()",["portalsim"]="por = false!@#&por2 = false!@#&unstart = true!@#&px = 1!@#&py = 1!@#&term.setBackgroundColor(colors.cyan)!@#&term.clear()!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&if por == true then!@#&bpx = px !@#&bpy = py!@#&term.setCursorPos(bpx,bpy)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&end!@#&!@#&function move()!@#&while run do!@#&if px == bpx and py == bpy and por2 == true then!@#&px = bp2x+1!@#&py = bp2y!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&elseif px == bp2x and py == bp2y and por == true then!@#&px = bpx+1!@#&py = bpy!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&end!@#&local event, button = os.pullEventRaw(\"key\")!@#&if button == keys.w then!@#& if py ~= 1 then!@#& py = py - 1!@#& term.setBackgroundColor(colors.cyan)!@#&term.clear()!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&if por == true then!@#&term.setCursorPos(bpx,bpy)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&end!@#&if por2 == true then!@#&term.setCursorPos(bp2x,bp2y)!@#&term.setBackgroundColor(colors.orange)!@#&print \" \"!@#&end!@#&end!@#&!@#&elseif button == keys.s then!@#& !@#& if py ~= 18 then!@#& py = py + 1!@#& term.setBackgroundColor(colors.cyan)!@#&term.clear()!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&if por == true then!@#&term.setCursorPos(bpx,bpy)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&end!@#&if por2 == true then!@#&term.setCursorPos(bp2x,bp2y)!@#&term.setBackgroundColor(colors.orange)!@#&print \" \"!@#&end!@#& end!@#&!@#&elseif button == keys.a then!@#& if px ~= 1 then!@#& px = px - 1!@#& term.setBackgroundColor(colors.cyan)!@#&term.clear()!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&if por == true then!@#&term.setCursorPos(bpx,bpy)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&end!@#&if por2 == true then!@#&term.setCursorPos(bp2x,bp2y)!@#&term.setBackgroundColor(colors.orange)!@#&print \" \"!@#&end!@#&end!@#&!@#&elseif button == keys.d then!@#& if px ~= 51 then!@#& px = px + 1!@#& term.setBackgroundColor(colors.cyan)!@#&term.clear()!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&if por == true then!@#&term.setCursorPos(bpx,bpy)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&end!@#&if por2 == true then!@#&term.setCursorPos(bp2x,bp2y)!@#&term.setBackgroundColor(colors.orange)!@#&print \" \"!@#&end!@#&end!@#&!@#&!@#&elseif button == keys.leftShift then!@#& term.setBackgroundColor(colors.cyan)!@#&term.clear()!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&por = true!@#&bpx = px+1!@#&bpy = py!@#&term.setCursorPos(bpx,bpy)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&if por2 == true then!@#&term.setCursorPos(bp2x,bp2y)!@#&term.setBackgroundColor(colors.orange)!@#&print \" \"!@#&end!@#&!@#&elseif button == keys.rightShift then!@#& term.setBackgroundColor(colors.cyan)!@#&term.clear()!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&por2 = true!@#&bp2x = px+1!@#&bp2y = py!@#&term.setCursorPos(bp2x,bp2y)!@#&term.setBackgroundColor(colors.orange)!@#&print \" \"!@#&if por == true then!@#&term.setCursorPos(bpx,bpy)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&end!@#&elseif button == keys.backspace then!@#&run = false!@#&return!@#&end!@#&end!@#&end!@#&!@#&function detect()!@#&if px == bpx and py == bpy and por2 == true then!@#&px = bp2x !@#&py = bp2y!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&elseif px == bp2x and py == bp2y and por == true then!@#&px = bpx !@#&py = bpy!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&end!@#&end!@#&!@#&while unstart do!@#&term.setCursorPos(10,5)!@#&term.setBackgroundColor(colors.yellow)!@#&print \" PortalSIM By Redxone \"!@#&term.setCursorPos(10,6)!@#&print \" Press Enter To Start \"!@#&term.setCursorPos(10,7)!@#&print \" Press Backspace To Exit \"!@#&event, button = os.pullEvent(\"key\")!@#&if button == keys.enter then!@#&run = true!@#&unstart = false!@#&term.setBackgroundColor(colors.cyan)!@#&term.clear()!@#&term.setCursorPos(px,py)!@#&term.setBackgroundColor(colors.gray)!@#&print \" \"!@#&move()!@#&end!@#&end",["beams"]="m = \"1\"!@#&local pX = 10!@#&local pY = 6!@#&local sc = 0!@#&run = true!@#&beam = math.max(math.random(1,20),0)!@#&local icolor = colors.white!@#&local pcolor = colors.blue!@#&local bcolor = colors.red!@#&local reset = colors.black!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(pcolor)!@#&print(\" \")!@#&term.setBackgroundColor(colors.lightBlue)!@#&!@#&i = paintutils.loadImage(\"sprites/world/bworld\")!@#&paintutils.drawImage(i,1,1)!@#&term.setCursorPos(1,5)!@#& iX = math.max(math.random(1,40),0)!@#&iY = math.max(math.random(5,17),0)!@#&term.setTextColor(colors.black)!@#&term.setCursorPos(iX,iY)!@#&term.setBackgroundColor(icolor)!@#&print \"I\"!@#& i2X = math.max(math.random(1,40),0)!@#&i2Y = math.max(math.random(5,17),0)!@#&term.setTextColor(colors.black)!@#& term.setCursorPos(i2X,i2Y)!@#&term.setBackgroundColor(icolor)!@#&print \"I\"!@#&term.setBackgroundColor(colors.black)!@#&term.setTextColor(colors.white)!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.setCursorPos(1,1)!@#&print \"--------------------------------------------------\"!@#&print \"| Wellcome to Beams: |\"!@#&print(\"| Score: \" ..sc)!@#&print \"--------------------------------------------------\"!@#&term.setCursorPos(50,3)!@#&print \"|\"!@#&!@#&function db()!@#&i = paintutils.loadImage(\"sprites/world/bworld\")!@#&paintutils.drawImage(i,1,1)!@#&end!@#&!@#&function reitem()!@#&term.setTextColor(colors.black)!@#&term.setCursorPos(iX,iY)!@#&term.setBackgroundColor(icolor)!@#&print \"I\"!@#&term.setTextColor(colors.black)!@#& term.setCursorPos(i2X,i2Y)!@#&term.setBackgroundColor(icolor)!@#&print \"I\"!@#&end!@#&!@#&function rei()!@#& iX = math.max(math.random(1,40),0)!@#&iY = math.max(math.random(6,17),0)!@#&term.setTextColor(colors.black)!@#&term.setCursorPos(iX,iY)!@#&term.setBackgroundColor(icolor)!@#&print \"I\"!@#& i2X = math.max(math.random(1,40),0)!@#&i2Y = math.max(math.random(6,17),0)!@#&term.setTextColor(colors.black)!@#& term.setCursorPos(i2X,i2Y)!@#&term.setBackgroundColor(icolor)!@#&print \"I\"!@#&end!@#&!@#&function drawLabel()!@#&term.setBackgroundColor(colors.black)!@#&term.setTextColor(colors.white)!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.setCursorPos(1,1)!@#&print \"--------------------------------------------------\"!@#&print \"| Wellcome to Beams: |\"!@#&print(\"| Score: \" ..sc)!@#&print \"--------------------------------------------------\"!@#&term.setCursorPos(50,3)!@#&print \"|\"!@#&term.setCursorPos(1,5)!@#&term.setTextColor(colors.black)!@#&end!@#&!@#&!@#&function drawChar()!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(pcolor)!@#&print(\" \")!@#&term.setBackgroundColor(reset)!@#&end!@#&!@#&function check()!@#&if pX == iX and pY == iY then!@#&term.setCursorPos(iX,iY)!@#&term.setBackgroundColor(reset)!@#&print \" \"!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#& warn()!@#&sc = sc + 10!@#&drawLabel()!@#&sleep(0.5)!@#&rei() !@#& elseif pX == i2X and pY == i2Y then!@#& term.setCursorPos(i2X,i2Y)!@#&term.setBackgroundColor(reset)!@#&print \" \"!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&warn()!@#&sc = sc + 10!@#&drawLabel()!@#&sleep(0.5)!@#&rei()!@#&end!@#&end!@#&!@#&function warn()!@#&term.setBackgroundColor(colors.red)!@#&term.setCursorPos(1,5)!@#&print(\" Next Beam At Line: \"..beam..\" \")!@#&end!@#&!@#&function beeam()!@#&!@#&ranb = math.max(math.random(1,30),0)!@#&if ranb == 5 then!@#&term.setCursorPos(54,beam)!@#&sleep(0.1)!@#&!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&be = beam + 1!@#&term.setCursorPos(1,1)!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&term.setBackgroundColor(colors.red)!@#&term.setCursorPos(54,beam)!@#&print(\"================================================\")!@#&sleep(0.2)!@#&beam = math.max(math.random(6,17),0)!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&if be == pY then!@#&term.setBackgroundColor(colors.black)!@#&term.clear()!@#&term.setCursorPos(10,5)!@#&term.setTextColor(colors.yellow)!@#&print \"Game Over\"!@#&term.setCursorPos(10,6)!@#&print(\"Score: \"..sc)!@#&sleep(2)!@#&print \"Hit Any Key To Continue.\"!@#&event = os.pullEvent()!@#&run = false!@#&term.setBackgroundColor(colors.black)!@#&term.clear()!@#&return!@#&else!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&db()!@#&drawLabel()!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&!@#& term.setCursorPos(iX,iY)!@#&term.setBackgroundColor(icolor)!@#&print \"I\"!@#& term.setCursorPos(i2X,i2Y)!@#&term.setBackgroundColor(icolor)!@#&print \"I\"!@#&move()!@#&term.setCursorPos(pX,pY)!@#&term.setBackgroundColor(colors.blue)!@#&print \" \"!@#&return move()!@#&end!@#&end!@#&end!@#&!@#&!@#&function move()!@#&while run == true do!@#&local event, button = os.pullEventRaw(\"key\")!@#&term.setTextColor(colors.white)!@#&term.setBackgroundColor(colors.black)!@#&!@#& if button == 200 then --up!@#& if pY == 6 then!@#& term.setCursorPos(1,1)!@#& print \"Cantmove\"!@#& event = os.pullEvent(\"key\")!@#& drawLabel()!@#& move()!@#& else!@#& sleep(0.001)!@#&db()!@#&reitem()!@#&drawLabel()!@#& pY = pY - 1!@#& print \" \"!@#& !@#& drawChar()!@#& check()!@#& beeam()!@#& warn()!@#& end!@#& end!@#& !@#& if button == 208 then -- down!@#& if pY == 18 then!@#& term.setCursorPos(1,1)!@#& print \"Cantmove\"!@#& event = os.pullEvent(\"key\")!@#& drawLabel()!@#& else!@#& sleep(0.001)!@#& db()!@#&reitem()!@#&drawLabel()!@#& pY = pY + 1!@#& !@#& check()!@#& beeam()!@#& warn()!@#&drawChar()!@#& end!@#& end!@#& !@#& if button == 203 then -- left!@#& if pX == 1 then!@#& term.setCursorPos(1,1)!@#& print \"Cantmove\"!@#& event = os.pullEvent(\"key\")!@#& drawLabel()!@#& move()!@#& else!@#& sleep(0.001)!@#& pX = pX - 1!@#&db()!@#&reitem()!@#&drawLabel()!@#& check()!@#& beeam()!@#& warn()!@#&drawChar()!@#& end!@#& end!@#& !@#& if button == 205 then -- right!@#& if pX == 51 then!@#& term.setCursorPos(1,1)!@#& print \"Cantmove\"!@#& event = os.pullEvent(\"key\")!@#& drawLabel()!@#& move()!@#& else!@#& sleep(0.001)!@#&db()!@#&reitem()!@#&drawLabel()!@#& pX = pX + 1!@#& !@#& check()!@#& beeam()!@#& warn()!@#& drawChar()!@#& end!@#& end!@#&end!@#&end!@#&move()",["wordclick"]="local tArgs = { ... }!@#& if(#tArgs < 1)then!@#& error \"Usage: wordclick <word>\"!@#& else!@#& start = true!@#& end!@#& !@#&refresh = 0.8!@#&rate = os.startTimer(refresh)!@#&xr = math.max(math.random(1,30), 0)!@#&yr = math.max(math.random(2,16), 0)!@#&term.clear()!@#&term.setCursorPos(xr, yr)!@#&word = tArgs[1]!@#&print(word)!@#&leng = word:len()!@#&clk = 0!@#&moved = 0!@#&accur = 100!@#&!@#&function draw(rxy)!@#& if(rxy == true)then!@#& xr = math.max(math.random(1,30), 0)!@#& yr = math.max(math.random(1,16), 0)!@#& end!@#& term.clear()!@#& term.setCursorPos(xr, yr)!@#& word = tArgs[1]!@#& print(word)!@#& term.setCursorPos(1,1)!@#& print(\"Clicks: \"..clk)!@#& term.setCursorPos(15,1)!@#& print(\"Accuate: \"..accur..\"%\")!@#&end!@#&!@#&function resetTime()!@#& rate = os.startTimer(refresh)!@#&end!@#&!@#&while start do!@#& local event, button, x, y = os.pullEvent()!@#& !@#& if(event == \"mouse_click\")then!@#& if(x >= xr and x <= xr + word:len() - 1 and y == yr)then!@#& clk = clk + 1!@#& accur = accur + 2!@#& draw(false)!@#& else!@#& term.setCursorPos(x,y)!@#& term.setBackgroundColor(colors.red)!@#& print \" \"!@#& term.setBackgroundColor(colors.black)!@#& if(accur > 0)then!@#& accur = accur - 1!@#& end!@#& end!@#& end!@#& !@#& if(event == \"timer\")then!@#& if(button == rate)then!@#& if(accur > 0)then!@#& accur = accur - 1!@#& end!@#& draw(true)!@#& resetTime()!@#& moved = moved + 1!@#& end!@#& end!@#& !@#& if(event == \"key\")then!@#& if(key == keys.BACKSPACE)then!@#& return!@#& end!@#& end!@#&end",["Lasers"]="--[[!@#& [Game] Lasers!@#& @version 1.2, 29/12/2013, \"Error: Lasers malfunctioning\"!@#& @author Hellkid98, HK98!@#&--]]!@#&!@#&local w,h = term.getSize()!@#&!@#&local oldPullEvent = os.pullEvent!@#&os.pullEvent = os.pullEventRaw!@#&!@#&local player = {!@#&!@#& !@#& dead = false,!@#& side = \"down\",!@#& !@#& [\"sides\"] = {!@#& [\"left\"] = {!@#& art = \"<\",!@#& },!@#& !@#& [\"right\"] = {!@#& art = \">\",!@#& },!@#& !@#& [\"down\"] = {!@#& art = \"v\",!@#& },!@#& !@#& [\"up\"] = {!@#& art = \"^\",!@#& },!@#& },!@#&}!@#&!@#&local player2 = {}!@#&!@#&!@#&!@#&!@#&!@#&!@#&!@#&local function pGet(hCode,file)!@#&!@#& hResponse = http.get(\"http://pastebin.com/raw.php?i=\"..textutils.urlEncode(hCode))!@#& if hResponse then!@#& hFile = fs.open(file,\"w\")!@#& local sCode = hResponse.readAll()!@#& hResponse.close()!@#& hFile.write(sCode)!@#& hFile.close()!@#& !@#& else !@#& error(\"Error getting file: \"..file,0)!@#& fs.delete(\".Lasers_Data\") -- If a file failed to download!@#& end!@#&end!@#& !@#&if not fs.exists(\".Lasers_Data\") then!@#& local folders = {!@#& \".Lasers_Data/APIs\", \".Lasers_Data/Settings\", \".Lasers_Data/Themes\",!@#& }!@#& !@#& local apis = {!@#& [1] = {!@#& name = \"gui\",!@#& code = \"MQvDWS5M\",!@#& },!@#& !@#& [2] = {!@#& name = \"rNet\",!@#& code = \"r3ueCHfs\",!@#& }!@#& }!@#& !@#& term.clear() !@#& term.setCursorPos(1,1)!@#& !@#& for i = 1, #folders do!@#& print(\"Creating: \"..folders[i])!@#& fs.makeDir(folders[i])!@#& end!@#& !@#& for i = 1,#apis do!@#& print(\"Downloading: \"..apis[i].name)!@#& pGet(apis[i].code,\".Lasers_Data/APIs/\"..apis[i].name)!@#& end!@#&end!@#&!@#&!@#&for _, file in ipairs( fs.list(\".Lasers_Data/APIs/\") ) do!@#& os.unloadAPI(\".Lasers_Data/APIs/\" .. file)!@#& os.loadAPI(\".Lasers_Data/APIs/\" .. file)!@#&end!@#&!@#&local default = {!@#& lang = 1, nickname = \"<Nickname>\", theme = \"Lasers\",!@#&}!@#&!@#&if not fs.exists(\".Lasers_Data/Settings/settings.cfg\") then!@#& gui.saveTable(\".Lasers_Data/Settings/settings.cfg\",default)!@#&end!@#&!@#&if not fs.exists(\".Lasers_Data/Themes/Lasers\") then!@#& local theme = {!@#& bColor = \"white\",!@#& defaultTextCol = \"red\",!@#& activeBackCol = \"red\",!@#& activeTextCol = \"white\",!@#& headerBackCol = \"red\",!@#& headerTextCol = \"white\",!@#& }!@#& local f = fs.open(\".Lasers_Data/Themes/Lasers\", \"w\")!@#& for i, v in pairs( theme ) do!@#& f.writeLine( i .. \" = \" .. tostring(v) )!@#& end!@#& f.close()!@#&end!@#&!@#&local tSettings = gui.getTable(\".Lasers_Data/Settings/settings.cfg\")!@#&player.nickname = tSettings.nickname!@#&local theme = gui.loadTheme( \".Lasers_Data/Themes/\" .. tSettings.theme )!@#&!@#&!@#&!@#&--# Default data!@#&local language = \"English\"!@#&!@#&local languages = {!@#& \"English\",!@#&}!@#&!@#&local function rebootGame()!@#& shell.run(shell.getRunningProgram()) error()!@#&end!@#&!@#&!@#&local themes = {}!@#&local themes_downloadable = {}!@#&!@#&for _, file in ipairs( fs.list(\".Lasers_Data/Themes/\") ) do!@#& local nTheme = {}!@#& nTheme.name = file!@#& table.insert( themes, nTheme )!@#&end!@#&!@#&local function changeName()!@#& gui.drawBox( 2, w - 1, h/2 - 3, h/2 + 2, colors.red )!@#& gui.drawLine( 2, w - 1, h/2 - 3, nil, colors.gray )!@#& gui.drawLine( 3, w - 2, h/2, nil, colors.white)!@#& gui.centerPrint( h/2 - 3, colors.red, colors.gray, \"Change Name\")!@#& gui.centerPrint(h/2 - 1, colors.white, colors.red, \"New Name\")!@#& term.setCursorPos(1, h/2)!@#& local nName = \"\"!@#& repeat!@#& term.setTextColor( colors.black )!@#& term.setBackgroundColor(colors.white)!@#& nName = gui.mRead({centeredText = true, textLength = w - 7, exitOnKey = 29})!@#& until nName ~= \"\" or nName == nil!@#& if nName ~= nil then!@#& tSettings.nickname = nName!@#& gui.saveTable(\".Lasers_Data/Settings/settings.cfg\", tSettings)!@#& end!@#&end!@#&!@#&!@#&local function changeLang()!@#& tSettings.lang = tSettings.lang + 1!@#& if tSettings.lang > #languages then!@#& tSettings.lang = 1!@#& end!@#& gui.saveTable(\".Lasers_Data/Settings/settings.cfg\",tSettings)!@#& !@#& for i = 5, 0, - 1 do!@#& gui.drawBox(w/2 - 12,w/2 + 12,6,13,colors.gray)!@#& gui.centerPrint(7,colors.white,colors.gray,\"The game will reboot\")!@#& gui.centerPrint(8,colors.white,colors.gray,\"-for the changes to\")!@#& gui.centerPrint(9,colors.white,colors.gray,\"-become active!\")!@#& gui.centerPrint(11,colors.white,colors.gray,\"Rebooting in \"..i)!@#& sleep(1)!@#& end!@#& rebootGame()!@#&end!@#&!@#&!@#&!@#&local function changeTheme()!@#& local themes = gui.table_pages( themes, 5, h - 1 )!@#& local page, mNum = 1, 1!@#& local loop = true!@#& while loop do!@#& gui.clear( theme.bColor )!@#& gui.drawBox(1,w,1,3,theme.headerBackCol)!@#& gui.centerPrint(2,theme.headerTextCol,nil,\"Themes\")!@#& gui.drawAt(2, h - 1, \" < Back \")!@#& for i = 1,#themes[page] do!@#& themes[page][i].sX = math.ceil(w/2 - #themes[page][i].name/2) - 1!@#& themes[page][i].fX = math.ceil(w/2 + #themes[page][i].name/2)!@#& if mNum == i then!@#& gui.centerPrint(4 + i, theme.activeTextCol, theme.activeBackCol, \" \" .. themes[page][i].name .. \" \" )!@#& else!@#& gui.centerPrint(4 + i, theme.defaultTextCol, theme.bColor, themes[page][i].name )!@#& end!@#& end!@#& local e, p, mX, mY = os.pullEvent()!@#& if e == \"key\" then!@#& if p == keys.up then!@#& mNum = mNum - 1!@#& if mNum < 1 then!@#& page = page - 1!@#& if page < 1 then!@#& page = 1!@#& mNum = 1!@#& else!@#& mNum = #themes[page]!@#& end!@#& end!@#& !@#& elseif p == keys.down then!@#& mNum = mNum + 1!@#& if mNum > #themes[page] then!@#& page = page + 1!@#& if page > #themes then!@#& page = #themes!@#& mNum = #themes[page]!@#& else!@#& mNum = 1!@#& end!@#& end!@#& !@#& elseif p == 28 then!@#& if fs.exists(\".Lasers_Data/Themes/\" .. themes[page][mNum].name) then!@#& tSettings.theme = themes[page][mNum].name!@#& gui.saveTable(\".Lasers_Data/Settings/settings.cfg\", tSettings)!@#& loop = false!@#& end!@#& end!@#& !@#& elseif e == \"mouse_click\" or e == \"monitor_touch\" then!@#& for i = 1, #themes[page] do!@#& if mX >= themes[page][i].sX and mX <= themes[page][i].fX and mY == 4 + i then!@#& if mNum == i then!@#& if fs.exists(\".Lasers_Data/Themes/\" .. themes[page][mNum].name) then!@#& tSettings.theme = themes[page][mNum].name!@#& gui.saveTable(\".Lasers_Data/Settings/settings.cfg\", tSettings)!@#& loop = false!@#& end!@#& else!@#& mNum = i!@#& end!@#& break!@#& end!@#& end!@#& !@#& if mX >= 2 and mX <= 9 and mY == h - 1 then!@#& term.setTextColor(theme.defaultTextCol)!@#& term.setBackgroundColor(theme.bColor)!@#& gui.drawAt(2, h - 1, \" < Back \")!@#& sleep(.15)!@#& loop = false!@#& end!@#& end!@#& end!@#&end!@#&!@#& !@#&!@#&!@#&!@#&local highscores = {}!@#&if fs.exists(\".Lasers_Data/highscore.data\") then!@#& highscores = gui.getTable(\".Lasers_Data/highscore.data\")!@#&end!@#& !@#&local function view_highscores()!@#&!@#&local hs = gui.table_pages(highscores,4,h - 3)!@#&local page = 1!@#&!@#&!@#&local tColors = {!@#& [1] = {!@#& bColor = colors.gray,!@#& tColor = colors.white,!@#& bColor2 = colors.white,!@#& tColor2 = colors.black,!@#& },!@#& !@#& [2] = {!@#& bColor = colors.lightGray,!@#& tColor = colors.white,!@#& bColor2 = colors.red,!@#& tColor2 = colors.white,!@#& },!@#&}!@#&!@#& if #highscores ~= 0 then!@#& local viewing = true!@#& while viewing do!@#& gui.drawBox(1,w,1,2,theme.headerBackCol)!@#& gui.drawBox(1,w/2,3,h,colors.gray)!@#& gui.drawBox(math.ceil(w/2),w,3,h,colors.white)!@#& gui.centerPrint(1,theme.headerTextCol,theme.headerBackCol,\"Highscores\")!@#& gui.drawLine(1,w,h,nil,theme.headerBackCol)!@#& gui.centerPrint(h,theme.headerTextCol,theme.headerBackCol,\" [Space]Exit [Down]Next Page [Up]Previous Page \")!@#& local cNum = 1!@#& for i = 1,#hs[page] do!@#& term.setTextColor(tColors[cNum].tColor)!@#& term.setBackgroundColor(tColors[cNum].bColor)!@#& gui.drawAt(2,3 + i,hs[page][i].pos .. \": \" .. hs[page][i].name .. \" \")!@#& term.setTextColor(tColors[cNum].tColor2)!@#& term.setBackgroundColor(tColors[cNum].bColor2)!@#& gui.drawAt(w/2 + 4,3 + i,\" \" .. hs[page][i].score .. \" \")!@#& cNum = cNum + 1!@#& if cNum > 2 then!@#& cNum = 1!@#& end!@#& end!@#& local evt, p1 = os.pullEvent(\"key\")!@#& if p1 == keys.up then!@#& page = page - 1!@#& if page < 1 then!@#& page = 1!@#& end!@#& !@#& elseif p1 == keys.down then!@#& page = page + 1!@#& if page > #hs then!@#& page = #hs!@#& end!@#& !@#& elseif p1 == 57 then!@#& viewing = false!@#& end!@#& end!@#& else!@#& gui.clear(colors.white)!@#& gui.drawBox(w/2 - 15, w/2 + 15,h/2 - 2,h/2 + 3,theme.headerBackCol)!@#& gui.drawBox(w/2 - 14, w/2 + 14,h/2 - 1,h/2 + 2,theme.bColor)!@#& gui.centerPrint(h/2 - 2,theme.headerTextCol,theme.headerBackCol,\"Alert!\")!@#& gui.centerPrint(h/2,theme.defaultTextCol,theme.bColor,\"Currently no highscores\")!@#& gui.centerPrint(h/2+ 1,theme.defaultTextCol,theme.bColor,\"Press any key to continue\")!@#& os.pullEvent(\"key\")!@#& end!@#&end!@#&!@#&!@#&!@#&!@#&!@#&!@#&!@#&!@#&!@#&local function main(botMode, multiplayer, host)!@#&!@#&!@#&local tScreen = {}!@#&!@#&!@#&!@#&local mNum = 1!@#&local cTime = 10!@#&local score = 0!@#&local mvSpeed = 0.5!@#&local powerupBar = 0!@#&!@#&local initializeLaser = false!@#&local laserBeam = false!@#&local won = false!@#&local tp = false!@#&local inMenu = false!@#&!@#& !@#&local vNum!@#&local hNum!@#&local oldX!@#&local oldY!@#&local newX!@#&local newY!@#&local cID!@#&!@#&!@#&local function check_highscores()!@#& if #highscores ~= 0 then!@#& local pos = #highscores!@#& local sPos!@#& local temp = {}!@#& for i = #highscores, 1, -1 do!@#& sPos = i!@#& if score > highscores[i].score then!@#& pos = i!@#& else!@#& pos = i + 1!@#& break!@#& end!@#& end!@#&!@#& for i = sPos, #highscores do!@#& local n = {}!@#& n.name = highscores[i].name!@#& n.score = highscores[i].score!@#& n.pos = highscores[i].pos + 1!@#& table.insert(temp, n)!@#& end!@#& for i = 1,#temp do!@#& highscores[temp[i].pos] = temp[i]!@#& end!@#& !@#& !@#& highscores[pos].name = tSettings.nickname!@#& highscores[pos].score = score!@#& gui.saveTable(\".Lasers_Data/highscore.data\",highscores)!@#& !@#& else!@#& local n = {}!@#& n.name = tSettings.nickname!@#& n.score = score!@#& n.pos = 1!@#& table.insert(highscores, n)!@#& gui.saveTable(\".Lasers_Data/highscore.data\",highscores)!@#& end!@#&end!@#& !@#&!@#&--# Multiplayer connection!@#&if multiplayer then!@#&!@#&modemAttached = rNet.openSides()!@#&!@#&!@#&!@#&if modemAttached then !@#& gui.clear(colors.white)!@#& local bar = gui.initBar(w/2 - 14, w/2 + 14,h/2,0,3)!@#& local barTexture = {barColor = colors.red, barBackgroundColor = colors.gray}!@#& !@#& !@#& !@#&local function drawScreen(text,id,h)!@#& gui.clear(colors.white)!@#& gui.drawBar(bar, barTexture)!@#& gui.centerPrint(bar.y - 1,colors.black,colors.white,bar.currentProgress .. \"/\" .. bar.maxLen)!@#& gui.centerPrint(bar.y + 1,colors.black,colors.white,text)!@#& if id ~= nil then!@#& if h then!@#& gui.centerPrint(2,colors.black,colors.white,\"Your ID: \".. os.getComputerID() .. \" Client ID: \"..id)!@#& else!@#& gui.centerPrint(2,colors.black,colors.white,\"Your ID: \".. os.getComputerID() .. \" Host ID: \"..id)!@#& end!@#& end!@#&end !@#&!@#&!@#& !@#& if host then!@#& --# Host!@#& player.x = math.ceil(w/2) - 1!@#& player.y = math.ceil(h/2)!@#& gui.updateBar(bar, bar.currentProgress + 1, barTexture)!@#& local rID, msg!@#& for i = 1, 5 do!@#& drawScreen(\"Searching for clients\",nil)!@#& rednet.broadcast(\"lasers_multiplayer_host\")!@#& repeat!@#& rID, msg = rednet.receive(1.5)!@#& until rID ~= os.getComputerID()!@#& if rID ~= nil then!@#& if msg == \"lasers_multiplayer_client\" then!@#& break!@#& end!@#& end!@#& end!@#& !@#& if rID == nil then!@#& gui.updateBar(bar, 0, barTexture)!@#& gui.clear(colors.white)!@#& gui.drawBar(bar, barTexture)!@#& gui.centerPrint(bar.y - 1,colors.black,colors.white,\"No clients found\")!@#& gui.centerPrint(bar.y + 1,colors.black,colors.white,\"Request timed out\")!@#& os.pullEvent(\"key\")!@#& shell.run(shell.getRunningProgram()) error()!@#& !@#& else!@#& !@#& player2.id = rID!@#& gui.clear(colors.white)!@#& gui.updateBar(bar, bar.currentProgress + 1, barTexture)!@#& drawScreen(\"Sending data\", player2.id, true)!@#& !@#& local rID!@#& repeat!@#& rNet.sendTable(player2.id, player)!@#& rID, msg = rednet.receive(.5)!@#& until rID == player2.id!@#& !@#& local rID!@#& gui.updateBar(bar, bar.currentProgress + 1, barTexture)!@#& drawScreen(\"Receiveing data\", player2.id, true)!@#& repeat!@#& rID, msg = rednet.receive()!@#& until rID == player2.id!@#& player2 = textutils.unserialize(msg)!@#& player2.id = rID!@#& end!@#& !@#& !@#& !@#& else!@#& !@#& !@#& !@#& --# Client!@#& player.x = math.ceil(w/2) + 1!@#& player.y = math.ceil(h/2)!@#& gui.updateBar(bar, bar.currentProgress + 1, barTexture)!@#& drawScreen(\"Searching for hosts\", nil)!@#& local rID, msg!@#& for i = 1,5 do!@#& rID, msg = rednet.receive(1.5)!@#& if msg == \"lasers_multiplayer_host\" then!@#& break!@#& end!@#& end!@#& !@#& gui.clear(colors.white)!@#& if rID ~= nil and msg == \"lasers_multiplayer_host\" then!@#& rednet.send(rID,\"lasers_multiplayer_client\")!@#& player2.id = rID!@#& gui.updateBar(bar, bar.currentProgress + 1, barTexture)!@#& drawScreen(\"Receiveing data\", player2.id, false)!@#& !@#& repeat!@#& rID, msg = rednet.receive() !@#& until rID == player2.id!@#& rednet.send(player2.id,\"lasers_multiplayer_data_received\")!@#& !@#& player2 = textutils.unserialize(msg)!@#& player2.id = rID!@#& gui.clear(colors.white)!@#& !@#& gui.updateBar(bar, bar.currentProgress + 1, barTexture)!@#& drawScreen(\"Sending data\", player2.id, false)!@#& rNet.sendTable(player2.id, player)!@#& else!@#& gui.updateBar(bar, 0, barTexture)!@#& gui.clear(colors.white)!@#& gui.drawBar(bar, barTexture)!@#& gui.centerPrint(bar.y - 1,colors.black,colors.white,\"No hosts found\")!@#& gui.centerPrint(bar.y + 1,colors.black,colors.white,\"Request timed out\")!@#& os.pullEvent(\"key\")!@#& shell.run(shell.getRunningProgram()) error()!@#& end!@#& !@#& end!@#&else!@#& gui.clear( colors.white )!@#& gui.centerPrint(h/2, colors.red, colors.white,\"No modems attached!\")!@#& os.pullEvent()!@#& rebootGame()!@#&end!@#& else!@#& player.x = math.ceil(w/2)!@#& player.y = math.ceil(h/2)!@#&!@#&end!@#&!@#& !@#& !@#& !@#& !@#& !@#& !@#&!@#&!@#&!@#&!@#&local lasers = {!@#& -- X axis!@#& [1] = {!@#& axis = \"vertical\",!@#& direction = \"left\",!@#& x = math.ceil(w/2),!@#& y = 1,!@#& minX = 2,!@#& maxX = w - 1,!@#& },!@#& !@#& [2] = {!@#& axis = \"vertical\",!@#& direction = \"left\",!@#& x = math.ceil(w/2),!@#& y = h - 1,!@#& minX = 2,!@#& maxX = w - 1,!@#& },!@#& !@#& -- Y axis !@#& [3] = {!@#& axis = \"horizontal\",!@#& direction = \"down\",!@#& x = 1,!@#& y = math.ceil(h/2),!@#& minY = 2,!@#& maxY = h - 2,!@#& },!@#& !@#& [4] = {!@#& axis = \"horizontal\",!@#& direction = \"down\",!@#& x = w,!@#& y = math.ceil(h/2),!@#& minY = 2,!@#& maxY = h - 2,!@#& },!@#&}!@#&!@#&!@#&!@#&!@#& !@#& !@#&!@#& local mOpts = {!@#& !@#& [1] = {!@#& name = \" Resume \",!@#& functionName = \"_resume\",!@#& },!@#& !@#& [2] = {!@#& name = \" Exit \",!@#& functionName = rebootGame,!@#& },!@#&}!@#&!@#&local powerups = {!@#& [1] = {!@#& -- Art!@#& bColor = colors.red,!@#& tColor = colors.white,!@#& !@#& -- Data!@#& bTimer = 3,!@#& booleanName = \"slowdownLaser\",!@#& },!@#& !@#& [2] = {!@#& -- Art!@#& bColor = colors.purple,!@#& tColor = colors.white,!@#& !@#& -- Data!@#& bTimer = 5,!@#& booleanName = \"teleport\",!@#& },!@#& !@#& [3] = {!@#& -- Art!@#& bColor = colors.lightBlue,!@#& tColor = colors.white,!@#& !@#& -- Data!@#& bTimer = 5,!@#& booleanName = \"freezeLaser\",!@#& },!@#&}!@#&!@#&local tPowerup = {!@#& [\"booleans\"] = {!@#& freezeLaser = false,!@#& teleport = false,!@#& slowdownLaser = false!@#& },!@#&}!@#&!@#&local function createPowerup(index)!@#& if #tPowerup < 2 then!@#& nPowerup = {}!@#& !@#& !@#& nPowerup.bColor = powerups[index].bColor!@#& nPowerup.tColor = powerups[index].tColor!@#& nPowerup.bTimer = powerups[index].bTimer!@#& nPowerup.booleanName = powerups[index].booleanName!@#& nPowerup.art = \"P\"!@#& nPowerup.x = math.random(3,w - 2)!@#& nPowerup.y = math.random(3,h - 3)!@#& table.insert(tPowerup,nPowerup)!@#& end!@#&end!@#&!@#&local function powerupBoolean(booleanName)!@#& if booleanName == \"freezeLaser\" then!@#& tPowerup[\"booleans\"].freezeLaser = true!@#& !@#& elseif booleanName == \"slowdownLaser\" then!@#& tPowerup[\"booleans\"].slowdownLaser = true!@#& !@#& elseif booleanName == \"teleport\" then!@#& tPowerup[\"booleans\"].teleport = true!@#& end!@#&end!@#&!@#&!@#&!@#& !@#&!@#&!@#&!@#&--# Bot/A.I Stuff!@#&!@#&local bots = {}!@#&!@#&local defBot = {!@#& [\"tColors\"] = {!@#& colors.red, colors.purple, colors.green, colors.blue,!@#& },!@#&!@#& [\"side\"] = {!@#& [\"left\"] = {!@#& art = \"<\",!@#& },!@#& !@#& [\"right\"] = {!@#& art = \">\",!@#& },!@#& !@#& [\"down\"] = {!@#& art = \"v\",!@#& },!@#& !@#& [\"up\"] = {!@#& art = \"^\",!@#& },!@#& },!@#&}!@#&!@#&local function spawnBot(addX)!@#&!@#& local nBot = {}!@#& !@#& nBot.direction = \"down\"!@#& nBot.x = math.ceil(w/2) + addX!@#& nBot.y = math.ceil(h/2)!@#& nBot.tColor = defBot[\"tColors\"][math.random(1,#defBot[\"tColors\"])]!@#& nBot.side = defBot.side!@#& !@#& table.insert(bots,nBot)!@#&end!@#&!@#&if botMode then!@#& spawnBot(1)!@#& player.x = math.ceil(w/2) - 1!@#&end!@#&!@#&local function hBots()!@#&!@#&!@#&-- Getting the axises!@#& for i = 1,#lasers do!@#& if lasers[i].axis == \"vertical\" then!@#& vNum = i!@#& break!@#& end!@#& end!@#& for i = 1,#lasers do!@#& if lasers[i].axis == \"horizontal\" then!@#& hNum = i!@#& break!@#& end!@#& end!@#&!@#&!@#& for i = 1,#bots do!@#& if not laserBeam then!@#& -- Y Axis!@#& if lasers[hNum].direction == \"down\" then!@#& !@#& if lasers[hNum].y <= h/2 then!@#& if not initializeLaser then!@#& bots[i].direction = \"up\"!@#& bots[i].y = bots[i].y - 1 if bots[i].y < 2 then bots[i].y = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y + 1!@#& end!@#& else!@#& bots[i].direction = \"down\"!@#& bots[i].y = bots[i].y + 1 if bots[i].y > h - 2 then bots[i].y = h - 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y - 1!@#& end!@#& end!@#& !@#& else!@#& !@#& if not initializeLaser then!@#& bots[i].direction = \"down\"!@#& bots[i].y = bots[i].y + 1 if bots[i].y > h - 2 then bots[i].y = h - 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y - 1!@#& end!@#& else!@#& bots[i].direction = \"up\"!@#& bots[i].y = bots[i].y - 1 if bots[i].y < 2 then bots[i].y = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y + 1!@#& end!@#& end!@#& !@#& end!@#& !@#& elseif lasers[hNum].direction == \"up\" then!@#& !@#& if not initializeLaser then!@#& if lasers[hNum].y >= h/2 then!@#& bots[i].direction = \"down\"!@#& bots[i].y = bots[i].y + 1 if bots[i].y > h - 2 then bots[i].y = h - 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y - 1!@#& end!@#& else!@#& bots[i].direction = \"up\"!@#& bots[i].y = bots[i].y - 1 if bots[i].y < 2 then bots[i].y = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y + 1!@#& end !@#& end!@#& !@#& else!@#& !@#& if not initializeLaser then!@#& bots[i].direction = \"up\"!@#& bots[i].y = bots[i].y - 1 if bots[i].y < 2 then bots[i].y = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y + 1!@#& end!@#& else!@#& bots[i].direction = \"down\"!@#& bots[i].y = bots[i].y + 1 if bots[i].y > h - 2 then bots[i].y = h - 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y - 1!@#& end!@#& end!@#& !@#& end!@#& end!@#& !@#& -- X axis!@#& if lasers[vNum].direction == \"right\" then!@#& if not initializeLaser then!@#& if lasers[vNum].x >= w/2 then!@#& bots[i].direction = \"left\"!@#& bots[i].x = bots[i].x - 1 if bots[i].x < 2 then bots[i].x = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x + 1!@#& end!@#& else!@#& bots[i].direction = \"right\"!@#& bots[i].x = bots[i].x + 1 if bots[i].x > w - 1 then bots[i].x = w - 1 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x - 1!@#& end !@#& end!@#& !@#& else!@#& !@#& if not initializeLaser then!@#& bots[i].direction = \"right\"!@#& bots[i].x = bots[i].x + 1 if bots[i].x > w - 1 then bots[i].x = w - 1 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x - 1!@#& end !@#& else!@#& bots[i].direction = \"left\"!@#& bots[i].x = bots[i].x - 1 if bots[i].x < 2 then bots[i].x = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x + 1!@#& end!@#& end!@#& !@#& end!@#& !@#& !@#& elseif lasers[vNum].direction == \"left\" then!@#& !@#& if not initializeLaser then!@#& if lasers[vNum].x <= w/2 then!@#& bots[i].direction = \"right\"!@#& bots[i].x = bots[i].x + 1 if bots[i].x > w - 1 then bots[i].x = w - 1 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x - 1!@#& end!@#& else!@#& bots[i].direction = \"left\"!@#& bots[i].x = bots[i].x - 1 if bots[i].x < 2 then bots[i].x = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x + 1!@#& end !@#& end!@#& !@#& else!@#& !@#& if not initializeLaser then!@#& bots[i].direction = \"left\"!@#& bots[i].x = bots[i].x - 1 if bots[i].x < 2 then bots[i].x = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x + 1!@#& end !@#& else!@#& bots[i].direction = \"right\"!@#& bots[i].x = bots[i].x + 1 if bots[i].x > w - 1 then bots[i].x = w - 1 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x - 1!@#& end!@#& end!@#& !@#& end!@#& end!@#& !@#& !@#& else!@#& !@#& --# X axis!@#& if lasers[vNum].x > bots[i].x then !@#& bots[i].direction = \"left\"!@#& bots[i].x = bots[i].x - 1 if bots[i].x < 2 then bots[i].x = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x + 1!@#& end!@#& !@#& elseif lasers[vNum].x < bots[i].x then!@#& bots[i].direction = \"right\"!@#& bots[i].x = bots[i].x + 1 if bots[i].x > w - 1 then bots[i].x = w - 1 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].x = bots[i].x - 1!@#& end!@#& end!@#& !@#& --# Y axis!@#& if lasers[hNum].y > bots[i].y then !@#& bots[i].direction = \"up\"!@#& bots[i].y = bots[i].y - 1 if bots[i].y < 2 then bots[i].y = 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y + 1!@#& end!@#& !@#& elseif lasers[hNum].y < bots[i].y then!@#& bots[i].direction = \"down\"!@#& bots[i].y = bots[i].y + 1 if bots[i].y > h - 2 then bots[i].y = h - 2 end!@#& if bots[i].x == player.x and bots[i].y == player.y then!@#& bots[i].y = bots[i].y - 1!@#& end!@#& end!@#& !@#& end!@#& end!@#&end!@#&!@#&!@#&local function checkCollision()!@#& if not multiplayer then!@#& for i = 1,#bots do!@#& if player.x == bots[i].x and player.y == bots[i].y then!@#& return true!@#& end!@#& end!@#& else!@#& if player.x == player2.x and player.y == player2.y then!@#& return true!@#& end!@#& end!@#&end!@#&!@#&!@#&!@#&!@#&!@#& local function events()!@#& for i = 1,#tPowerup do!@#& if player.x == tPowerup[i].x and player.y == tPowerup[i].y then!@#& powerupBoolean(tPowerup[i].booleanName)!@#& powerupBarTimer = os.startTimer(1)!@#& powerupBar = 5!@#& table.remove(tPowerup,i)!@#& break!@#& end!@#& end!@#& !@#& evt, p1, mX, mY = os.pullEvent()!@#& if evt == \"key\" then!@#& if p1 == keys.up then!@#& if not inMenu then!@#& player.side = \"up\"!@#& player.y = player.y - 1!@#& if player.y < 2 then player.y = 2 end!@#& local collision = checkCollision()!@#& if collision then!@#& player.y = player.y + 1!@#& end!@#& if multiplayer then!@#& rNet.sendTable(player2.id, player)!@#& end !@#& else!@#& if mNum > 1 then!@#& mNum = mNum - 1!@#& end !@#& end!@#& !@#& elseif p1 == keys.down then!@#& if not inMenu then!@#& player.side = \"down\"!@#& player.y = player.y + 1!@#& if player.y > h - 2 then player.y = h - 2 end!@#& local collision = checkCollision()!@#& if collision then!@#& player.y = player.y - 1!@#& end!@#& if multiplayer then!@#& rNet.sendTable(player2.id, player)!@#& end !@#& else!@#& if mNum < #mOpts then!@#& mNum = mNum + 1!@#& end!@#& end!@#& !@#& !@#& !@#& !@#& elseif p1 == keys.left then!@#& if not inMenu then!@#& player.side = \"left\"!@#& player.x = player.x - 1!@#& if player.x < 2 then player.x = 2 end!@#& local collision = checkCollision()!@#& if collision then!@#& player.x = player.x + 1!@#& end!@#& if multiplayer then!@#& rNet.sendTable(player2.id, player)!@#& end !@#& end!@#& !@#& elseif p1 == keys.right then!@#& if not inMenu then!@#& player.side = \"right\"!@#& player.x = player.x + 1!@#& if player.x > w - 1 then player.x = w - 1 end!@#& local collision = checkCollision()!@#& if collision then!@#& player.x = player.x - 1!@#& end!@#& if multiplayer then!@#& rNet.sendTable(player2.id, player)!@#& end !@#& end!@#&!@#& elseif p1 == 29 then!@#& if inMenu then!@#& inMenu = false!@#& countdown = os.startTimer(1)!@#& else!@#& inMenu = true!@#& end!@#& !@#& elseif p1 == 28 then!@#& if inMenu then!@#& if mOpts[mNum].functionName ~= \"_resume\" then!@#& local callFunction = mOpts[mNum].functionName!@#& callFunction()!@#& end!@#& inMenu = false!@#& end !@#& end!@#& !@#& elseif evt == \"rednet_message\" then!@#& if multiplayer then!@#& if p1 == player2.id then!@#& player2 = textutils.unserialize(mX)!@#& player2.id = p1!@#& end!@#& end!@#& !@#& !@#& !@#& elseif evt == \"timer\" then!@#& !@#& if p1 == countdown then!@#& if not inMenu then!@#& cTime = cTime - 1!@#& if cTime < 0 then cTime = 0 end!@#& if cTime > 0 then!@#& countdown = os.startTimer(1)!@#& else!@#& spawnPowerup = os.startTimer(math.random(15,20))!@#& moveTimer = os.startTimer(.5)!@#& laserTimer = os.startTimer(math.random(3,5))!@#& scoreTimer = os.startTimer(1)!@#& if botMode then!@#& botMove = os.startTimer(.35)!@#& end!@#& end!@#& end!@#& !@#& elseif p1 == moveTimer then!@#& for i = 1,#lasers do!@#& !@#& if lasers[i].axis == \"vertical\" then!@#& if lasers[i].direction == \"left\" then!@#& lasers[i].x = lasers[i].x - 1!@#& if lasers[i].x < lasers[i].minX then!@#& lasers[i].x = lasers[i].minX; lasers[i].direction = \"right\"!@#& end!@#& !@#& elseif lasers[i].direction == \"right\" then!@#& lasers[i].x = lasers[i].x + 1!@#& if lasers[i].x > lasers[i].maxX then!@#& lasers[i].x = lasers[i].maxX; lasers[i].direction = \"left\"!@#& end!@#& end!@#& !@#& elseif lasers[i].axis == \"horizontal\" then!@#& if lasers[i].direction == \"up\" then!@#& lasers[i].y = lasers[i].y - 1!@#& if lasers[i].y < lasers[i].minY then!@#& lasers[i].y = lasers[i].minY; lasers[i].direction = \"down\"!@#& end!@#& !@#& elseif lasers[i].direction == \"down\" then!@#& lasers[i].y = lasers[i].y + 1!@#& if lasers[i].y > lasers[i].maxY then!@#& lasers[i].y = lasers[i].maxY; lasers[i].direction = \"up\"!@#& end!@#& end!@#& !@#& end !@#& !@#& end -- For loop!@#& !@#& local levels = {!@#& [1] = {!@#& score = 250,!@#& mvSpeed = 0.45,!@#& },!@#& !@#& [2] = {!@#& score = 500,!@#& mvSpeed = 0.4,!@#& },!@#& !@#& [3] = {!@#& score = 750,!@#& mvSpeed = 0.35,!@#& },!@#& !@#& [4] = {!@#& score = 1000,!@#& mvSpeed = 0.3,!@#& },!@#& !@#& [5] = {!@#& score = 1250,!@#& mvSpeed = 0.25,!@#& },!@#& !@#& [6] = {!@#& score = 1500,!@#& mvSpeed = 0.2,!@#& },!@#& !@#& [7] = {!@#& score = 2000,!@#& mvSpeed = 0.1,!@#& },!@#& }!@#& !@#& if not tPowerup[\"booleans\"].slowdownLaser then!@#& for i = 1,#levels do!@#& if score >= levels[i].score then!@#& mvSpeed = levels[i].mvSpeed!@#& end!@#& end!@#& !@#& else!@#& mvSpeed = 0.8!@#& end!@#& !@#& if not tPowerup[\"booleans\"].freezeLaser then !@#& moveTimer = os.startTimer(mvSpeed)!@#& end!@#& !@#& elseif p1 == laserTimer then!@#& initializeLaser = true!@#& beamTimer = os.startTimer(3)!@#&!@#& elseif p1 == beamTimer then!@#& initializeLaser = false!@#& laserBeam = true!@#& fTimer = os.startTimer(2)!@#& !@#& elseif p1 == fTimer then!@#& laserBeam = false!@#& laserTimer = os.startTimer(math.random(3,5)) !@#& !@#& elseif p1 == scoreTimer then!@#& score = score + 10!@#& scoreTimer = os.startTimer(1) !@#&!@#& elseif p1 == spawnPowerup then!@#& if not multiplayer then!@#& createPowerup(math.random(1,#powerups))!@#& spawnPowerup = os.startTimer(math.random(15,20))!@#& end!@#& !@#& elseif p1 == rmTimer then!@#& tp = false;!@#& !@#& elseif p1 == botMove then!@#& hBots()!@#& botMove = os.startTimer(.15)!@#&!@#& elseif p1 == powerupBarTimer then!@#& powerupBar = powerupBar - 1!@#& if powerupBar > 0 then!@#& powerupBarTimer = os.startTimer(1)!@#& else!@#& powerupBar = 0!@#& tPowerup[\"booleans\"].freezeLaser = false!@#& tPowerup[\"booleans\"].slowdownLaser = false!@#& tPowerup[\"booleans\"].teleport = false!@#& moveTimer = os.startTimer(mvSpeed) !@#& end !@#& end!@#& !@#& elseif evt == \"mouse_click\" then !@#& if tPowerup[\"booleans\"].teleport then!@#& if mX > 2 and mX < w and mY > 2 and mY < w - 1 then!@#& oldX = player.x; oldY = player.y!@#& newX = mX; newY = mY!@#& player.x = mX; player.y = mY;!@#& tp = true!@#& rmTimer = os.startTimer(0.1)!@#& end!@#& end!@#& !@#& end!@#& end!@#& !@#& !@#& !@#& !@#& !@#&local function draw()!@#& term.setBackgroundColor(colors.white)!@#& gui.clear()!@#& !@#& gui.drawLine(1,w,1,colors.lightGray,colors.white,\"-\")!@#& gui.drawLine(1,w,h - 1,colors.lightGray,colors.white,\"-\")!@#& for i = 1, h - 1 do!@#& gui.drawAt(1,i,\"|\")!@#& gui.drawAt(w,i,\"|\")!@#& end!@#& !@#& gui.drawAt(1,1,\"+\")!@#& gui.drawAt(w,1,\"+\")!@#& gui.drawAt(1,h - 1,\"+\")!@#& gui.drawAt(w,h - 1,\"+\")!@#& !@#& for i = 1,#lasers do!@#& term.setBackgroundColor(colors.gray)!@#& gui.drawAt(lasers[i].x,lasers[i].y,\" \")!@#& end!@#& !@#& if initializeLaser then!@#&!@#& !@#& for i = 1,#lasers do!@#& if lasers[i].axis == \"vertical\" then!@#& vNum = i!@#& break!@#& end!@#& end!@#& for i = 1,#lasers do!@#& if lasers[i].axis == \"horizontal\" then!@#& hNum = i!@#& break!@#& end!@#& end!@#& !@#& gui.drawLine(2,w - 1,lasers[hNum].y,colors.red,colors.white,\"-\")!@#& for i = 2,h - 2 do!@#& gui.drawAt(lasers[vNum].x,i,\"|\")!@#& end!@#& !@#& end!@#& !@#& if botMode then!@#& term.setBackgroundColor(colors.white)!@#& for i = 1,#bots do!@#& term.setTextColor(bots[i].tColor)!@#& gui.drawAt(bots[i].x,bots[i].y,bots[i].side[bots[i].direction].art)!@#& end!@#& end!@#& !@#& --#Players!@#& term.setBackgroundColor(colors.white)!@#& term.setTextColor(colors.black)!@#& gui.drawAt(player.x,player.y,player.sides[player.side].art)!@#& term.setTextColor(colors.blue)!@#& if multiplayer then!@#& gui.drawAt(player2.x, player2.y,player2.sides[player2.side].art)!@#& end!@#& !@#& if tp then!@#& term.setTextColor(colors.purple)!@#& gui.drawAt(oldX,oldY,\"#\")!@#& gui.drawAt(newX,newY,\"#\")!@#& end!@#& !@#&!@#& for i = 1,#tPowerup do!@#& term.setTextColor(tPowerup[i].tColor)!@#& term.setBackgroundColor(tPowerup[i].bColor)!@#& gui.drawAt(tPowerup[i].x,tPowerup[i].y,tPowerup[i].art)!@#& end!@#& !@#& if laserBeam then!@#& local vNum!@#& local hNum!@#& !@#& for i = 1,#lasers do!@#& if lasers[i].axis == \"vertical\" then!@#& vNum = i!@#& break!@#& end!@#& end!@#& for i = 1,#lasers do!@#& if lasers[i].axis == \"horizontal\" then!@#& hNum = i!@#& break!@#& end!@#& end!@#& !@#&!@#& gui.drawLine(2,w - 1,lasers[hNum].y,nil,colors.red,\" \")!@#& for i = 2,h - 2 do!@#& gui.drawAt(lasers[vNum].x,i,\" \")!@#& end!@#& !@#& if player.y == lasers[hNum].y or player.x == lasers[vNum].x then!@#& player.dead = true!@#& if multiplayer then!@#& rNet.sendTable(player2.id, player)!@#& end!@#& end!@#&!@#&if botMode then !@#&!@#& for i = 1,#bots do!@#& if bots[i].y == lasers[hNum].y or bots[i].x == lasers[vNum].x then!@#& table.remove(bots,i)!@#& break!@#& end!@#& end!@#&!@#&end!@#&!@#&!@#& !@#& !@#& end!@#& !@#& gui.drawLine(1,w,h,colors.white,colors.lightGray)!@#& if cTime > 0 then!@#& gui.centerPrint(h,colors.white,nil,\"Lasers starting in \"..cTime..\" seconds\")!@#& !@#& else!@#& gui.drawAt(2,h,\"[SCORE] \"..score)!@#& if powerupBar > 0 then!@#& gui.drawLine(w - 5,w - 1,h,nil,colors.gray)!@#& gui.drawLine(w - 6,w - 6 + powerupBar,h,nil,colors.purple)!@#& end!@#& end!@#&!@#&if inMenu then!@#& gui.drawBox(w/2 - 11,w/2 + 11,h/2 - 3,h/2 + 5,colors.gray)!@#& gui.drawBox(w/2 - 10,w/2 + 10,h/2 - 2,h/2 + 4,colors.white)!@#& for i = 1,#mOpts do!@#& if mNum == i then!@#& gui.centerPrint((h/2 - 2) + i,colors.white,colors.red,mOpts[i].name)!@#& else!@#& gui.centerPrint((h/2 - 2) + i,colors.red,colors.white,mOpts[i].name)!@#& end!@#& end!@#&end !@#& !@#&end!@#&!@#&!@#&!@#&--# Main part!@#&countdown = os.startTimer(1)!@#&while not player.dead do!@#&!@#& if player.y > h - 2 then!@#& player.y = h - 2!@#& end!@#&!@#& if botMode then!@#& if #bots == 0 then!@#& won = true!@#& end!@#& !@#& if won then!@#& break!@#& end!@#& end!@#&!@#& if multiplayer then!@#& if player2.dead then!@#& won = true!@#& break!@#& end !@#& end !@#& draw()!@#& events()!@#&end!@#&!@#&if won then!@#& term.setBackgroundColor(colors.lime)!@#& term.clear()!@#& gui.centerPrint(h/2,colors.white,colors.lime,\"You won!\")!@#& gui.centerPrint(h/2 + 1,colors.white,colors.lime,\"Score: \"..score)!@#& check_highscores()!@#&else!@#&!@#& term.setBackgroundColor(colors.red)!@#& term.clear()!@#& gui.centerPrint(h/2,colors.white,colors.red,\"You died!\")!@#& gui.centerPrint(h/2 + 1,colors.white,colors.red,\"Score: \"..score)!@#& check_highscores()!@#&end!@#&!@#&sleep(1)!@#&os.pullEvent(\"key\")!@#&!@#&rebootGame()!@#& !@#&end!@#&!@#&!@#&!@#&!@#&!@#&!@#&!@#&!@#&local menu = {!@#&!@#& defLanguage = languages[tSettings.lang],!@#& defMenu = \"Main\",!@#& !@#& [\"English\"] = {!@#& !@#& [\"Main\"] = {!@#& title = \"Lasers\",!@#& !@#& [1] = {!@#& name = \"Single Player\",!@#& destination = \"SP\",!@#& },!@#& !@#& [2] = {!@#& name = \"Multiplayer\",!@#& destination = \"MP\",!@#& },!@#& !@#& [3] = {!@#& name = \"Highscore\",!@#& destination = \"_function\",!@#& [\"tFunction\"] = {!@#& name = view_highscores,!@#& },!@#& },!@#& !@#& !@#& [4] = {!@#& name = \"Settings\",!@#& destination = \"Settings\",!@#& },!@#& !@#& [5] = {!@#& name = \"Exit\",!@#& destination = \"_exit\",!@#& },!@#& },!@#& !@#& [\"SP\"] = {!@#& title = \"Single Player\",!@#& !@#& [1] = {!@#& name = \"Survival Mode\",!@#& destination = \"_function\",!@#& [\"tFunction\"] = {!@#& name = main,!@#& },!@#& },!@#& !@#& [2] = {!@#& name = \"Bot Mode\",!@#& destination = \"_function\",!@#& [\"tFunction\"] = {!@#& name = main,!@#& [\"args\"] = {!@#& true,!@#& },!@#& },!@#& },!@#& !@#& [3] = {!@#& name = \"Back\",!@#& destination = \"_back\",!@#& },!@#& },!@#& !@#& !@#& [\"MP\"] = {!@#& title = \"Multiplayer\",!@#& !@#& [1] = {!@#& name = \"Host\",!@#& destination = \"_function\",!@#& [\"tFunction\"] = {!@#& name = main,!@#& [\"args\"] = {!@#& false,!@#& true,!@#& true,!@#& },!@#& },!@#& },!@#& !@#& [2] = {!@#& name = \"Join\",!@#& destination = \"_function\",!@#& [\"tFunction\"] = {!@#& name = main,!@#& [\"args\"] = {!@#& false,!@#& true,!@#& false,!@#& },!@#& },!@#& },!@#& !@#& [3] = {!@#& name = \"Back\",!@#& destination = \"_back\",!@#& },!@#& },!@#& !@#&!@#& !@#& [\"Settings\"] = {!@#& title = \"Settings\",!@#& [1] = {!@#& name = languages[tSettings.lang],!@#& destination = \"_function\",!@#& [\"tFunction\"] = {!@#& name = changeLang,!@#& },!@#& },!@#& !@#& [2] = {!@#& name = \"Change Theme\",!@#& destination = \"_function\",!@#& [\"tFunction\"] = {!@#& name = changeTheme,!@#& },!@#& },!@#& !@#& [3] = {!@#& name = \"Change Name\",!@#& destination = \"_function\",!@#& [\"tFunction\"] = {!@#& name = changeName,!@#& },!@#& },!@#& !@#& [4] = {!@#& name = \"Back\",!@#& destination = \"_back\",!@#& }, !@#& }, !@#& }, !@#&}!@#& !@#&!@#&!@#&!@#&!@#&!@#&gui.handleMenu(menu,theme)",["laserbox"]="lives = 5!@#&px = 1!@#&py = 4!@#&p2x = 49!@#&p2y = 4!@#&p1p = 0!@#&p2p = 0!@#&p1b = 3!@#&p2b = 3!@#&p1ba = down!@#&p2ba = down!@#&bar = paintutils.loadImage(\"sprites/lbbar\")!@#&field = paintutils.loadImage(\"sprites/world/lbback\")!@#&!@#&function drawP1(xx2,yy2)!@#& term.setCursorPos(xx2,yy2)!@#& term.setBackgroundColor(colors.red)!@#& print \" \"!@#&end!@#&!@#&function drawP2(xx3,yy3)!@#& term.setCursorPos(xx3,yy3)!@#& term.setBackgroundColor(colors.blue)!@#& print \" \"!@#&end!@#&!@#&run = true!@#&!@#&!@#&!@#&!@#&function p1()!@#&while run do!@#&local event, button, X, Y = os.pullEvent(\"key\")!@#&if button == keys.w then!@#& if py ~= 2 then!@#& py = py - 1!@#& sleep(0.010)!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&term.setBackgroundColor(colors.lightBlue)!@#&paintutils.drawImage(field,2,2)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&!@#&if p2ba == \"up\" then!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&end!@#&drawP1(px,py)!@#&drawP2(p2x,p2y)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&end!@#&end!@#&!@#&if button == keys.s then!@#& if py ~= 17 then!@#& py = py + 1!@#& sleep(0.010)!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&term.setBackgroundColor(colors.lightBlue)!@#&paintutils.drawImage(field,2,2)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&!@#&if p2ba == \"up\" then!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&end!@#&drawP1(px,py)!@#&drawP2(p2x,p2y)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&end!@#&end!@#&!@#&!@#&if button == keys.leftShift then!@#&lx = px+1!@#&term.setCursorPos(lx,py)!@#&term.setBackgroundColor(colors.red)!@#&print \"================================================\"!@#&sleep(0.2)!@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&if p1p == lives - 1 then!@#&p1p = p1p + 1 !@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&term.setBackgroundColor(colors.orange)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&print \"PLayer 1 Wins!\"!@#&run = false!@#&return!@#&elseif py == p2y then!@#& if p2ba == \"up\" then!@#& p2ba = down!@#& term.setCursorPos(1,1)!@#&term.setBackgroundColor(colors.orange)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#& else!@#&p1p = p1p + 1!@#&term.setCursorPos(1,1)!@#&term.setBackgroundColor(colors.orange)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&end!@#&end!@#&!@#&sleep(0.2)!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&term.setBackgroundColor(colors.lightBlue)!@#&paintutils.drawImage(field,2,2)!@#&term.setBackgroundColor(colors.orange)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&!@#&if p2ba == \"up\" then!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&end!@#&drawP1(px,py)!@#&drawP2(p2x,p2y)!@#&end!@#&!@#&if button == keys.d then!@#&if p1b == 0 then!@#&!@#&else!@#&paintutils.drawImage(bar,px+1,py-1)!@#&p1b = p1b - 1!@#&p1ba = \"up\"!@#&end!@#&end!@#&end!@#&end!@#&!@#&!@#&!@#&function p2()!@#&while run do!@#&local event, button, X, Y = os.pullEvent(\"key\")!@#&!@#&!@#&if button == keys.down then!@#& if p2y ~= 17 then!@#& p2y = p2y + 1!@#&sleep(0.010)!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&term.setBackgroundColor(colors.lightBlue)!@#&paintutils.drawImage(field,2,2)!@#&term.setBackgroundColor(colors.orange)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&!@#&if p2ba == \"up\" then!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&end!@#&drawP1(px,py)!@#&drawP2(p2x,p2y)!@#&end!@#&end!@#&!@#&!@#&if button == keys.up then!@#& if p2y ~= 2 then!@#& p2y = p2y - 1!@#& sleep(0.010)!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&term.setBackgroundColor(colors.lightBlue)!@#&paintutils.drawImage(field,2,2)!@#&term.setBackgroundColor(colors.orange)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&!@#&if p2ba == \"up\" then!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&end!@#&drawP1(px,py)!@#&drawP2(p2x,p2y)!@#&end!@#&end!@#&!@#&!@#&if button == keys.rightShift then!@#&l2y = p2y - 1!@#&term.setCursorPos(p2x,l2y)!@#&term.setBackgroundColor(colors.blue)!@#&print \"================================================\"!@#&sleep(0.2)!@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&if p2p == lives - 1 then!@#&p2p = p2p + 1 !@#&term.setBackgroundColor(colors.orange)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&!@#&if p2ba == \"up\" then!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&end!@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&print \"PLayer 2 Wins!\"!@#&run = false!@#&return!@#&elseif p2y == py then!@#& if p1ba == \"up\" then!@#& p1ba = down!@#& term.setCursorPos(1,1)!@#&term.setBackgroundColor(colors.orange)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#& else!@#&p2p = p2p + 1 !@#&term.setCursorPos(1,1)!@#&term.setBackgroundColor(colors.orange)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&end!@#&end!@#&!@#&sleep(0.2)!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&term.setBackgroundColor(colors.lightBlue)!@#&paintutils.drawImage(field,2,2)!@#&term.setBackgroundColor(colors.orange)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&!@#&if p2ba == \"up\" then!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&end!@#&drawP1(px,py)!@#&drawP2(p2x,p2y)!@#&end!@#&!@#&if button == keys.l then!@#&if p2b == 0 then!@#&!@#&else!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&p2b = p2b - 1!@#&p2ba = \"up\"!@#&end!@#&end!@#&end!@#&end!@#&!@#&!@#&term.setBackgroundColor(colors.lightBlue)!@#&term.clear()!@#&term.setBackgroundColor(colors.orange)!@#&term.setCursorPos(1,1)!@#&print(\"P1: \"..p1p..\"/\"..lives)!@#&term.setCursorPos(45,1)!@#&print(\"P2: \"..p2p..\"/\"..lives)!@#&term.setBackgroundColor(colors.lightBlue)!@#&paintutils.drawImage(field,2,2)!@#&term.setBackgroundColor(colors.orange)!@#&if p1ba == \"up\" then!@#&paintutils.drawImage(bar,px+1,py-1)!@#&end!@#&!@#&if p2ba == \"up\" then!@#&paintutils.drawImage(bar,p2x-1,p2y-1)!@#&end!@#&drawP1(px,py)!@#&drawP2(p2x,p2y)!@#&!@#&!@#&!@#&function para()!@#&while run do!@#¶llel.waitForAny(p1,p2)!@#&end!@#&end!@#¶()",["worm"]="!@#&-- Display the start screen!@#&local w,h = term.getSize()!@#&!@#&local headingColour, textColour, wormColour, fruitColour!@#&if term.isColour() then!@#& headingColour = colours.yellow!@#& textColour = colours.white!@#& wormColour = colours.lime!@#& fruitColour = colours.red!@#&else!@#& headingColour = colours.white!@#& textColour = colours.white!@#& wormColour = colours.white!@#& fruitColour = colours.white!@#&end!@#&!@#&function printCentred( y, s )!@#& local x = math.floor((w - string.len(s)) / 2)!@#& term.setCursorPos(x,y)!@#& --term.clearLine()!@#& term.write( s )!@#&end!@#&!@#&local xVel,yVel = 1,0!@#&local xPos, yPos = math.floor(w/2), math.floor(h/2)!@#&local pxVel, pyVel = nil, nil!@#&!@#&local nLength = 1!@#&local nExtraLength = 6!@#&local bRunning = true!@#&!@#&local tailX,tailY = xPos,yPos!@#&local nScore = 0!@#&local nDifficulty = 2!@#&local nSpeed, nInterval!@#&!@#&-- Setup the screen!@#&local screen = {}!@#&for x=1,w do!@#& screen[x] = {}!@#& for y=1,h do!@#& screen[x][y] = {}!@#& end!@#&end!@#&screen[xPos][yPos] = { snake = true }!@#&!@#&local nFruit = 1!@#&local tFruits = {!@#& \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\",!@#& \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\",!@#& \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\",!@#& \"Y\", \"Z\",!@#& \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\",!@#& \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\",!@#& \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\",!@#& \"y\", \"z\",!@#& \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"0\",!@#& \"@\", \"$\", \"%\", \"#\", \"&\", \"!\", \"?\", \"+\", \"*\", \"~\"!@#&}!@#&!@#&local function addFruit()!@#& while true do!@#& local x = math.random(1,w)!@#& local y = math.random(2,h)!@#& local fruit = screen[x][y]!@#& if fruit.snake == nil and fruit.wall == nil and fruit.fruit == nil then!@#& screen[x][y] = { fruit = true }!@#& term.setCursorPos(x,y)!@#& term.setBackgroundColour( fruitColour )!@#& term.write(\" \")!@#& term.setBackgroundColour( colours.black )!@#& break!@#& end!@#& end!@#& !@#& nFruit = nFruit + 1!@#& if nFruit > #tFruits then!@#& nFruit = 1!@#& end!@#&end!@#&!@#&local function drawMenu()!@#& term.setTextColour( headingColour )!@#& term.setCursorPos(1,1)!@#& term.write( \"SCORE \" )!@#& !@#& term.setTextColour( textColour )!@#& term.setCursorPos(7,1)!@#& term.write( tostring(nScore) )!@#&!@#& term.setTextColour( headingColour )!@#& term.setCursorPos(w-11,1)!@#& term.write( \"DIFFICULTY \")!@#&!@#& term.setTextColour( textColour )!@#& term.setCursorPos(w,1)!@#& term.write( tostring(nDifficulty or \"?\") ) !@#&!@#& term.setTextColour( colours.white )!@#&end!@#&!@#&local function update( )!@#& local x,y = xPos,yPos!@#& if pxVel and pyVel then!@#& xVel, yVel = pxVel, pyVel!@#& pxVel, pyVel = nil, nil!@#& end!@#&!@#& -- Remove the tail!@#& if nExtraLength == 0 then!@#& local tail = screen[tailX][tailY]!@#& screen[tailX][tailY] = {}!@#& term.setCursorPos(tailX,tailY)!@#& term.write(\" \")!@#& tailX = tail.nextX!@#& tailY = tail.nextY!@#& else!@#& nExtraLength = nExtraLength - 1!@#& end!@#& !@#& -- Update the head!@#& local head = screen[xPos][yPos]!@#& local newXPos = xPos + xVel!@#& local newYPos = yPos + yVel!@#& if newXPos < 1 then!@#& newXPos = w!@#& elseif newXPos > w then!@#& newXPos = 1!@#& end!@#& if newYPos < 2 then!@#& newYPos = h!@#& elseif newYPos > h then!@#& newYPos = 2!@#& end!@#& !@#& local newHead = screen[newXPos][newYPos]!@#& term.setCursorPos(1,1);!@#& print( newHead.snake )!@#& if newHead.snake == true or newHead.wall == true then!@#& bRunning = false!@#& !@#& else!@#& if newHead.fruit == true then!@#& nScore = nScore + 10!@#& nExtraLength = nExtraLength + 1!@#& addFruit()!@#& end!@#& xPos = newXPos!@#& yPos = newYPos!@#& head.nextX = newXPos!@#& head.nextY = newYPos!@#& screen[newXPos][newYPos] = { snake = true }!@#& !@#& end!@#& !@#& term.setCursorPos(xPos,yPos)!@#& term.setBackgroundColour( wormColour )!@#& term.write(\" \")!@#& term.setBackgroundColour( colours.black )!@#&!@#& drawMenu()!@#&end!@#&!@#&-- Display the frontend!@#&term.clear()!@#&local function drawFrontend()!@#& term.setTextColour( headingColour )!@#& printCentred( math.floor(h/2) - 3, \"\" )!@#& printCentred( math.floor(h/2) - 2, \" SELECT DIFFICULTY \" )!@#& printCentred( math.floor(h/2) - 1, \"\" )!@#& !@#& printCentred( math.floor(h/2) + 0, \" \" )!@#& printCentred( math.floor(h/2) + 1, \" \" )!@#& printCentred( math.floor(h/2) + 2, \" \" )!@#& printCentred( math.floor(h/2) - 1 + nDifficulty, \" [ ] \" )!@#&!@#& term.setTextColour( textColour )!@#& printCentred( math.floor(h/2) + 0, \"EASY\" )!@#& printCentred( math.floor(h/2) + 1, \"MEDIUM\" )!@#& printCentred( math.floor(h/2) + 2, \"HARD\" )!@#& printCentred( math.floor(h/2) + 3, \"\" )!@#&!@#& term.setTextColour( colours.white )!@#&end!@#&!@#&drawMenu()!@#&drawFrontend()!@#&while true do!@#& local e,key = os.pullEvent( \"key\" )!@#& if key == keys.up or key == keys.w then!@#& -- Up!@#& if nDifficulty > 1 then!@#& nDifficulty = nDifficulty - 1!@#& drawMenu()!@#& drawFrontend()!@#& end!@#& elseif key == keys.down or key == keys.s then!@#& -- Down!@#& if nDifficulty < 3 then!@#& nDifficulty = nDifficulty + 1!@#& drawMenu()!@#& drawFrontend()!@#& end!@#& elseif key == keys.enter then!@#& -- Enter!@#& break!@#& end!@#&end!@#&!@#&local tSpeeds = { 5, 10, 25 }!@#&nSpeed = tSpeeds[nDifficulty]!@#&nInterval = 1 / nSpeed!@#&!@#&-- Grow the snake to its intended size!@#&term.clear()!@#&drawMenu()!@#&screen[tailX][tailY].snake = true!@#&while nExtraLength > 0 do!@#& update()!@#&end!@#&addFruit()!@#&addFruit()!@#&!@#&-- Play the game!@#&local timer = os.startTimer(0)!@#&while bRunning do!@#& local event, p1, p2 = os.pullEvent()!@#& if event == \"timer\" and p1 == timer then!@#& timer = os.startTimer(nInterval)!@#& update( false )!@#& !@#& elseif event == \"key\" then!@#& local key = p1!@#& if key == keys.up or key == keys.w then!@#& -- Up!@#& if yVel == 0 then!@#& pxVel,pyVel = 0,-1!@#& end!@#& elseif key == keys.down or key == keys.s then!@#& -- Down!@#& if yVel == 0 then!@#& pxVel,pyVel = 0,1!@#& end!@#& elseif key == keys.left or key == keys.a then!@#& -- Left!@#& if xVel == 0 then!@#& pxVel,pyVel = -1,0!@#& end!@#& !@#& elseif key == keys.right or key == keys.d then!@#& -- Right!@#& if xVel == 0 then!@#& pxVel,pyVel = 1,0!@#& end!@#& !@#& end !@#& end!@#&end!@#&!@#&-- Display the gameover screen!@#&term.setTextColour( headingColour )!@#&printCentred( math.floor(h/2) - 2, \" \" )!@#&printCentred( math.floor(h/2) - 1, \" G A M E O V E R \" )!@#&!@#&term.setTextColour( textColour )!@#&printCentred( math.floor(h/2) + 0, \" \" )!@#&printCentred( math.floor(h/2) + 1, \" FINAL SCORE \"..nScore..\" \" )!@#&printCentred( math.floor(h/2) + 2, \" \" )!@#&term.setTextColour( colours.white )!@#&!@#&local timer = os.startTimer(2.5)!@#&repeat!@#& local e,p = os.pullEvent()!@#& if e == \"timer\" and p == timer then!@#& term.setTextColour( textColour )!@#& printCentred( math.floor(h/2) + 2, \" PRESS ANY KEY \" )!@#& printCentred( math.floor(h/2) + 3, \" \" )!@#& term.setTextColour( colours.white )!@#& end!@#&until e == \"char\"!@#&!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&!@#& ",} local function makeFile(_path, _content) local file = fs.open(_path, "w") _content = _content:gsub("!@".."#&", "%\n") file.write(_content) file.close() end local function makeFolder(_path, _content) fs.makeDir(_path) for k,v in pairs(_content) do if type(v) == "table" then makeFolder(_path .. "/" .. k, v) else makeFile(_path .. "/" .. k, v) end end end local sDest = shell.resolve( "BlueGames" ) or "/" if sDest == "root" then sDest = "/" end local tPackage = pkg makeFolder(sDest, tPackage) print("Package Extracted to '" .. sDest .. "'!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement