Advertisement
Redxone

Legend Of Kone - Offical Installer

Nov 26th, 2015
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 72.10 KB | None | 0 0
  1. local pkg = {
  2.   launch = "local prog = shell.getRunningProgram()!@#&local name = fs.getName(prog)!@#&local root = prog:sub(1, -1 - #name)!@#&if( root == \"/\" )then!@#&  root = \"\"!@#&end!@#&os.loadAPI(root .. \"game/redgame\")!@#&redgame.init()!@#&local w, h = term.getSize()!@#&!@#&local cave_open = false!@#&local entered_cave = false!@#&local randomized = false!@#&local isGame = false!@#&local started = false!@#&  !@#&  lastvalues = {!@#&    sanity = 100,!@#&    hunger = 100,!@#&    thirst = 100,!@#&    health = 100,!@#&  }!@#&!@#&  sanity = {!@#&    stepstaken = 0,!@#&    steps = 20,!@#&    decrement = 10,!@#&    value = 100,!@#&  }!@#&!@#&  thirst = {!@#&    stepstaken = 0,!@#&    steps = 10,!@#&    decrement = 10,!@#&    value = 100,!@#&  }!@#&!@#&  hunger = {!@#&    stepstaken = 0,!@#&    steps = 15,!@#&    decrement = 5,!@#&    value = 100,!@#&  }!@#&!@#&  health = {!@#&    value = 100,!@#&    hunger_decrement = 0,!@#&    thirst_decrement = 10,!@#&    sanity_decrement = 20,!@#&    hunger_decrement_value = 2,!@#&    thirst_decrement_value = 5,!@#&    sanity_decrement_value = 3, !@#&  }!@#&  !@#&  stepcount = 0!@#&!@#&local isMenu = true!@#&!@#&function createRat(x,y,dmg,map,diff)!@#&    local rat = {!@#&        x = 0,!@#&        y = 0,!@#&        dmg = 0,!@#&        map = \"\",!@#&        hp  = 100,!@#&        dir = 0,!@#&        bID = 17,!@#&        mode=diff,!@#&        mdirs = {!@#&            [0] = 'down',!@#&            [1] = 'up',!@#&            [2] = 'right',!@#&            [3] = 'left',!@#&        };!@#&!@#&        dispose = function(self)!@#&          redgame.setPMAP(self.x,self.y,0)!@#&        end,!@#&!@#&        put = function(self)!@#&            self.x = x!@#&            self.y = y!@#&            self.dmg = dmg!@#&            self.map = map!@#&            redgame.setPMAP(self.x,self.y,self.bID)!@#&            redgame.drawMapPixel(self.y,self.x)!@#&        end,!@#&!@#&      checkCollide = function(self,cx,cy)!@#&          if(redgame.getPMAP()[self.y + cy][self.x + cx] == 0 and !@#&            ( (redgame.getGMAP()[self.y + cy][self.x + cx] == 0) or !@#&            (redgame.getGBLOCKS()[redgame.getGMAP()[self.y + cy][self.x + cx]].solid == false)))then!@#&            return true!@#&        else!@#&           return false!@#&        end!@#&      end,!@#&!@#&      redrawAt = function(self,cx,cy)!@#&          redgame.setPMAP(self.x,self.y,0)!@#&          redgame.drawMapPixel(self.y,self.x)!@#&          self.x = self.x + cx!@#&          self.y = self.y + cy!@#&          redgame.setPMAP(self.x,self.y,self.bID)!@#&          redgame.drawMapPixel(self.y,self.x)!@#&      end,!@#&!@#&      moveTX = function(self)!@#&        if( (self.x < player.x-1) and self:checkCollide(1,0)) then!@#&            cMov = math.random(1,self.mode)!@#&            if(cMov == self.mode)then self:redrawAt(1,0) end!@#&            if(self.x == player.x)then!@#&               self:moveTY()!@#&            end!@#&        end!@#&!@#&        if( (self.x > player.x+1) and self:checkCollide(-1,0)) then!@#&            cMov = math.random(1,self.mode)!@#&            if(cMov == self.mode)then self:redrawAt(-1,0) end!@#&            if(self.x == player.x)then!@#&                self:moveTY()!@#&            end!@#&        end!@#&      end,!@#&!@#&      moveTY = function(self)!@#&        if( (self.y < player.y) and self:checkCollide(0,1)) then!@#&            cMov = math.random(1,self.mode)!@#&            if(cMov == self.mode)then self:redrawAt(0,1) end!@#&            if(self.y == player.y)then!@#&               self:moveTX()!@#&            end!@#&        end!@#&!@#&        if( (self.y > player.y) and self:checkCollide(0,-1)) then!@#&            cMov = math.random(1,self.mode)!@#&            if(cMov == self.mode)then self:redrawAt(0,-1) end!@#&            if(self.y == player.y)then!@#&                self:moveTX()!@#&            end!@#&        end!@#&      end,!@#&!@#&      update = function(self,tick,player,health)!@#&        if(tick)then!@#&              if( (self.x == player.x+1 and self.y == player.y) or (self.x == player.x-1 and self.y == player.y) ) then!@#&                  health.value = health.value - self.dmg!@#&              end!@#&              if(self.y ~= player.y)then!@#&                    self:moveTY()!@#&              elseif(self.x ~= player.x)then!@#&                    self:moveTX()!@#&              end!@#&              return health.value!@#&        end!@#&      end,!@#&    }!@#&!@#&    return rat!@#&end!@#&!@#&statblks = {!@#&  ['water'] = 18,!@#&  ['food'] = 19,!@#&  ['pills'] = 20,!@#&  ['health'] = 21!@#&}!@#&!@#& rats = {}!@#&  local gamescore = 0!@#&  local intel = 3!@#&!@#&function resetStats()!@#&      lastvalues = {!@#&          sanity = 100,!@#&          hunger = 100,!@#&          thirst = 100,!@#&          health = 100,!@#&      }!@#&      sanity = {!@#&         stepstaken = 0,!@#&         steps = 20,!@#&         decrement = 10,!@#&         value = 100,!@#&      }!@#&      thirst = {!@#&         stepstaken = 0,!@#&         steps = 10,!@#&         decrement = 10,!@#&         value = 100,!@#&      }!@#&      hunger = {!@#&         stepstaken = 0,!@#&         steps = 15,!@#&         decrement = 5,!@#&         value = 100,!@#&      }!@#&      health = {!@#&         value = 100,!@#&         hunger_decrement = 0,!@#&         thirst_decrement = 10,!@#&         sanity_decrement = 20,!@#&         hunger_decrement_value = 2,!@#&         thirst_decrement_value = 5,!@#&         sanity_decrement_value = 3, !@#&      }!@#&      stepcount = 0!@#&end!@#&!@#&local isTick = false!@#&local lastX = 0!@#&local lastY = 0!@#&!@#&!@#&function updateSteps()!@#&    if(thirst.value < 0)then thirst.value = 0 end!@#&    if(hunger.value <= 0)then hunger.value = 0 end!@#&    if(sanity.value < 0)then sanity.value = 0 end!@#&    if(health.value <= 0)then !@#&      health.value = 0 !@#&      drawHud()!@#&      term.setBackgroundColor(colors.black)!@#&      term.setTextColor(colors.red)!@#&      term.clear()!@#&      term.setCursorPos((w/2) - (4), (h/2)-1)!@#&      write(\"GAMEOVER\")!@#&      sleep(0.6)!@#&      term.setTextColor(colors.yellow)!@#&      term.setCursorPos( (w/2) - ( (7 + string.len(tostring(gamescore))/2) ), (h/2)+1 )!@#&      write(\" Final Score: \" .. tostring(gamescore))!@#&      sleep(0.8)!@#&      term.setCursorPos((w/2) - (6), (h/2)+3)!@#&      term.setTextColor(colors.white)!@#&      write(\"Press Any Key.\")!@#&      os.pullEvent(\"key\")!@#&      player:unput()!@#&      resetStats()!@#&      isGame = false!@#&      isMenu = true!@#&      started=false!@#&      disposeRats()!@#&      fadein(1)!@#&      fadeout(0.5)!@#&      startloops()!@#&!@#&    end!@#&!@#&    if(thirst.value > 100)then thirst.value = 100 end!@#&    if(hunger.value > 100)then hunger.value = 100 end!@#&    if(sanity.value > 100)then sanity.value = 100 end!@#&    if(health.value > 100)then health.value = 100 end!@#&!@#&    sanity.stepstaken = sanity.stepstaken + 1!@#&    thirst.stepstaken = thirst.stepstaken + 1!@#&    hunger.stepstaken = hunger.stepstaken + 1!@#&!@#&    if(sanity.stepstaken >= sanity.steps)then!@#&        sanity.value = sanity.value - sanity.decrement!@#&        sanity.stepstaken = 0!@#&    end!@#&!@#&    if(thirst.stepstaken >= thirst.steps)then!@#&        thirst.value = thirst.value - thirst.decrement!@#&        thirst.stepstaken = 0!@#&    end!@#&!@#&    if(hunger.stepstaken >= hunger.steps)then!@#&        hunger.value = hunger.value - hunger.decrement!@#&        hunger.stepstaken = 0!@#&    end!@#&!@#&    if(sanity.value <= health.sanity_decrement)then!@#&        health.value = health.value - health.sanity_decrement_value!@#&    end!@#&!@#&    if(hunger.value <= health.hunger_decrement)then!@#&        health.value = health.value - health.hunger_decrement_value!@#&    end!@#&!@#&    if(thirst.value <= health.thirst_decrement)then!@#&        health.value = health.value - health.hunger_decrement_value!@#&    end!@#&end!@#&!@#&function game_step(player)!@#&    if(player:getBlockUnder() == statblks['water'] )then!@#&        gamescore = gamescore + 10!@#&        if( (thirst.value + 40) <= 100)then !@#&            thirst.value = thirst.value + 40 !@#&        else!@#&            thirst.value = 100!@#&        end!@#&          redgame.breakBlockAt(player.x,player.y)!@#&    end!@#&    if(player:getBlockUnder() == statblks['food'] )then!@#&      gamescore = gamescore + 10!@#&        if( (hunger.value + 40) <= 100)then !@#&            hunger.value = hunger.value + 40 !@#&        else!@#&            hunger.value = 100!@#&        end!@#&          redgame.breakBlockAt(player.x,player.y)!@#&    end!@#&    if(player:getBlockUnder() == statblks['pills'] )then!@#&      gamescore = gamescore + 10!@#&        if( (sanity.value + 30) <= 100)then !@#&            sanity.value = sanity.value + 30 !@#&        else!@#&            sanity.value = 100!@#&        end!@#&          redgame.breakBlockAt(player.x,player.y)!@#&    end!@#&    if(player:getBlockUnder() == statblks['health'] )then!@#&      gamescore = gamescore + 10!@#&        if( (health.value + 30) <= 100)then !@#&            health.value = health.value + 30 !@#&        else!@#&            health.value = 100!@#&        end!@#&          redgame.breakBlockAt(player.x,player.y)!@#&    end!@#&!@#&    if( (lastX ~= player.x) or (lastY ~= player.y) )then!@#&        stepcount = stepcount + 1!@#&        lastX = player.x!@#&        lastY = player.y!@#&        updateSteps();!@#&        isTick = true;!@#&    end!@#&end!@#&!@#&function disposeRats()!@#&      for i = 0, #rats do!@#&          if(rats[i] ~= nil)then!@#&             rats[i]:dispose()!@#&             rats[i] = nil!@#&          end!@#&      end!@#&end!@#&!@#&function randomize_cave()!@#&    if(redgame.getCurrentMap() == \"MAP02\")then!@#&        if(not randomized)then!@#&            randItems = {!@#&              [0] = 18,!@#&              [1] = 19,!@#&              [2] = 20,!@#&              [3] = 21,!@#&            }!@#&            disposeRats()!@#&            for i = 1, math.random(5 + intel,12) do!@#&                rx = math.random(5,40)!@#&                ry = math.random(7,12)!@#&                rats[#rats+1] = createRat(rx,ry,5 * intel,\"MAP02\",intel)!@#&                rats[#rats]:put()!@#&            end!@#&            for i = 1, math.random(3,8) do!@#&                rx = math.random(5,40)!@#&                ry = math.random(7,12)!@#&                if(redgame.getGMAP()[ry][rx] == 0)then!@#&                    redgame.setBlockAt(randItems[math.random(0,3)],rx,ry)!@#&                end!@#&            end!@#&            !@#&            redgame.addDoor(2,10, 26,17, \"MAP02\", \"MAP03\")!@#&            redgame.addDoor(w-1,11, 26,17, \"MAP02\", \"MAP03\")!@#&            randomized = true!@#&        end!@#&    end!@#&end!@#&!@#&function drawHud() !@#&    term.current().setVisible(false)!@#&      term.setBackgroundColor(colors.blue)!@#&      term.setTextColor(colors.white)!@#&      paintutils.drawFilledBox(1,1,w,4,colors.cyan)!@#&      term.setCursorPos(3, 1)!@#&      print(\"Sanity: \" .. tostring(sanity.value) )!@#&      term.setCursorPos(3, 2)!@#&      print(\"Thirst: \" .. tostring(  math.abs(thirst.value - 100)  ) )!@#&      term.setCursorPos(3, 3)!@#&      print(\"Hunger: \" .. tostring(  math.abs(hunger.value - 100)  ) )!@#&      term.setCursorPos(3, 4)!@#&      print(\"HEALTH: \" .. tostring(health.value) )!@#&      term.setCursorPos(23, 4)!@#&      print(\"SCORE: \" .. tostring(gamescore) )      !@#&    term.current().setVisible(true) !@#&end!@#&!@#&function fadein(speed)!@#&    fades = {\"black\", \"gray\", \"lightGray\", \"white\"}!@#&    sleepTime = speed / #fades!@#&    for i=1, #fades do!@#&        term.setBackgroundColor(colors[fades[i]])!@#&        term.clear()!@#&        sleep(sleepTime)!@#&    end!@#&end!@#&!@#&function fadeout(speed)!@#&    fades = {\"white\", \"lightGray\", \"gray\", \"black\"}!@#&    sleepTime = speed / #fades!@#&    for i=1, #fades do!@#&        term.setBackgroundColor(colors[fades[i]])!@#&        term.clear()!@#&        sleep(sleepTime)!@#&    end!@#&end!@#&!@#&function Intro(skip) !@#&  redgame.openTextbox()!@#&  redgame.drawTextbox(\"Skip intro?\",1,50)!@#&  if(redgame.createYesNo(\"Yes\",\"No\",2) ~= \"ok\")then!@#&    redgame.closeTextboxRaw()!@#&    redgame.openTextbox()!@#&    redgame.drawTextbox(\"There is a legend... a legend of a fierce\",1,50)!@#&    redgame.drawTextbox(\"and evil virus called the Kone.\",2,50)!@#&    redgame.closeTextbox()!@#&    redgame.openTextbox()!@#&    redgame.drawTextbox(\"The virus came from the rusty pneumatics\",1,50)!@#&    redgame.drawTextbox(\"in old elevators it killed thousands \",2,50)!@#&    redgame.drawTextbox(\"of people.. \",3,50)!@#&    redgame.closeTextbox()!@#&    redgame.openTextbox()!@#&    redgame.drawTextbox(\"It was horrible, everyone infected..\",1,50)!@#&    redgame.drawTextbox(\".. Well storys tell that those infected \",2,50)!@#&    redgame.drawTextbox(\"where sent to this very island..\",3,50)!@#&    redgame.closeTextbox()!@#&    redgame.openTextbox()!@#&    redgame.drawTextbox(\"They say they are hidden in the caves..\",1,50)!@#&    redgame.drawTextbox(\"You have opened the cave, and disturbed the\",2,50)!@#&    redgame.setBlockAt(15,18,11)!@#&    redgame.setBlockAt(15,19,11)!@#&    term.setBackgroundColor(colors.blue)!@#&    redgame.drawTextbox(\"Kone. Have fun on your suicide mission.\",3,50)!@#&    redgame.closeTextbox()!@#&  else!@#&    redgame.closeTextboxRaw()!@#&  end!@#&    sleep(0.5)!@#&    fadein(2)!@#&    redgame.setMap(\"MAP02\")!@#&    fadeout(1)!@#&    player:setPos(26,17)!@#&    player:put()!@#&    redgame.draw()!@#&    randomized=false!@#&    randomize_cave()!@#&end!@#&!@#&!@#&!@#&--]] Load game resources!@#&res_map01 = redgame.getResource(root .. \"maps/MAP01\")!@#&res_map02 = redgame.getResource(root .. \"maps/MAP02\")!@#&res_map03 = redgame.getResource(root .. \"maps/MAP03\")!@#&res_tileset = redgame.getResource(root .. \"maps/blocks/tileset\")!@#&!@#&--]] Create Maps!@#&redgame.addMap(\"MAP01\",res_map01,res_tileset)!@#&redgame.addMap(\"MAP02\",res_map02,res_tileset)!@#&redgame.addMap(\"MAP03\",res_map03,res_tileset)!@#&!@#&--]] Set starting map!@#&!@#&--]] Creating player / interactions!@#&player = redgame.createPlayer(1,26,17)!@#&lastX = player.x!@#&lastY = player.y!@#&!@#&--]] player:addInteraction(\"MAP01\",8,10,NPC01)!@#&!@#&function menusys()!@#&    local menu = {!@#&       options = {!@#&          \" Easy \",!@#&          \"Medium\",!@#&          \" Hard \",!@#&          \" Quit \",!@#&       };!@#&       selectedindex = 1,!@#&!@#&       transition = function(self)!@#&!@#&       end,!@#&!@#&       update = function(self,ev) !@#&            if(ev[1] == \"key\")then!@#&                if(ev[2] == keys.up and self.selectedindex > 1)then!@#&                  self.selectedindex = self.selectedindex - 1!@#&                  self:draw()!@#&                end!@#&                if(ev[2] == keys.down and self.selectedindex < #self.options)then!@#&                  self.selectedindex = self.selectedindex + 1!@#&                  self:draw()!@#&                end!@#&                if(ev[2] == keys.enter)then!@#&                   self:transition(self.selectedindex)!@#&                   return self.selectedindex!@#&                end!@#&            end!@#&       end,!@#&!@#&       draw = function(self)!@#&          --]] get longest menu item!@#&          long=0!@#&          for i=1, #self.options do!@#&              if(#self.options[i] > long)then!@#&                  long = #self.options[i]!@#&              end!@#&          end!@#&!@#&          --]] paint in menu box!@#&          centerx = ( math.floor(w/2) - ( (long) / 2) )-2!@#&          centery = ( math.floor(h/2)+6 )!@#&          paintutils.drawFilledBox( !@#&          centerx-1, centery-1, !@#&          centerx+(long+4), centery+(#self.options),!@#&          colors.lightGray)!@#&!@#&          --]] draw menu upper thingy!@#&          term.setCursorPos(centerx-1,centery-1)!@#&          term.setTextColor(colors.gray)!@#&          write(string.rep(\"@\",long+6))!@#&          for i=1,#self.options do!@#&              term.setCursorPos(((w/2)-2) - (#self.options[i]/2) !@#&              ,centery+(i-1) )!@#&              term.setTextColor(colors.black)!@#&!@#&              if(self.selectedindex == i)then!@#&                    write(\"> \") !@#&                    term.setTextColor(colors.red)!@#&                    write(self.options[i])!@#&              else!@#&                    write(\"  \" .. self.options[i])!@#&              end!@#&          end!@#&          --]] draw bottom thingy!@#&          term.setCursorPos(centerx-1,centery+(#self.options))!@#&          term.setBackgroundColor(colors.gray)!@#&          write(string.rep(\" \",long+6))!@#&       end,!@#&    }!@#&!@#&    return menu!@#&end!@#&!@#&!@#&--]] Game loop!@#&function startloops()!@#&    setuptitle()!@#&    menu:draw()!@#&!@#&    while isMenu and not isGame do!@#&        events = {os.pullEvent()}!@#&        val = menu:update(events)!@#&!@#&        if(val == 1)then!@#&          intel = 4!@#&        elseif(val == 2)then!@#&          intel = 3!@#&        elseif(val == 3)then!@#&          intel = 2!@#&        elseif(val == 4)then!@#&           isMenu = false!@#&           fadein(0.5)!@#&           fadeout(0.5)!@#&           term.setTextColor(colors.white)!@#&           term.setCursorPos(1,1)!@#&        end!@#&!@#&        if(val == 1 or val == 2 or val == 3)then!@#&          started = false!@#&            isMenu = false!@#&            isGame = true!@#&            fadein(0.5)!@#&            fadeout(0.5)!@#&            break!@#&        end!@#&!@#&        if(events[1] == 'timer')then!@#&            term.current().setVisible(false)!@#&            timer = os.startTimer(2)!@#&            if(animindex == 6)then !@#&               animindex = 1 !@#&            else!@#&               animindex = animindex + 1 !@#&            end!@#&            paintutils.drawImage(animation[animindex],1,1)!@#&            menu:draw()!@#&            term.current().setVisible(true)!@#&        end!@#&    end!@#&    !@#&    while isGame and not isMenu do!@#&      startgame()!@#&!@#&      game_step(player)!@#&      --]] Draw HUD!@#&      drawHud()!@#&      --]] Update player!@#&      player:update()!@#&!@#&      if(redgame.getCurrentMap() == \"MAP03\")then!@#&          disposeRats()!@#&          randomized=false!@#&          redgame.setMap(\"MAP02\")!@#&          player:setPos(26,17)!@#&      end!@#&!@#&      if(isTick)then!@#&        gamescore = gamescore + 1!@#&          --]] Update enemys!@#&          for i = 0, #rats do!@#&              if(rats[i] ~= nil)then!@#&                 health.value = rats[i]:update(isTick,player,health)!@#&              end!@#&          end!@#&          isTick = false!@#&      end!@#&!@#&      if(player.y > 17) then player:moveUp(1) end!@#&!@#&      --]] Generate random obstacles when entering cave!@#&      randomize_cave()!@#&!@#&      game_step(player)!@#&    end!@#&end!@#&!@#&function startgame()!@#&  if(not started)then!@#&    redgame.setMap(\"MAP01\")!@#&    redgame.draw()!@#&    started=true!@#&    Intro()!@#&  end!@#&end!@#&!@#&function setuptitle()!@#&    menu = menusys(nil,nil,nil)!@#&    menu:draw()!@#&    --]] clear screen and draw title!@#&    term.setBackgroundColor(colors.black)!@#&    term.setTextColor(colors.white)!@#&    term.clear()!@#&    timer = os.startTimer(2)!@#&!@#&    animation = {!@#&        [1] = paintutils.loadImage(root .. \"game/title/anim0\"),!@#&        [2] = paintutils.loadImage(root .. \"game/title/anim1\"),!@#&        [3] = paintutils.loadImage(root .. \"game/title/anim2\"),!@#&        [4] = paintutils.loadImage(root .. \"game/title/anim3\"),!@#&        [5] = paintutils.loadImage(root .. \"game/title/anim4\"),!@#&        [6] = paintutils.loadImage(root .. \"game/title/anim5\"),!@#&    }!@#&    animindex = 1!@#&    paintutils.drawImage(animation[animindex],1,1)!@#&end!@#&!@#&startloops()",
  3.   game = {
  4.     oldhud = "function drawHud() !@#&   if ((sanity.value ~= lastvalues.sanity) or !@#&       (thirst.value ~= lastvalues.thirst) or!@#&       (hunger.value ~= lastvalues.hunger) or!@#&       (health.value ~= lastvalues.health)!@#&       ) then!@#&      term.setBackgroundColor(colors.blue)!@#&      term.setTextColor(colors.white)!@#&      paintutils.drawFilledBox(2,2,w-2,6,colors.cyan)!@#&     !@#&      term.setCursorPos(3, 2)!@#&      print(\"Sanity: \" .. tostring(sanity.value) )!@#&      term.setCursorPos(3, 3)!@#&      print(\"Thirst: \" .. tostring(  math.abs(thirst.value - 100)  ) )!@#&      term.setCursorPos(3, 4)!@#&      print(\"Hunger: \" .. tostring(  math.abs(hunger.value - 100)  ) )!@#&      term.setCursorPos(10, 6)!@#&      print(\"HEALTH: \" .. tostring(health.value) )      !@#&      lastvalues = {!@#&          sanity = sanity.value,!@#&          hunger = hunger.value,!@#&          thirst = thirst.value,!@#&          health = health.value,!@#&      }!@#&  end!@#&end!@#&!@#&  if(entered_cave == false and redgame.getCurrentMap() == \"MAP02\")then!@#&     entered_cave = true!@#&     redgame.openTextbox()!@#&     redgame.drawTextbox(\"The door slams shut behind you!\",1,20)!@#&     redgame.drawTextbox(\"You try to open it but its stuck.\",2,20)!@#&     redgame.drawTextbox(\"The thought that this was a bad idea dawns\",3,20)!@#&     redgame.drawTextbox(\"on you. You must find a way out!\",4,20)!@#&     redgame.closeTextbox()!@#&  end!@#&!@#&!@#&               if( (self.y ~= player.y) ) then !@#&                  if(self.y > player.y-1)then!@#&                      if(self:checkCollide(0,-1))then!@#&                        redgame.setPMAP(self.x,self.y,0)!@#&                        redgame.drawMapPixel(self.y,self.x)!@#&                        self.y = self.y - 1!@#&                        redgame.setPMAP(self.x,self.y,self.bID)!@#&                        redgame.drawMapPixel(self.y,self.x)!@#&!@#&                            if(self.y == player.y)then!@#&                                if(self.x > player.x-1)then!@#&                                   if(self:checkCollide(-1,0))then!@#&                                    redgame.setPMAP(self.x,self.y,0)!@#&                                    redgame.drawMapPixel(self.y,self.x)!@#&                                    self.x = self.x - 1!@#&                                    redgame.setPMAP(self.x,self.y,self.bID)!@#&                                    redgame.drawMapPixel(self.y,self.x)!@#&                                   end!@#&                                end!@#&                            end!@#&                      end!@#&!@#&                  elseif(self.y < player.y+1)then!@#&!@#&                     if(self:checkCollide(0,1))then!@#&                      redgame.setPMAP(self.x,self.y,0)!@#&                      redgame.drawMapPixel(self.y,self.x)!@#&                      self.y = self.y + 1!@#&                      redgame.setPMAP(self.x,self.y,self.bID)!@#&                      redgame.drawMapPixel(self.y,self.x)!@#&                        if(self.y == player.y)then!@#&                            if(self.x < player.x+1)then!@#&                               if(self:checkCollide(1,0))then!@#&                                redgame.setPMAP(self.x,self.y,0)!@#&                                redgame.drawMapPixel(self.y,self.x)!@#&                                self.x = self.x + 1!@#&                                redgame.setPMAP(self.x,self.y,self.bID)!@#&                                redgame.drawMapPixel(self.y,self.x)!@#&                               end!@#&                           end!@#&                        end!@#&          end!@#&!@#&              !@#&    if(result == \"ok\")then!@#&!@#&      ocave = redgame.createYesNo(\"Open the cave!\",\"Oh wow\",2)!@#&      if(ocave == \"ok\")then!@#&        redgame.closeTextboxRaw()!@#&        redgame.openTextbox()!@#&        redgame.drawTextbox(\"Woah are you crazy?!? fine i will\",1,50)!@#&!@#&        cave_open = true!@#&        !@#&        redgame.setBlockAt(15,18,11)!@#&        redgame.setBlockAt(15,19,11)!@#&        redgame.addDoor(18,11, 26,17, \"MAP01\", \"MAP02\")!@#&        redgame.addDoor(19,11, 26,17, \"MAP01\", \"MAP02\")!@#&      else!@#&        redgame.closeTextboxRaw()!@#&      end!@#&    else!@#&!@#&    end!@#&    else!@#&       redgame.drawTextbox(\"Go on already, i thought you wanted to die?\",1,80)!@#&       redgame.closeTextbox()!@#&    end!@#&    !@#&    redgame.closeTextbox()",
  5.     title = {
  6.       anim1 = "707e77777eeee777eeeee77eeee777eee77e777eee7777777!@#&080e77777e777777e777777e777777e7e77e777e77e777777!@#&707e77777eeee777e7eee77eeee777e7ee7e777e77e777777!@#&777e77777e777777e777e77e777777e77eee777e77e777777!@#&777eeee77eeee777eeeee77eeee777e777ee777eee7777777!@#&88800007700d1777000007700007770777007770008888888!@#&   888888881881118888888888888888888888888!@#&          11d1!@#&          11d      111    1!@#&       dd1  11    dd 1   d11    d   d11!@#&        1    11   1  1   1 1   11   1  11!@#&              1   1 dd   1  1 11   11d!@#&                  1111   dd 1d1    1  111!@#&                         1   d1   11d1!@#&                                     11",
  7.       anim5 = "777e77777eeee777eeeee77eeee777eee77e777eee7777777!@#&777e77777e777777e777777e777777e7e77e777e77e777777!@#&777e77777eeee777e7eee77eeee777e7ee7e777e77e777777!@#&777e77777e777777e777e77e777707e77eee777e77e777777!@#&777eeee77eeee777eeeee77eeee080e777ee777eee7777777!@#&88800007700d1777000007700007070777007770008888888!@#&   888888881881118888888888888888888888888!@#&          11d1!@#&          11d      111    1!@#&       dd1  11    dd 1   d11    d   d11!@#&        1    11   1  1   1 1   11   1  11!@#&              1   1 dd   1  1 11   11d!@#&                  1111   dd 1d1    1  111!@#&                         1   d1   11d1!@#&                                     11",
  8.       anim3 = "777e77777eeee777eeeee77eeee777eee77e777eee7777777!@#&777e77777e777777e777777e777777e7e77e777e77e707777!@#&777e77777eeee777e7eee77eeee777e7ee7e777e77e080777!@#&777e77777e777777e777e77e777777e77eee777e77e707777!@#&777eeee77eeee777eeeee77eeee777e777ee777eee7777777!@#&88800007700d1777000007700007770777007770008888888!@#&   888888881881118888888888888888888888888!@#&          11d1!@#&          11d      111    1!@#&       dd1  11    dd 1   d11    d   d11!@#&        1    11   1  1   1 1   11   1  11!@#&              1   1 dd   1  1 11   11d!@#&                  1111   dd 1d1    1  111!@#&                         1   d1   11d1!@#&                                     11",
  9.       anim2 = "777e77777eeee777eeeee77eeee777eee77e777eee7777777!@#&777e77077e777777e777777e777777e7e77e777e77e777777!@#&777e70807eeee777e7eee77eeee777e7ee7e777e77e777777!@#&777e77077e777777e777e77e777777e77eee777e77e777777!@#&777eeee77eeee777eeeee77eeee777e777ee777eee7777777!@#&88800007700d1777000007700007770777007770008888888!@#&   888888881881118888888888888888888888888!@#&          11d1!@#&          11d      111    1!@#&       dd1  11    dd 1   d11    d   d11!@#&        1    11   1  1   1 1   11   1  11!@#&              1   1 dd   1  1 11   11d!@#&                  1111   dd 1d1    1  111!@#&                         1   d1   11d1!@#&                                     11",
  10.       anim0 = "777e77777eeee777eeeee77eeee777eee77e777eee7777777!@#&777e77777e777777e777777e777777e7e77e777e77e777777!@#&777e77777eeee777e7eee77eeee777e7ee7e777e77e777777!@#&777e77777e777777e777e77e777777e77eee777e77e777777!@#&777eeee77eeee777eeeee77eeee777e777ee777eee7777777!@#&88800007700d1777000007700007770777007770008888888!@#&   888888881881118888888888888888888888888!@#&          11d1!@#&          11d      111    1!@#&       dd1  11    dd 1   d11    d   d11!@#&        1    11   1  1   1 1   11   1  11!@#&              1   1 dd   1  1 11   11d!@#&                  1111   dd 1d1    1  111!@#&                         1   d1   11d1!@#&                                     11",
  11.       anim4 = "777e77777eeee777eeeee77eeee777eee77e777eee7777777!@#&777e77777e777777e777770e777777e7e77e777e77e777777!@#&777e77777eeee777e7eee080eee777e7ee7e777e77e777777!@#&777e77777e777777e777e70e777777e77eee777e77e777777!@#&777eeee77eeee777eeeee77eeee777e777ee777eee7777777!@#&88800007700d1777000007700007770777007770008888888!@#&   888888881881118888888888888888888888888!@#&          11d1!@#&          11d      111    1!@#&       dd1  11    dd 1   d11    d   d11!@#&        1    11   1  1   1 1   11   1  11!@#&              1   1 dd   1  1 11   11d!@#&                  1111   dd 1d1    1  111!@#&                         1   d1   11d1!@#&                                     11",
  12.     },
  13.     redgame = "--]] RedGame API By: Redxone[[--!@#&!@#&function init()!@#&      w,h = term.getSize()!@#&        pmap = {}!@#&    for i = 1, h do!@#&        pmap[i] = {}!@#&       for c = 1, w do!@#&            pmap[i][c] = 0!@#&       end    !@#&    end!@#&!@#&    gmap = {}!@#&  emp={}!@#&      gplayer={}!@#&  gblocks={}!@#&  doors={}!@#&    maps={}!@#&     mapName = \"\"!@#&!@#&end!@#&!@#&function getGMAP()!@#& return gmap!@#&end!@#&!@#&function getPMAP()!@#&        return pmap!@#&end!@#&!@#&function getGBLOCKS()!@#&     return gblocks!@#&end!@#&!@#&function setPMAP(x,y,id)!@#&       pmap[y][x] = id!@#&end!@#&!@#&function setGMAP(x,y,id)!@#&      gmap[y][x] = id!@#&end!@#&!@#&function openTextbox()!@#&        paintutils.drawBox(1,h-5,w,h,colors.gray)!@#&   paintutils.drawFilledBox(2,h-4,w-1,h-1,colors.blue)!@#&end!@#&!@#&clearTextbox = openTextbox!@#&!@#&function drawTextbox(text,ln,speed)!@#&     term.setCursorPos(6,h- ( 4 - ( ln-1 ) ) )!@#&   term.setTextColor(colors.white)!@#&     textutils.slowPrint(text,speed)!@#&end!@#&!@#&function createYesNo(YText,NText,ln)!@#&  local sel = 1!@#&       local waiting = true!@#&        local opt = {!@#&               {name=YText};!@#&               {name=NText};!@#&       }!@#&!@#&       function waitResult()!@#&               while waiting do!@#&                    for i = 1, #opt do!@#&                          term.setCursorPos((w/2) - #opt[i].name/2,h- ( 4 - ( (ln+i)-1 ) ) )!@#&                          if(sel == i )then!@#&                                   write(\"[\"..opt[i].name..\"]\")!@#&                            else!@#&                                        write(\" \"..opt[i].name..\" \")!@#&                            end!@#&                 end!@#&!@#&                     a = {os.pullEvent(\"key\")}!@#&!@#&                     if(a[2] == keys.w and sel > 1)then!@#&                          sel = sel - 1!@#&                       end!@#&                 if(a[2] == keys.s and sel < #opt)then!@#&                               sel = sel + 1!@#&                       end!@#&                 if(a[2] == keys.space)then!@#&                          if(sel == 1)then waiting = false  return \"ok\" end!@#&                         if(sel == 2)then  waiting = false return \"no\" end!@#&                 end!@#&         end!@#& end!@#& return waitResult()!@#&end!@#&!@#&!@#&function addDoor(fromx,fromy,tox,toy,fromMap,toMap)!@#&   doors[#doors+1] = {fx=fromx,fy=fromy,tx=tox,ty=toy,fMap=fromMap,tMap=toMap}!@#&end!@#&!@#&function draw()!@#&!@#&       for i = 1, #gmap do!@#&         for c = 1, #gmap[i] do!@#&                      term.setCursorPos(c,i)!@#&                      term.setTextColor(colors[ gblocks[ gmap[i][c] ].color ])!@#&                    term.setBackgroundColor(colors[ gblocks[ gmap[i][c] ].bcolor ])!@#&                     write(gblocks[ gmap[i][c] ].graphic)!@#&                end!@#& end!@#&!@#&     for i = 1, #pmap do!@#&         for c = 1, #pmap[i] do!@#&                      if(pmap[i][c] ~= 0)then!@#&                             term.setCursorPos(c,i)!@#&                              term.setTextColor(colors[ gblocks[ pmap[i][c] ].color ])!@#&                            term.setBackgroundColor(colors[ gblocks[ pmap[i][c] ].bcolor ])!@#&                             write(gblocks[ pmap[i][c] ].graphic)!@#&                        end!@#&         end!@#& end!@#&!@#&end!@#&!@#&!@#&function closeTextbox()!@#&   os.pullEvent(\"key\")!@#&       draw()!@#&      term.setCursorPos(1,h)!@#&      term.setBackgroundColor(colors[gblocks[0].bcolor])!@#&  term.clearLine()!@#&end!@#&!@#&function closeTextboxRaw()!@#&   draw()!@#&      term.setCursorPos(1,h)!@#&      term.setBackgroundColor(colors[gblocks[0].bcolor])!@#&  term.clearLine()!@#&end!@#&!@#&!@#&function drawMapPixel(x,y)!@#&       term.setCursorPos(y,x)!@#&      term.setTextColor(colors[ gblocks[ gmap[x][y] ].color ])!@#&    term.setBackgroundColor(colors[ gblocks[ gmap[x][y] ].bcolor ])!@#&     write(gblocks[ gmap[x][y] ].graphic)!@#&        if(pmap[x][y] ~= 0)then!@#&             term.setCursorPos(y,x)!@#&              term.setTextColor(colors[ gblocks[ pmap[x][y] ].color ])!@#&            term.setBackgroundColor(colors[ gblocks[ pmap[x][y] ].bcolor ])!@#&             write(gblocks[ pmap[x][y] ].graphic)!@#&        end!@#&end!@#&!@#&function lookupBlock(id)!@#&  for i = 1, #gmap do!@#&         for c = 1, #gmap[i] do!@#&                      if(gmap[i][c] == id)then return true end!@#&            end!@#& end!@#& return false!@#&end!@#&!@#&function findBlockAt(id)!@#& inf = {}!@#&    for i = 1, #gmap do!@#&         for c = 1, #gmap[i] do!@#&                      if(gmap[i][c] == tonumber(id))then !@#&                          return i,c !@#&                        end!@#&         end!@#& end!@#& return nil!@#&end!@#&!@#&function getBlockAt(x,y)!@#&   return gmap[y][x]!@#&end!@#&!@#&function setBlockAt(id,x,y)!@#& gmap[y][x] = id!@#&     drawMapPixel(y,x)!@#&end!@#&!@#&function breakBlockAt(x,y)!@#&  gmap[y][x] = 0!@#&      drawMapPixel(y,x)!@#&end!@#&!@#&function editBlock(id,color,bcolor,graphic,solid)!@#&   gblocks[id].color = color!@#&   gblocks[id].bcolor = bcolor!@#& gblocks[id].graphic = graphic!@#&       gblocks[id].solid = solid!@#&   draw()!@#&end!@#&function getCurrentMap()!@#&   return mapName!@#&end!@#&!@#&!@#&function addMap(name,levmap,blocks)!@#&        if(maps[name] ~= nil)then error(\"[Redgame] - > AddMap - > Map already added!\") end!@#&        maps[name] = {level=levmap,blockmap=blocks}!@#&end!@#&!@#&function setSolid(id,solid)!@#&       gblocks[id].solid = solid!@#&end!@#&!@#&function getResource(file)!@#&  f = fs.open(file,\"r\")!@#&     res = textutils.unserialize(f.readAll())!@#&    f.close()!@#&   if(type(res) ~= \"table\")then error(\"[RedGame]: getResource -> file [\"..file..\"] must contain only a table!\") end!@#&      return res!@#&end!@#&!@#&function setMap(map)!@#&       if(maps[map] == nil)then!@#&            error(\"[RedGame] -> setMap -> No such map.\")!@#&      end!@#& gmap=maps[map].level!@#&        mapName = map!@#&       gblocks = maps[map].blockmap!@#&        draw()!@#&end!@#&!@#&function getMap()!@#&      return gmap!@#&end!@#&!@#&!@#&!@#&!@#&function createPlayer(block,startX,startY)!@#&!@#&        local player = {!@#&!@#&                x=startX,!@#&           y=startY,!@#&           tickrate=tonumber(0.1),!@#&             physicsTick = os.startTimer(0.1),!@#&           jump_height=2,!@#&              hspd = 0,!@#&           vspd = 0,!@#&           blockid = block,!@#&            multidir = false,!@#&           physic_control= {!@#&                   [\"direction_up\"] = keys.w,!@#&                        [\"direction_down\"] = keys.s,!@#&                      [\"direction_left\"] = keys.a,!@#&                      [\"direction_right\"] = keys.d,!@#&             },!@#&          lastMove = \"player_up\",!@#&           events = {},!@#&                interactions ={},!@#&!@#&               addInteraction = function(self,mydmap,x,y,func)!@#&                     self.interactions[#self.interactions+1] = {onmap=mydmap,x=x,y=y,active=true,event=func}!@#&             end,!@#&!@#&            removeInteraction = function(self,mydmap,x,y)!@#&                       for i = 1, #self.interactions do!@#&                            if(self.interactions[i].x == x and self.interactions[i].y == y and self.interactions[i].onmap == mydmap)then!@#&                                        self.interactions[i].active=false;!@#&                          end!@#&                 end !@#&                end,!@#&!@#&            setPhysicsTick = function(self,time)!@#&                        self.tickrate = tonumber(time)!@#&                      self.physicsTick = os.startTimer(time)!@#&              end,!@#&!@#&            addEvent = function(self,check,evfunc)!@#&                      table.insert(self.events,{type=check,run=evfunc})!@#&           end,!@#&!@#&            getBlockUnder = function(self)!@#&                              if(gmap[self.y][self.x] ~= 0)then!@#&                                   return gmap[self.y][self.x]!@#&                         end!@#&                         return 0!@#&            end,!@#&!@#&!@#&                checkCollision = function(self,x,y)!@#&                 hasColl = false!@#&                     if( gblocks[gmap[y][x]].solid or pmap[y][x] ~= 0)then hasColl = true end!@#&                    if( gmap[y][x] == 0 and pmap[y][x] == 0)then hasColl = false end!@#&                    return hasColl!@#&              end,!@#&!@#&            jump = function(self,ammount)!@#&                       if(self:checkCollision(self.x,self.y+1))then!@#&                                for i = 1, ammount do!@#&                                       if(not self:checkCollision(self.x,self.y-1))then!@#&                                            pmap[self.y][self.x] = 0!@#&                                            drawMapPixel(self.y,self.x)!@#&                                         self.y = self.y - 1!@#&                                         pmap[self.y][self.x] = self.blockid!@#&                                         drawMapPixel(self.y,self.x)!@#&                                 end!@#&                         end!@#&                 end!@#&         end,!@#&!@#&            moveUp=function(self,ammount)!@#&                       if(not self:checkCollision(self.x,self.y-1) and not self:checkPhysics(\"gravity\"))then!@#&                             pmap[self.y][self.x] = 0!@#&                            drawMapPixel(self.y,self.x)!@#&                         self.y = self.y - ammount!@#&                           pmap[self.y][self.x] = self.blockid!@#&                         drawMapPixel(self.y,self.x)!@#&                 end!@#&!@#&                     if(not self:checkCollision(self.x,self.y-1) and self:checkPhysics(\"gravity\"))then!@#&                         self:jump(self.jump_height)!@#&                 end!@#&         end,!@#&!@#&            moveDown=function(self,ammount)!@#&                     if(not self:checkCollision(self.x,self.y+1))then!@#&                            pmap[self.y][self.x] = 0!@#&                            drawMapPixel(self.y,self.x)!@#&                         self.y = self.y + ammount!@#&                           pmap[self.y][self.x] = self.blockid!@#&                         drawMapPixel(self.y,self.x)!@#&                 end     !@#&            !@#&            end,!@#&!@#&            moveLeft=function(self,ammount)!@#&                     --pmap[self.y][self.x-1] == 0!@#&                       if(not self:checkCollision(self.x-1,self.y))then!@#&                            pmap[self.y][self.x] = 0!@#&                            drawMapPixel(self.y,self.x)!@#&                         self.x = self.x - ammount!@#&                           pmap[self.y][self.x] = self.blockid!@#&                         drawMapPixel(self.y,self.x)!@#&                 end             !@#&!@#&!@#&            end,!@#&!@#&            moveRight=function(self,ammount)!@#&                    if(not self:checkCollision(self.x+1,self.y))then!@#&                            pmap[self.y][self.x] = 0!@#&                            drawMapPixel(self.y,self.x)!@#&                         self.x = self.x + ammount!@#&                           pmap[self.y][self.x] = self.blockid!@#&                         drawMapPixel(self.y,self.x)!@#&                 end             !@#&            end,!@#&!@#&!@#&                physics = {!@#&!@#&                     [\"gravity\"] = {has=false,func=function(self) !@#&                             if(not self:checkCollision(self.x,self.y+1))then!@#&                                            self:moveDown(1)!@#&                                            sleep(0.01)!@#&                         end!@#&                 end};!@#&!@#&                   [\"smooth_experimental\"] = {has=false,func=function(self) !@#&                                 self.multidir = true!@#&                                        self.physics[\"smooth_experimental\"].has = false!@#&                   end};!@#&!@#&           },!@#&!@#&!@#&          checkPhysics = function(self,element)!@#&                       for k, v in pairs(self.physics) do!@#&                          if(k == element and v.has)then!@#&                                      return true!@#&                         end!@#&                 end!@#&!@#&                     return false!@#&                end,!@#&!@#&            checkInteract = function(self)!@#&                      for i = 1, #self.interactions do!@#&                            if(    ((self.y == self.interactions[i].y-1) !@#&                                       and (self.x == self.interactions[i].x)) !@#&                                    or ((self.y == self.interactions[i].y+1)!@#&                                and (self.x == self.interactions[i].x))!@#&                                 or ((self.y == self.interactions[i].y)!@#&                                  and (self.x == self.interactions[i].x+1))!@#&                                       or ((self.y == self.interactions[i].y)!@#&                                  and (self.x == self.interactions[i].x-1))!@#&                                   )then!@#&                                   if(self.interactions[i].onmap == getCurrentMap() and self.interactions[i].active)then!@#&                                               self.interactions[i].event()!@#&                                        end!@#&                         end!@#&                 end!@#&         end,!@#&!@#&            controls = {!@#&                        {name = \"player_interact\",event=\"key\",key=keys.space,func=function(self) self:checkInteract() end};!@#&                     {name=\"player_up\",event=\"key\",key=keys.w,func=function(self) self.lastMove = \"player_up\" self:moveUp(1)  end};!@#&                        {name=\"player_down\",event=\"key\",key=keys.s,func=function(self) self.lastMove = \"player_down\" self:moveDown(1) end};!@#&                   {name=\"player_left\",event=\"key\",key=keys.a,func=function(self) self.lastMove = \"player_left\" self:moveLeft(1) end};!@#&                   {name=\"player_right\",event=\"key\",key=keys.d,func=function(self)self.lastMove = \"player_right\" self:moveRight(1) end};!@#&         },!@#&!@#&              --]] movement functions!@#&!@#&         put = function(self)!@#&                        pmap[self.y][self.x] = self.blockid !@#&                end,!@#&!@#&            unput = function(self)!@#&                      pmap[self.y][self.x] = 0; !@#&                  drawMapPixel(self.y,self.x)!@#&         end,!@#&!@#&            applyPhysics = function(self,element)!@#&                       if(self.physics[element] ~= nil)then!@#&                                if(self.physics[element].has == false)then!@#&                                  self.physics[element].has = true!@#&                            end!@#&                 else!@#&                                error(\"[RedGame]: player -> addPhysicsElement -> no such element!\")!@#&                       end!@#&         end,!@#&!@#&            setJumpHeight = function(self,h)!@#&                    self.jump_height = h!@#&                end,!@#&!@#&            createPhysics = function(self,element,physic)!@#&                               if(self.physics[element] ~= nil)then error(\"[RedGame]: player - > createPhysicsElement -> element already exists!\") end!@#&                           if(type(physic) ~= \"table\")then error(\"[RedGame]: player -> createPhysicsElement -> must be in table format eg {func=function(self) physics stuff end};\") end!@#&                            metaindex = {has=false,func=function(self) end};!@#&                           physic = setmetatable(physic, {__index = metaindex})!@#&                                self.physics[element] = physic!@#&              end,!@#&!@#&            remapPhysicsControl = function(self,name,to)!@#&                                if(self.physic_control[name])then!@#&                                   self.physic_control[name] = to!@#&                              else!@#&                                        error(\"[RedGame]: player -> remapPhysicsControl invalid control!\")!@#&                                end!@#&         end,!@#&!@#&            remapControl = function(self,name,to)!@#&                       for i = 1, #self.controls do!@#&                                if(self.controls[i].name == name)then!@#&                                       self.controls[i].key = to!@#&                           end!@#&                 end!@#&         end,!@#&!@#&            addControl=function(self,controltable)!@#&                      if(type(controltable) ~= \"table\")then!@#&                             error(\"[RedGame]:addControl -> control must be a table in this format: {name=<control name>,event=<event>,key=<key in string format>,func=function() <actions> end}\")!@#&                     else!@#&                                table.insert(self.controls,controltable)!@#&                    end!@#&         end,!@#&!@#&            importControls=function(self,controltable)!@#&                  if(type(controltable) ~= \"table\")then!@#&                             error(\"[RedGame]:importControls -> control must be a table in this format: controls = { {name=<control name>,event=<event>,key=<key in string format>,func=function() <actions> end}, ect... }\")!@#&                  else!@#&                                self.controls = controltable!@#&                        end!@#&         end,!@#&!@#&!@#&                setPos = function(self,x,y)!@#&                 pmap[self.y][self.x] = 0!@#&                    drawMapPixel(self.y,self.x)!@#&                 self.x = x!@#&                  self.y = y!@#&                  self:checkCollision(self.x,self.y)!@#&                  pmap[self.y][self.x] = self.blockid!@#&                 drawMapPixel(self.y,self.x)!@#&         end,!@#&!@#&            update=function(self)!@#&!@#&                   for i = 1, #doors do!@#&                                if(getCurrentMap() == doors[i].fMap and self.x == doors[i].fx and self.y == doors[i].fy)then!@#&                                        setMap(doors[i].tMap)!@#&                                       self:setPos(doors[i].tx,doors[i].ty)!@#&                                end!@#&                 end!@#&!@#&                     if(self.multidir)then!@#&                               pmap[self.y][self.x] = 0!@#&                            drawMapPixel(self.y,self.x)!@#&                         if(not self:checkCollision(self.x+self.hspd,self.y))then!@#&                                    self.x = self.x + self.hspd!@#&                         end!@#&                         if(not self:checkCollision(self.x,self.y+self.vspd))then!@#&                                    self.y = self.y + self.vspd!@#&                         end!@#&                         pmap[self.y][self.x] = self.blockid!@#&                         drawMapPixel(self.y,self.x)!@#&                 end!@#&!@#&                     a = {os.pullEvent()}!@#&!@#&                    for k, v in pairs(self.events) do!@#&                           if(v.type == a[1])then!@#&                                      v.run(a)!@#&                            end!@#&                 end!@#&!@#&                     if(a[1]==\"timer\")then!@#&                             self.physicsTick=os.startTimer(self.tickrate)!@#&                               for k, v in pairs(self.physics) do!@#&                                  if(v.has)then v.func(self) end!@#&                              end!@#&                 end!@#&!@#&                     if(not self.multidir)then!@#&                           for i = 1, #self.controls do!@#&                                        if(a[1] == self.controls[i].event and a[2] == self.controls[i].key)then!@#&                                             self.controls[i].func(self)!@#&                                 end!@#&                         end !@#&                        end!@#&!@#&                     if(self.multidir)then!@#&                                               if(a[2] ~= self.physic_control[\"direction_up\"] and a[2] ~= self.physic_control[\"direction_down\"])then!@#&                                                   self.vspd = 0!@#&                                               end!@#&                                         if(a[2] ~= self.physic_control[\"direction_left\"] and a[2] ~= self.physic_control[\"direction_right\"])then!@#&                                                        self.hspd = 0!@#&                                               end!@#&                                         if(a[2] == self.physic_control[\"direction_up\"])then!@#&                                                       if(self:checkPhysics(\"gravity\"))then!@#&                                                              if(self:checkCollision(self.x,self.y+1))then!@#&                                                                        self.vspd = -self.jump_height!@#&                                                               end!@#&                                                 else!@#&                                                                self.vspd = -self.jump_height!@#&                                                       end!@#&                                         end!@#&                                         if(a[2] == self.physic_control[\"direction_down\"])then!@#&                                                     self.vspd = 1!@#&                                               end!@#&                                         if(a[2] == self.physic_control[\"direction_left\"])then!@#&                                                     self.hspd = -1!@#&                                              end!@#&                                         if(a[2] == self.physic_control[\"direction_right\"])then!@#&                                                    self.hspd = 1!@#&                                               end!@#&                 end!@#&         end,!@#&!@#&    }!@#&!@#&       return player!@#&end",
  14.   },
  15.   maps = {
  16.     MAP04 = "{{16,16,16,2,2,2,10,10,10,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},{16,16,2,2,2,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,0,0,},{16,2,2,2,10,10,0,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,},{16,2,2,10,10,10,0,0,0,19,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,0,},{16,2,2,10,10,10,0,18,0,21,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,0,},{16,2,2,10,10,10,0,19,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,0,},{16,2,2,10,10,10,0,0,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,0,},{2,2,2,10,10,10,0,0,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,16,16,0,},{2,2,2,10,10,10,0,0,21,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{2,2,2,10,10,10,0,0,0,0,18,19,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{2,2,2,10,10,10,0,0,0,0,0,21,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{16,2,2,2,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{16,16,16,2,2,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,0,},{0,0,0,0,16,16,16,16,16,16,16,16,16,0,0,0,0,0,0,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,0,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,0,0,0,0,0,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,0,0,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,16,16,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},}",
  17.     blocks = {
  18.       tileset = "{!@#&  {!@#&    solid = true,!@#&    name = \"Player\",!@#&    color = \"blue\",!@#&    graphic = \"@\",!@#&    bcolor = \"black\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"Dirt\",!@#&    color = \"yellow\",!@#&    graphic = \" \",!@#&    bcolor = \"brown\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"Stone\",!@#&    color = \"lightGray\",!@#&    graphic = \"@\",!@#&    bcolor = \"gray\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"Sand\",!@#&    color = \"white\",!@#&    graphic = \"+\",!@#&    bcolor = \"yellow\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"Scifi\",!@#&    color = \"purple\",!@#&    graphic = \"0\",!@#&    bcolor = \"blue\",!@#&  },!@#&  {!@#&    solid = false,!@#&    name = \"Grass\",!@#&    color = \"green\",!@#&    graphic = \"*\",!@#&    bcolor = \"brown\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"Iron\",!@#&    color = \"white\",!@#&    graphic = \"/\",!@#&    bcolor = \"lightGray\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"Gravel\",!@#&    color = \"white\",!@#&    graphic = \"G\",!@#&    bcolor = \"brown\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"Quartz\",!@#&    color = \"lightGray\",!@#&    graphic = \"X\",!@#&    bcolor = \"white\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"cliff\",!@#&    color = \"gray\",!@#&    graphic = \"#\",!@#&    bcolor = \"brown\",!@#&  },!@#&  {!@#&    solid = false,!@#&    name = \"shore\",!@#&    color = \"blue\",!@#&    graphic = \"*\",!@#&    bcolor = \"yellow\",!@#&  },!@#&  {!@#&    solid = false,!@#&    name = \"sand\",!@#&    color = \"yellow\",!@#&    graphic = \" \",!@#&    bcolor = \"yellow\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"water\",!@#&    color = \"blue\",!@#&    graphic = \" \",!@#&    bcolor = \"blue\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"barrier\",!@#&    color = \"brown\",!@#&    graphic = \"X\",!@#&    bcolor = \"black\",!@#&  },!@#&  {!@#&    solid = false,!@#&    name = \"cave\",!@#&    color = \"black\",!@#&    graphic = \" \",!@#&    bcolor = \"black\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"MazeWall\",!@#&    color = \"gray\",!@#&    graphic = \"=\",!@#&    bcolor = \"black\",!@#&  },!@#&  {!@#&    solid = true,!@#&    name = \"rat\",!@#&    color = \"red\",!@#&    graphic = \"&\",!@#&    bcolor = \"black\",!@#&  },!@#&  {!@#&    solid = false,!@#&    name = \"water\",!@#&    color = \"blue\",!@#&    graphic = \"[\",!@#&    bcolor = \"black\",!@#&  },!@#&  {!@#&    solid = false,!@#&    name = \"food\",!@#&    color = \"brown\",!@#&    graphic = \"*\",!@#&    bcolor = \"black\",!@#&  },!@#&  {!@#&    solid = false,!@#&    name = \"pills\",!@#&    color = \"purple\",!@#&    graphic = \":\",!@#&    bcolor = \"black\",!@#&  },!@#&  {!@#&    solid = false,!@#&    name = \"healthpack\",!@#&    color = \"red\",!@#&    graphic = \"+\",!@#&    bcolor = \"black\",!@#&  },!@#&  [ 0 ] = {!@#&    solid = false,!@#&    name = \"Air\",!@#&    color = \"black\",!@#&    graphic = \" \",!@#&    bcolor = \"black\",!@#&  },!@#&}",
  19.     },
  20.     MAP01 = "{{13,13,13,13,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,13,13,13,},{13,13,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,13,},{13,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,13,},{13,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,13,},{13,6,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,13,},{13,6,6,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,13,},{13,6,6,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,13,},{13,6,6,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,6,13,},{13,6,6,6,6,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,6,6,13,},{13,13,6,6,6,6,6,5,6,6,6,6,6,6,6,10,10,10,10,10,10,6,6,6,6,6,6,6,6,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,6,6,6,13,},{11,13,6,6,6,6,6,6,6,6,6,6,6,6,6,6,10,14,14,10,6,6,6,6,6,6,6,6,6,6,6,10,10,10,10,10,10,10,10,10,10,10,10,6,6,6,6,6,6,6,13,},{11,13,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,10,10,10,10,10,10,10,10,10,6,6,6,6,6,6,6,6,13,},{13,13,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,10,10,10,10,6,6,6,6,6,6,6,6,12,12,13,},{13,11,12,12,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,12,12,12,13,},{13,11,11,12,12,12,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,12,12,12,11,13,13,},{13,13,11,11,11,11,12,12,12,6,6,6,6,6,6,6,6,6,6,6,6,6,6,12,12,12,12,12,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,12,12,12,11,13,13,13,13,},{13,13,13,13,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,6,6,6,6,6,6,12,11,11,13,13,13,13,13,},{13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,13,13,13,13,13,},}",
  21.     MAP03 = "{{14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,},{14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,3,3,3,3,0,0,0,0,0,3,3,0,3,3,0,0,0,0,0,3,3,3,0,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,0,3,3,0,0,0,3,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,0,3,3,3,0,3,3,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,14,},{14,0,0,21,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,0,3,0,3,3,3,0,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,14,},{14,0,0,0,0,18,0,0,0,3,3,3,3,3,3,3,3,0,0,3,3,3,3,3,0,0,0,0,3,0,0,0,0,0,3,0,0,0,3,3,3,3,0,0,0,20,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,0,3,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,3,0,3,3,0,3,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,},{14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,3,0,0,3,0,3,3,3,3,0,0,7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,14,},{14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,},}",
  22.     cavetemplate = "{{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{16,0,0,16,0,0,16,0,0,0,16,0,0,16,0,0,0,16,0,16,0,0,0,0,16,0,0,16,16,0,16,16,0,0,0,16,0,0,0,16,16,0,0,0,16,16,16,0,0,0,16,},{16,0,0,16,0,0,16,0,0,0,0,16,16,0,0,0,0,16,0,16,0,0,0,0,16,0,0,16,0,16,0,16,0,0,16,0,16,0,0,16,16,0,0,0,16,16,0,0,0,0,16,},{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,0,0,0,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,},{16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,0,0,0,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,},{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},}",
  23.     MAP02 = "{{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{16,0,0,16,0,0,16,0,0,0,16,0,0,16,0,0,0,16,0,16,0,0,0,0,16,0,0,16,16,0,16,16,0,0,0,16,0,0,0,16,16,0,0,0,16,16,16,0,0,0,16,},{16,0,0,16,0,0,16,0,0,0,0,16,16,0,0,0,0,16,0,16,0,0,0,0,16,0,0,16,0,16,0,16,0,0,16,0,16,0,0,16,16,0,0,0,16,16,0,0,0,0,16,},{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},{16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,},{16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,},{16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,0,0,0,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,},{16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,16,16,16,0,0,0,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,},{16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,},}",
  24.   },
  25. }
  26.  
  27. local function makeFile(_path, _content)
  28.         local file = fs.open(_path, "w")
  29.         _content = _content:gsub("!@".."#&", "%\n")
  30.         --_content = textutils.unserialize(_content)
  31.         file.write(_content) file.close()
  32. end
  33.  
  34. local function makeFolder(_path, _content)
  35.         fs.makeDir(_path)
  36.         for k,v in pairs(_content) do
  37.                 if type(v) == "table" then
  38.                         makeFolder(_path .. "/" .. k, v)
  39.                 else
  40.                         makeFile(_path .. "/" .. k, v)
  41.                 end
  42.         end
  43. end
  44.  
  45. local sDest = shell.resolve( "Install" ) or "/"
  46. if sDest == "root" then sDest = "/" end
  47. local tPackage = pkg
  48. --makeFolder(sDest, tPackage)
  49.  
  50. sbc = term.setBackgroundColor
  51. stc = term.setTextColor
  52. scp = term.setCursorPos
  53. cl = term.clearLine
  54. doExit = false
  55. w,h = term.getSize()
  56.  
  57. function setup()
  58.         sbc(colors.black)
  59.         term.clear()
  60.         scp(1,1)
  61.         sbc(colors.lightGray)
  62.         cl()
  63.         stc(colors.gray)
  64.         write(string.rep("@",w))
  65.         paintutils.drawFilledBox((w/2) - 15, (h/2) - 5, (w/2) + 15, (h/2) + 8, colors.lightGray )
  66.         paintutils.drawLine((w/2) - 15, (h/2) - 5, (w/2) + 15, (h/2) - 5, colors.gray)
  67.         scp((w/2) - 9, (h/2) - 5)
  68.         stc(colors.white)
  69.         write("The Legend Of Kone")
  70. end
  71.  
  72. function install()
  73.         setup()
  74.         sbc(colors.lightGray)
  75.         scp((w/2) - 15, (h/2) - 3)
  76.         print("Extracting files to path....")
  77.         makeFolder(shell.resolve(path), tPackage)
  78.         sbc(colors.lightGray)
  79.         scp((w/2) - 15, (h/2) - 3)
  80.         print("Files successfully extracted!")
  81.         scp((w/2) - 15, (h/2) - 2)
  82.         print("To launch game run: ")
  83.         scp((w/2) - 12, (h/2) - 1 )
  84.         print(path .. "/launch")
  85.         scp((w/2) - 11, (h/2) + 4 )
  86.         inMenu = true
  87.         opt = {"Launch Game","Exit Installer"}
  88.         selid = 1
  89.         function drawmenu()
  90.                         for i=1, #opt do
  91.                                 scp((w/2) - 11, (h/2) + (3 + i) )
  92.                                 if(selid == i)then
  93.                                         write("[ " .. opt[i] .. " ]")
  94.                                 else
  95.                                         write("  " .. opt[i] .. "  ")
  96.                                 end
  97.                         end
  98.         end
  99.         function updatemenu(ev)
  100.                 if(ev[1] == "key")then
  101.                         if(ev[2] == keys.up and selid > 1)then
  102.                                 selid = selid - 1
  103.                                 drawmenu()
  104.                         end
  105.  
  106.                         if(ev[2] == keys.down and selid < #opt)then
  107.                                 selid = selid + 1
  108.                                 drawmenu()
  109.                         end
  110.  
  111.                         if(ev[2] == keys.enter)then
  112.                                 return selid
  113.                         end
  114.  
  115.                 end
  116.         end
  117.         drawmenu()
  118.         while inMenu and not doExit do
  119.                 ev = {os.pullEvent()}
  120.                 sel = updatemenu(ev)
  121.                 if(sel==1)then
  122.                         inMenu = false
  123.                         sbc(colors.black)
  124.                         stc(colors.white)
  125.                         term.clear()
  126.                         scp(1,1)
  127.                         shell.run(path .."/launch")
  128.                         break                        
  129.                 elseif(sel==2 or doExit)then
  130.                         inMenu = false
  131.                         sbc(colors.black)
  132.                         stc(colors.white)
  133.                         term.clear()
  134.                         scp(1,1)
  135.                         break
  136.                 end
  137.         end
  138. end
  139.  
  140. function doInstall()
  141.         setup()
  142.         sbc(colors.lightGray)
  143.         scp((w/2) - 11, (h/2) - 3)
  144.         print("Install to: " .. path .. "?")
  145.         scp((w/2) - 11, (h/2) - 1)
  146.         print("Game size: 58.2KB")
  147.         scp((w/2) - 14, (h/2) )
  148.         print("Space free: " .. fs.getFreeSpace("/") .. " bytes.")
  149.         inMenu = true
  150.         opt = {"Yes","No"}
  151.         selid = 2
  152.         function drawmenu()
  153.                         for i=1, #opt do
  154.                                 scp((w/2) - 11, (h/2) + (3 + i) )
  155.                                 if(selid == i)then
  156.                                         write("[ " .. opt[i] .. " ]")
  157.                                 else
  158.                                         write("  " .. opt[i] .. "  ")
  159.                                 end
  160.                         end
  161.         end
  162.         function updatemenu(ev)
  163.                 if(ev[1] == "key")then
  164.                         if(ev[2] == keys.up and selid > 1)then
  165.                                 selid = selid - 1
  166.                                 drawmenu()
  167.                         end
  168.  
  169.                         if(ev[2] == keys.down and selid < #opt)then
  170.                                 selid = selid + 1
  171.                                 drawmenu()
  172.                         end
  173.  
  174.                         if(ev[2] == keys.enter)then
  175.                                 return selid
  176.                         end
  177.  
  178.                 end
  179.         end
  180.         drawmenu()
  181.         while inMenu do
  182.                 ev = {os.pullEvent()}
  183.                 sel = updatemenu(ev)
  184.                 if(sel==1)then
  185.                         inMenu = false
  186.                         install()
  187.                         doExit = true
  188.                         break
  189.                 elseif(sel==2)then
  190.                         inMenu = false
  191.                         getPath()
  192.                         doExit = true
  193.                         break
  194.                 elseif(sel==3)then
  195.                         inMenu = false
  196.                         sbc(colors.black)
  197.                         stc(colors.white)
  198.                         term.clear()
  199.                         scp(1,1)
  200.                         doExit = true
  201.                         break
  202.                 end
  203.         end
  204. end
  205.  
  206. function getPath()
  207.         setup()
  208.         sbc(colors.lightGray)
  209.         scp((w/2) - 11, (h/2) - 3)
  210.         print("Enter an install path.")
  211.         scp((w/2) - 12, (h/2) - 1)
  212.         sbc(colors.gray)
  213.         write(string.rep(" ",24))
  214.         sbc(colors.lightGray)
  215.         scp((w/2) - 12, (h/2) - 1)
  216.         sbc(colors.gray)
  217.         if(not doExit)then path = read() end
  218.         sbc(colors.lightGray)
  219.         inMenu = false
  220.         opt = {"Yes","No"}
  221.         selid = 1
  222.  
  223.         if(not fs.isDir(path))then
  224.                 inMenu = true
  225.                  scp((w/2) - 15, (h/2) + 2)
  226.                  print("No such directory, create it?")
  227.                 function drawmenu()
  228.                      for i=1, #opt do
  229.                         scp((w/2) - 11, (h/2) + (3 + i) )
  230.                             if(selid == i)then
  231.                                  write("[ " .. opt[i] .. " ]")
  232.                             else
  233.                                  write("  " .. opt[i] .. "  ")
  234.                             end
  235.                      end
  236.                 end
  237.                 function updatemenu(ev)
  238.                         if(ev[1] == "key")then
  239.                                 if(ev[2] == keys.up and selid > 1)then
  240.                                         selid = selid - 1
  241.                                         drawmenu()
  242.                                 end
  243.          
  244.                                 if(ev[2] == keys.down and selid < #opt)then
  245.                                         selid = selid + 1
  246.                                         drawmenu()
  247.                                 end
  248.          
  249.                                 if(ev[2] == keys.enter)then
  250.                                         return selid
  251.                                 end
  252.          
  253.                         end
  254.                 end
  255.                 drawmenu()
  256.                 while inMenu and not doExit do
  257.                         ev = {os.pullEvent()}
  258.                         sel = updatemenu(ev)
  259.                         if(sel==1)then
  260.                                 inMenu = false
  261.                                 fs.makeDir(path)
  262.                                 doInstall()
  263.                                 break
  264.                         elseif(sel==2)then
  265.                                 inMenu = false
  266.                                 getPath()
  267.                                 break
  268.                         elseif(sel==3)then
  269.                                 inMenu = false
  270.                                 sbc(colors.black)
  271.                                 stc(colors.white)
  272.                                 term.clear()
  273.                                 scp(1,1)
  274.                                 break
  275.                         end
  276.                 end
  277.                 getPath()
  278.         end
  279.         scp((w/2) - 11, (h/2) + 1 )
  280.         print("Press Any Key")
  281.         os.pullEvent("key")
  282.         doInstall()
  283. end
  284.  
  285. getPath()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement