Advertisement
MisterNoNameLP

ocCraft_v0.1.2_setup.lua

Sep 11th, 2019
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 237.71 KB | None | 0 0
  1. local licenseNotice = [[This installation script is createt by MisterNoNameLPs OC project exporter v1.0.4
  2. <https://github.com/MisterNoNameLP/ocCraft/blob/master/src/debug/export.lua>.
  3.  
  4. This installer DO NOT give ANY WARRANTY for stored/installed data.
  5. All stored/installed data are third party content i am not responsible for.
  6.  
  7.     export Copyright (C) 2019 MisterNoNameLP.
  8.    
  9.     This program is free software: you can redistribute it and/or modify
  10.     it under the terms of the GNU General Public License as published by
  11.     the Free Software Foundation, either version 3 of the License, or
  12.     (at your option) any later version.
  13.  
  14.     This program is distributed in the hope that it will be useful,
  15.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.     GNU General Public License for more details.
  18.  
  19.     You should have received a copy of the GNU General Public License
  20.     along with this program.  If not, see <https://www.gnu.org/licenses/>.
  21. ]]
  22. local data = {["//libs/tl.lua"] = "local t = {t = 1}\13\n\13\nprint(\"t\")\13\n\13\nreturn t",["//libs/ocl.lua"] = "--[[\13\n    ocl Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This library is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    This library is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with this library.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\n--ToDo: make it object oriented.\13\n\13\nlocal ocl = { version = \"v1.1\",\13\n\9conf = {\13\n\9\9logFile = \"logs/occ.log\",\13\n\9\9backups = false,\13\n\9},\13\n\9\13\n\9logFile = {},\13\n}\13\n\13\nlocal filesystem = require(\"filesystem\")\13\nlocal shell = require(\"shell\")\13\nlocal ut = require(\"libs/UT\")\13\n\13\nfunction ocl.open(path)\13\n\9if path ~= nil then\13\n\9\9ocl.conf.logFile = path\13\n\9end\13\n\9local dir, fileName, fileEnd = ut.seperatePath(ocl.conf.logFile)\13\n\9fileEnd = fileEnd or \"\"\13\n\9if string.sub(ocl.conf.logFile, 0, 1) ~= \"/\" then\13\n\9\9dir = shell.getWorkingDirectory() .. \"/\" .. dir\13\n\9end\13\n\9filesystem.makeDirectory(dir)\13\n\9\13\n\9local file = nil\13\n\9if ocl.conf.backups then\13\n\9\9file = io.open(dir .. fileName .. fileEnd, \"r\")\13\n\9end\13\n\9if file == nil or not ocl.conf.backups then\13\n\9\9ocl.logFile = io.open(dir .. fileName .. fileEnd, \"w\")\13\n\9else\13\n\9\9file:close()\13\n\9\9local count = 1\13\n\9\9while true do\13\n\9\9\9file = io.open(dir .. fileName .. \"(\" .. tostring(count) .. \")\" .. fileEnd, \"r\")\13\n\9\9\9if file == nil then\13\n\9\9\9\9ocl.logFile = io.open(dir .. fileName .. \"(\" .. tostring(count) .. \")\" .. fileEnd, \"w\")\13\n\9\9\9\9break\13\n\9\9\9end\13\n\9\9\9file:close()\13\n\9\9\9count = count +1\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction ocl.add(...)\13\n\9local text = \"\"\13\n\9for _, s in ipairs({...}) do\13\n\9\9text = text .. tostring(s)\13\n\9end\13\n\9ocl.logFile:write(tostring(text))\13\n\9ocl.logFile:write(\"\\n\")\13\n\9ocl.logFile:flush()\13\nend\13\n\13\nfunction ocl.close()\13\n\9ocl.logFile:close()\13\nend\13\n\13\nreturn ocl",["//libs/ocgl.lua"] = "--[[\13\n    ocgf Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This library is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    This library is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with this library.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal OCGL = {version = \"v1.3.2\"} --OpenComputersGraphicLibary\13\nOCGL.__index = OCGL\13\n\13\n\13\n--===== local vars =====--\13\nlocal tmpTexture = {\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.2\",\13\n\9drawCalls = {},\13\n}\13\nlocal computer = require(\"computer\")\13\n\13\n--===== local functions =====--\13\nlocal function addFrameTime(this, dt, backwards)\13\n\9this.lastFrame = this.currentFrame\13\n\9this.currentFrame = (this.currentFrame + (dt * this.speed))\13\nend\13\n\13\nlocal function parseArgs(...) --ripped from UT_v0.6\13\n\9for _, a in pairs({...}) do\13\n\9\9if a ~= nil then\13\n\9\9\9return a\13\n\9\9end\13\n\9end\13\nend\13\n\13\nlocal function parseLink(this, posX, posY, v, func, ...)\13\n\9if #v == 1 then\13\n\9\9tmpTexture.drawCalls = v[1]\13\n\9\9func(this, posX, posY, tmpTexture, ...)\13\n\9else\13\n\9\9tmpTexture.drawCalls = v[3]\13\n\9\9func(this, posX + v[1], posY + v[2], tmpTexture, ...)\13\n\9end\13\n\9tmpTexture.drawCalls = {}\13\nend\13\n\13\n--===== global functions =====--\13\nfunction OCGL.initiate(gpu)\13\n\9local this = setmetatable({}, OCGL)\13\n\9\13\n\9this.gpu = gpu\13\n\9this.resX, this.resY = gpu.getResolution()\13\n\9this.pFColor, this.pBColor = gpu.getForeground(), gpu.getBackground()\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCGL.draw(this, posX, posY, texture, checkColor)\13\n\9if checkColor == nil or checkColor == true then\13\n\9\9this.pFColor, this.pBColor = this.gpu.getForeground(), this.gpu.getBackground()\13\n\9end\13\n\9\13\n\9for c, v in ipairs(texture.drawCalls or texture) do \13\n\9\9if #v == 1 or type(v[3]) == \"table\" then --link\13\n\9\9\9parseLink(this, posX, posY, v, OCGL.draw, checkColor)\13\n\9\9elseif #v == 3 or #v == 4 then --set\13\n\9\9\9if v[1] +posX <= this.resX and v[2] +posY <= this.resY then\13\n\9\9\9\9if v[4] and v[1] +posX >= 0 and v[2] +posY +#v[3] >= 0 then\13\n\9\9\9\9\9this.gpu.set(v[1] +posX, v[2] +posY, v[3], v[4])\13\n\9\9\9\9elseif v[2] +posY >= 0 and v[1] +posX +#v[3] >= 0 then\13\n\9\9\9\9\9this.gpu.set(v[1] +posX, v[2] +posY, v[3])\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9elseif #v == 5 then --fill\13\n\9\9\9if v[1] +posX <= this.resX and v[2] +posY <= this.resY and v[1] +v[3] +posX >= 0 and v[2] +v[4] +posY >= 0 then\13\n\9\9\9\9this.gpu.fill(v[1] +posX, v[2] +posY, v[3], v[4], v[5])\13\n\9\9\9end\13\n\9\9else --color change\13\n\9\9\9if v[1] == \"b\" and v[2] ~= this.pBColor then\13\n\9\9\9\9this.gpu.setBackground(v[2])\13\n\9\9\9elseif v[1] == \"f\" and v[2] ~= this.pFColor then\13\n\9\9\9\9this.gpu.setForeground(v[2])\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\nend\13\n\13\nfunction OCGL.clearBlack(this, posX, posY, texture, color)\13\n\9this.gpu.setBackground(color or 0x000000)\13\n\9this.gpu.setForeground(color or 0x000000)\13\n\9for c, v in ipairs(texture.drawCalls or texture) do\13\n\9\9if #v == 1 or type(v[3]) == \"table\" then --link\13\n\9\9\9parseLink(this, posX, posY, v, OCGL.clearBlack, color)\13\n\9\9elseif #v == 3 or #v == 4 then\13\n\9\9\9this.gpu.set(v[1] +posX, v[2] +posY, v[3])\13\n\9\9elseif #v == 5 then\13\n\9\9\9this.gpu.fill(v[1] +posX, v[2] +posY, v[3], v[4], \" \")\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCGL.generateTexture(...)\13\n\9local t = {}\13\n\9if type(...) ~= \"table\" then\13\n\9\9t = {...}\13\n\9else\13\n\9\9t = ...\13\n\9end\13\n\9if #t == 5 then\13\n\9\9return {textureFormat = \"OCGLT\", version = \"v0.1\", drawCalls = {{\"f\", t[1]}, {\"b\", t[2]}, {0, 0, t[3], t[4], t[5]}}}\13\n\9elseif #t == 3 or #t == 4 then\13\n\9\9return {textureFormat = \"OCGLT\", version = \"v0.1\", drawCalls = {{\"f\", t[1]}, {\"b\", t[2]}, {0, 0, t[3], t[4] or false}}}\13\n\9else\13\n\9\9return {textureFormat = \"OCGLT\", version = \"v0.1\", drawCalls = {}}\13\n\9end\13\nend\13\n\13\nfunction OCGL.getColors(t, n)\13\n\9local fColor, bColor = nil, nil\13\n\9for c = n, 1, -1 do\13\n\9\9if t.drawCalls[c][1] == \"f\" and fColor == nil then\13\n\9\9\9fColor = t.drawCalls[c][2]\13\n\9\9end\13\n\9\9if t.drawCalls[c][1] == \"b\" and bColor == nil then\13\n\9\9\9bColor = t.drawCalls[c][2]\13\n\9\9end\13\n\9end\13\n\9return {\"f\", fColor or 0x000000}, {\"b\", bColor or 0x000000}\13\nend\13\n\13\nfunction OCGL.clear(this, posX, posY, texture, backgroundTextures, checkOverlap) --ToDo: add \"OCGLT_v0.2\" support.\13\n\9if backgroundTextures == nil then\13\n\9\9this.clearBlack(this, posX, posY, texture)\13\n\9\9return\13\n\9end\13\n\9if checkOverlap == nil then\13\n\9\9checkOverlap = true\13\n\9end\13\n\9\13\n\9--local write = function(...) io.write(tostring(...)) end --Debug\13\n\9--local serialization = require(\"serialization\") --Debug\13\n\9\13\n\9local toDraw = {drawCalls = {}}\13\n\9local toCheck = {}\13\n\9local isCheckt = {}\13\n\9local pFColor, pBColor = nil, nil\13\n\9local fColor, bColor = nil, nil\13\n\9\13\n\9for c = 1, #backgroundTextures do\13\n\9\9isCheckt[c] = {}\13\n\9end\13\n\9\13\n\9local function SetCall(btdc, bt, c, c2)\13\n\9\9if toDraw[c] == nil then\13\n\9\9\9toDraw[c] = {}\13\n\9\9\9\13\n\9\9\9for c2 = 1, #bt[3].drawCalls, 1 do\13\n\9\9\9\9toDraw[c][c2] = {}\13\n\9\9\9end\13\n\9\9end\13\n\9\9\13\n\9\9if #btdc == 3 or #btdc == 4 then\13\n\9\9\9toDraw[c][c2] = {btdc[1] +bt[1], btdc[2] +bt[2], btdc[3], btdc[4]}\13\n\9\9elseif #btdc == 5 then\13\n\9\9\9toDraw[c][c2] = {btdc[1] +bt[1], btdc[2] +bt[2], btdc[3], btdc[4], btdc[5]}\13\n\9\9end\13\n\9\9\13\n\9\9if checkOverlap then\13\n\9\9\9table.insert(toCheck, {btdc, bt[1], bt[2]})\13\n\9\9end\13\n\9\9\13\n\9\9isCheckt[c][c2] = true\13\n\9end\13\n\9\13\n\9if checkOverlap then\13\n\9\9local old = SetCall\13\n\9\9SetCall = function(btdc, bt, c, c2)\13\n\9\9\9old(btdc, bt, c, c2)\13\n\9\9\9toDraw[c][c2].bc = fColor\13\n\9\9\9toDraw[c][c2].fc = bColor\13\n\9\9end\13\n\9else\13\n\9\9local old = SetCall\13\n\9\9SetCall = function(btdc, bt, c, c2)\13\n\9\9\9old(btdc, bt, c, c2)\13\n\9\9\9if fColor ~= pFColor then\13\n\9\9\9\9toDraw[c][c2].bc = fColor\13\n\9\9\9\9pFColor = fColor\13\n\9\9\9end\13\n\9\9\9if bColor ~= pBColor then\13\n\9\9\9\9toDraw[c][c2].fc = bColor\13\n\9\9\9\9pBColor = bColor\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9local function CheckOverlab(dc, backgroundTextures, posX, posY)\13\n\9\9for c, bt in ipairs(backgroundTextures) do\13\n\9\9\9for c2, btdc in ipairs(bt[3].drawCalls or bt[3]) do\13\n\9\9\9\9if isCheckt[c][c2] ~= true then\13\n\9\9\9\9\9if #btdc == 3 or #btdc == 4 then\13\n\9\9\9\9\9\9if #dc == 3 or #dc == 4 then\13\n\9\9\9\9\9\9\9if dc[1] +posX < btdc[1] +bt[1] +#btdc[3] and dc[1] +posX +#dc[3] > btdc[1] +bt[1] and dc[2] +posY == btdc[2] +bt[2] then\13\n\9\9\9\9\9\9\9\9SetCall(btdc, bt, c, c2)\13\n\9\9\9\9\9\9\9end\13\n\9\9\9\9\9\9elseif #dc == 5 then\13\n\9\9\9\9\9\9\9if dc[1] +posX < btdc[1] +bt[1] +#btdc[3] and dc[1] +posX +dc[3] > btdc[1] +bt[1] and dc[2] +posY <= btdc[2] +bt[2] and dc[2] +posY +dc[4] > btdc[2] +bt[2] then\13\n\9\9\9\9\9\9\9\9SetCall(btdc, bt, c, c2)\13\n\9\9\9\9\9\9\9end\9\13\n\9\9\9\9\9\9end\13\n\9\9\9\9\9elseif #btdc == 5 then\13\n\9\9\9\9\9\9if #dc == 3 or #dc == 4 then\13\n\9\9\9\9\9\9\9if dc[1] +posX < btdc[1] +bt[1] +btdc[3] and dc[1] +posX +#dc[3] > btdc[1] +bt[1] and dc[2] +posY < btdc[2] +bt[2] +btdc[4] and dc[2] +posY > btdc[2] +bt[2] then\13\n\9\9\9\9\9\9\9\9SetCall(btdc, bt, c, c2)\13\n\9\9\9\9\9\9\9end\13\n\9\9\9\9\9\9elseif #dc == 5 then\13\n\9\9\9\9\9\9\9if dc[1] +posX < btdc[1] +bt[1] +btdc[3] and dc[1] +posX +dc[3] > btdc[1] +bt[1] and dc[2] +posY < btdc[2] +bt[2] +btdc[4] and dc[2] +posY +dc[4] > btdc[2] +bt[2] then\13\n\9\9\9\9\9\9\9\9SetCall(btdc, bt, c, c2)\13\n\9\9\9\9\9\9\9end\13\n\9\9\9\9\9\9end\13\n\9\9\9\9\9else\13\n\9\9\9\9\9\9if btdc[1] == \"f\" then\13\n\9\9\9\9\9\9\9fColor = btdc\13\n\9\9\9\9\9\9end\13\n\9\9\9\9\9\9if btdc[1] == \"b\" then\13\n\9\9\9\9\9\9\9bColor = btdc\13\n\9\9\9\9\9\9end\13\n\9\9\9\9\9end\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9for c, dc in ipairs(texture.drawCalls) do\13\n\9\9CheckOverlab(dc, backgroundTextures, posX, posY)\13\n\9end\13\n\9\13\n\9if checkOverlap then\13\n\9\9for c, tc in ipairs(toCheck) do\13\n\9\9\9CheckOverlab(tc[1], backgroundTextures, tc[2], tc[3])\13\n\9\9end\13\n\9end\13\n\9\13\n\9local graphic = {drawCalls = {}}\13\n\9for c, v in pairs(toDraw) do\13\n\9\9for c, v2 in pairs(v) do\13\n\9\9\9if #v2 ~= 0 then\13\n\9\9\9\9table.insert(graphic.drawCalls, v2.fc)\13\n\9\9\9\9table.insert(graphic.drawCalls, v2.bc)\13\n\9\9\9\9table.insert(graphic.drawCalls, v2)\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9this:draw(0, 0, graphic)\13\n\9this.gpu.setForeground(0xffffff)\13\n\9--write(#graphic.drawCalls .. \" \")\13\n\9\13\nend\13\n\13\nfunction OCGL.convertToPixels(this, g, s) --WIP\13\n\9local newG = {}\13\n\9local oNewG = {}\13\n\9s = s or 1\13\n\9\13\n\9for c, v in ipairs(g.drawCalls) do\13\n\9\9if #v == 3 or #v == 4 then\13\n\9\9\9for c = 1, #v[3], s do\13\n\9\9\9\9newG[#newG +1] = {v[1] +c, v[2], string.sub(v[3], c, c +s -1), v[4]}\13\n\9\9\9end\13\n\9\9elseif #v == 5 then\13\n\9\9\9local fillString = \"\"\13\n\9\9\9for c = 1, s, 1 do\13\n\9\9\9\9fillString = fillString .. v[5]\13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9for c = 1, v[4], 1 do\13\n\9\9\9\9for c2 = 1, v[3], s do\13\n\9\9\9\9\9local tm = c2 +#fillString - v[3]\13\n\9\9\9\9\9if tm < 0 then\13\n\9\9\9\9\9\9tm = 0\13\n\9\9\9\9\9end\13\n\9\9\9\9\9newG[#newG +1] = {v[1] +c2, v[2] +c -1, string.sub(fillString, tm)}\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9else\13\n\9\9\9newG[#newG +1] = v\13\n\9\9end\13\n\9end\13\n\9\13\n\9local count = 0\13\n\9for c, v in ipairs(newG) do\13\n\9\9count = count +1\13\n\9\9if count > 1000 then\13\n\9\9\9os.sleep()\13\n\9\9\9count = 0\13\n\9\9end\13\n\9\9\13\n\9\9if #v ~= 2 then\13\n\9\9\9local set = true\13\n\9\9\9\13\n\9\9\9for c2 = c +1, #newG, 1 do\13\n\9\9\9\9if #newG[c2] ~= 2 and v[2] == newG[c2][2] then\13\n\9\9\9\9\9if v[1] == newG[c2][1] or v[1] > newG[c2][1] and v[1] +#v[3] < newG[c2][1] +#newG[c2][3] then\13\n\9\9\9\9\9\9set = false\13\n\9\9\9\9\9\9break\13\n\9\9\9\9\9end\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9if set then\13\n\9\9\9\9oNewG[#oNewG +1] = v\13\n\9\9\9end\13\n\9\9else\13\n\9\9\9oNewG[#oNewG +1] = v\13\n\9\9end\13\n\9end \13\n\9\13\n\9return {textureFormat = \"OCGLT\", version = \"v0.1\", drawCalls = oNewG}\13\nend \13\n\13\n\13\n\13\nfunction OCGL.convertToRaster(this, g, s) --WIP\13\n\9local newG = {}\13\n\9s = s or 1\13\n\9\13\n\9for c, v in ipairs(g.drawCalls) do\13\n\9\9if #v == 3 or #v == 4 then\13\n\9\9\9\13\n\9\9\9\13\n\9\9\9\13\n\9\9elseif #v == 5 then\13\n\9\9\9\13\n\9\9else\13\n\9\9\9\13\n\9\9end\13\n\9end\13\n\9\13\n\9return {textureFormat = \"OCGLTT\", version = \"v0.1\", drawCalls = newG}\13\nend\13\n\13\n\13\n--===== animator =====-- --WIP\13\nOCGL.Animation = {}\13\nOCGL.Animation.__index = OCGL.Animation\13\n\13\nfunction OCGL.Animation.new(ocgl, animation, args) --no ocgl...\13\n\9this = setmetatable({}, OCGL.Animation)\13\n\9\13\n\9args = args or {}\13\n\9this.ocgl = ocgl\13\n\9\13\n\9this.animation = animation\13\n\9this.speed = args.speed or 1\13\n\9this.useDt = parseArgs(args.dt, true)\13\n\9this.clear = parseArgs(args.clear, true)\13\n\9this.background = args.background\13\n\9this.halt = parseArgs(args.halt, false)\13\n\9this.tmpHalt = false\13\n\9\13\n\9this.currentFrame = args.frame or 1\13\n\9this.lastFrame = this.currentFrame\13\n\9this.lastCall = 0 --time in sec.\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCGL.Animation.draw(this, posX, posY, dt, clear, background)\13\n\9if parseArgs(clear, this.clear) then\13\n\9\9background = parseArgs(background, this.background)\13\n\9\9if background == nil or type(background) == \"number\" then\13\n\9\9\9this:clearBlack(posX, posY, false, background)\13\n\9\9else\13\n\9\9\9this:clear(posX, posY, background, true, false)\13\n\9\9end\13\n\9end\13\n\9\13\n\9this.ocgl:draw(posX, posY, this.animation.frames[math.floor(this.currentFrame)])\13\n\9\13\n\9if parseArgs(dt, this.dt) == false then\13\n\9\9addFrameTime(this, 1, backwards)\13\n\9\9return\13\n\9end\13\n\9\13\n\9if dt == nil or dt == true then\13\n\9\9dt = computer.uptime() - this.lastCall\13\n\9\9this.lastCall = computer.uptime()\13\n\9end\13\n\9\13\n\9addFrameTime(this, (dt / this.animation.frameTime), backwards)\13\n\9\13\n\9if math.floor(this.currentFrame) > #this.animation.frames then\13\n\9\9this.currentFrame = 1\13\n\9\9if this.halt or this.tmpHalt then\13\n\9\9\9this.speed = 0\13\n\9\9\9this.tmpHalt = false\13\n\9\9end\13\n\9elseif math.floor(this.currentFrame) < 1 then\13\n\9\9this.currentFrame = #this.animation.frames +.9\13\n\9\9if this.halt or this.tmpHalt then\13\n\9\9\9this.speed = 0\13\n\9\9\9this.currentFrame = 1\13\n\9\9\9this.tmpHalt = false\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCGL.Animation.clearBlack(this, posX, posY, current, color)\13\n\9if current == true then\13\n\9\9this.ocgl:clearBlack(posX, posY, this.animation.frames[math.floor(this.currentFrame)], color)\13\n\9elseif current == false then\13\n\9\9this.ocgl:clearBlack(posX, posY, this.animation.frames[math.floor(this.lastFrame)], color)\13\n\9else\13\n\9\9this.ocgl:clearBlack(posX, posY, this.animation.frames[math.floor(this.currentFrame)], color)\13\n\9\9this.ocgl:clearBlack(posX, posY, this.animation.frames[math.floor(this.lastFrame)], color)\13\n\9end\13\nend\13\n\13\nfunction OCGL.Animation.clear(this, posX, posY, textures, checkOverlap, current) --useless yet (not supporting \"OCGLT_v0.2\"/\"OCGLA_v0.1\".)\13\n\9if current then\13\n\9\9this.ocgl:clear(posX, posY, this.animation.frames[math.floor(this.currentFrame)], textures, checkOverlap)\13\n\9else\13\n\9\9this.ocgl:clear(posX, posY, this.animation.frames[math.floor(this.lastFrame)], textures, checkOverlap)\13\n\9end\13\nend\13\n\13\nfunction OCGL.Animation.start(this, speed, frame)\13\n\9this.speed = speed or 1\13\n\9this.currentFrame = frame or 1\13\n\9this.tmpHalt = false\13\nend\13\n\13\nfunction OCGL.Animation.stop(this, frame, playTilEnd)\13\n\9if playTilEnd then\13\n\9\9this.tmpHalt = true\13\n\9else\13\n\9\9this.speed = 0\13\n\9\9this.frame = frame or 1\13\n\9end\13\nend\13\n\13\nfunction OCGL.Animation.pause(this)\13\n\9this.speed = 0\13\nend\13\n\13\nfunction OCGL.Animation.play(this, speed)\13\n\9this.speed = speed or 1\13\n\9this.tmpHalt = false\13\nend\13\n\13\n\13\nreturn OCGL\13\n\13\n--print(string.sub(\"1234567890\", 0, #\"1234567890\" -3))\13\n--print(string.sub(\"1234567890\", #\"1234567890\" -3 +1))\13\n\13\n\13\n\13\n\13\n\13\n",["//libs/ocui.lua"] = "--[[\13\n    ocui Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This library is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    This library is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with this library.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal OCUI = {version = \"v1.4.6\"}\13\nOCUI.__index = OCUI\13\n\13\n--[[ToDo:\13\n\9add color check arg on draw calls.\13\n\9rework the initialisation routines (better args etc.).\13\n\9add dynamic ui generation (no texture).\13\n]]--\13\n\13\nfunction OCUI.initiate(ocgl, onError)\13\n\9local this = setmetatable({}, OCUI)\13\n\9this.event = require(\"event\")\13\n\9this.ocgl = ocgl\13\n\9\13\n\9this.updateList = {} --list of managed buttons\13\n\9this.updateCount = 0\13\n\9this.drawList = {} --list of managed buttons\13\n\9this.drawCount = 0\13\n\9this.stopList = {}\13\n\9this.stopCount = 0\13\n\9\13\n\9this.globalStop = false --to avoid stopList cleaning by iterate it.\13\n\9\13\n\9this.onError = onError or function() end\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCUI.stop(this) --dont ignor\13\n\9this.globalStop = true\13\n\9for c, v in ipairs(this.stopList) do\13\n\9\9if v ~= nil then\13\n\9\9\9v:stop()\13\n\9\9end\13\n\9end\13\n\9this.globalStop = false\13\nend\13\n\13\nfunction OCUI.update(this, x, y)\13\n\9for c, v in ipairs(this.updateList) do\13\n\9\9v:update(x, y)\13\n\9end\13\nend\13\n\13\nfunction OCUI.draw(this)\13\n\9for c, v in ipairs(this.drawList) do\13\n\9\9v:draw(x, y)\13\n\9end\13\nend\13\n\13\nfunction OCUI.listAutoManage(object, args) --ToDo: needs to work with value index instead of numeretic index.\13\n\9local managed = {}\13\n\9managed[1] = args.update\13\n\9managed[2] = args.draw\13\n\9managed[3] = args.stop\13\n\9\13\n\9if managed[1] or managed[1] == nil then\13\n\9\9object.ocui.updateCount = object.ocui.updateCount +1\13\n\9\9object.ocui.updateList[object.ocui.updateCount] = object\13\n\9\9object.updateListPos = object.ocui.updateCount\13\n\9end\13\n\9if managed[2] or managed[2] == nil then\13\n\9\9object.ocui.drawCount = object.ocui.drawCount +1\13\n\9\9object.ocui.drawList[object.ocui.drawCount] = object\13\n\9\9object.drawListPos = object.ocui.drawCount\13\n\9end\13\n\9if managed[3] or managed[3] == nil then\13\n\9\9object.ocui.stopCount = object.ocui.stopCount +1\13\n\9\9object.ocui.stopList[object.ocui.stopCount] = object\13\n\9\9object.stopListPos = object.ocui.stopCount\13\n\9end\13\nend\13\n\13\nfunction OCUI.ignoreAutoManage(object)\13\n\9if object.updateListPos ~= nil then\13\n\9\9table.remove(object.ocui.updateList, object.updateListPos)\13\n\9\9object.ocui.updateCount = object.ocui.updateCount -1\13\n\9\9for c = object.updateListPos, #object.ocui.updateList, 1 do\13\n\9\9\9object.ocui.updateList[c].updateListPos = object.ocui.updateList[c].updateListPos -1\13\n\9\9end\13\n\9end\13\n\9if object.drawListPos ~= nil then\13\n\9\9table.remove(object.ocui.drawList, object.drawListPos)\13\n\9\9object.ocui.drawCount = object.ocui.drawCount -1\13\n\9\9for c = object.drawListPos, #object.ocui.drawList, 1 do\13\n\9\9\9object.ocui.drawList[c].drawListPos = object.ocui.drawList[c].drawListPos -1\13\n\9\9end\13\n\9end\13\n\9if object.stopListPos ~= nil then\13\n\9\9if object.ocui.globalStop == false then\13\n\9\9\9table.remove(object.ocui.stopList, object.stopListPos)\13\n\9\9\9object.ocui.stopCount = object.ocui.stopCount -1\13\n\9\9\9for c = object.stopListPos, #object.ocui.stopList, 1 do\13\n\9\9\9\9object.ocui.stopList[c].stopListPos = object.ocui.stopList[c].stopListPos -1\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\nend\13\n\13\n\13\n--===== TextBox =====--\13\nOCUI.TextBox = {widgetType = \"TextBox\"}\13\nOCUI.TextBox.__index = OCUI.TextBox\13\n\13\nfunction OCUI.TextBox.new(ocui, args)\13\n\9local this = setmetatable({}, OCUI.TextBox)\13\n\9\13\n\9this.ut = require(\"libs/UT\")\13\n\9\13\n\9args = args or {}\13\n\9\13\n\9this.posX = args.posX or args.x\13\n\9this.posY = args.posY or args.y\13\n\9this.sizeX = args.sizeX or args.sx\13\n\9this.sizeY = args.sizeY or args.sy\13\n\9this.lineBreak = args.lineBreak or false\13\n\9this.cfg_foregroundColor = args.foregroundColor or 0xaaaaaa\13\n\9this.cfg_backgroundColor = args.backgroundColor or 0x555555\13\n\9this.content = {}\13\n\9OCUI.TextBox.addContent(this, OCUI.TextBox.getContent(this, args.content, args.sizeX, this.lineBreak))\13\n\9--[[ or OCUI.TextBox.getContent(\13\n\9\9{args.text or \"\"},\13\n\9\9args.sizeX,\13\n\9\9args.lineBreak or false\13\n\9)]]\13\n\9\13\n\9this.ocui = ocui\13\n\9\13\n\9if this.sizeX == nil or this.sizeY == nil then\13\n\9\9return false, \"No sizeX or sizeY given\"\13\n\9end\13\n\9if this.posX == nil or this.posY == nil then\13\n\9\9return false, \"No posX or posY given\"\13\n\9end\13\n\9\13\n\9if args.managed ~= nil then\13\n\9\9args.managed.update = false\13\n\9end\13\n\9ocui.listAutoManage(this, args.managed or {update = false})\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCUI.TextBox.getContent(this, text, length, lineBreak)\13\n\9local content = {}\13\n\9local index = 1\13\n\9if type(text) ~= \"table\" then\13\n\9\9text = {text}\13\n\9end\13\n\9for _, t in ipairs(text) do\13\n\9\9\13\n\9\9for s in string.gmatch(tostring(t), \"[^\\r\\n]+\") do\13\n\9\9\9s = string.gsub(s, \"\\t\", \"     \")\13\n\9\9\9\13\n\9\9\9if #s > length then\13\n\9\9\9\9if lineBreak then\13\n\9\9\9\9\9table.insert(text, #text +1, string.sub(s, length))\13\n\9\9\9\9end\13\n\9\9\9\9s = string.sub(s, 0, length)\13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9content[index] = this.ut.fillString(s, length - #s, \" \")\13\n\9\9\9index = index +1\13\n\9\9end\13\n\9end\13\n\9\13\n\9return content\13\nend\13\n\13\nfunction OCUI.TextBox.addContent(this, content)\13\n\9for _, c in ipairs(content) do\13\n\9\9\13\n\9\9for s in string.gmatch(tostring(c), \"[^\\r\\n]+\") do\13\n\9\9\9s = string.gsub(s, \"\\t\", \"     \")\13\n\9\9\9--table.insert(this.content, s)\13\n\9\9end\13\n\9\9table.insert(this.content, c)\13\n\9end\13\n\9if #this.content > this.sizeY then\13\n\9\9local tmpContent = {}\13\n\9\9for c = #this.content -this.sizeY +1, #this.content do\13\n\9\9\9table.insert(tmpContent, this.content[c])\13\n\9\9end\13\n\9\9this.content = tmpContent\13\n\9end\13\nend\13\n\13\nfunction OCUI.TextBox.add(this, ...)\13\n\9local text = \"\"\13\n\9for _, s in ipairs({...}) do\13\n\9\9text = text .. tostring(s) .. \"     \"\13\n\9end\13\n\9this:addContent(this:getContent({text}, this.sizeX, this.lineBreak))\13\nend\13\n\13\nfunction OCUI.TextBox.update(this, ...)\9\13\n\9\13\nend\13\n\13\nfunction OCUI.TextBox.draw(this)\13\n\9local gpu = this.ocui.ocgl.gpu\13\n\9\13\n\9gpu.setForeground(this.cfg_foregroundColor)\13\n\9gpu.setBackground(this.cfg_backgroundColor)\13\n\9\13\n\9if #this.content < this.sizeY then\13\n\9\9gpu.fill(this.posX, this.posY, this.sizeX, this.sizeY, \" \")\13\n\9end\13\n\9\13\n\9for c, t in ipairs(this.content) do\13\n\9\9gpu.set(this.posX, this.posY +c -1, t)\13\n\9end\13\nend\13\n\13\nfunction OCUI.TextBox.move(this, x, y)\13\n\9this.posX, this.posY = x, y\13\nend\13\n\13\nfunction OCUI.TextBox.stop(this)\9\13\n\9this.ocui.ignoreAutoManage(this)\13\nend\13\n\13\n\13\n--===== Menu =====--\13\nOCUI.Menu = {widgetType = \"menu\"}\13\nOCUI.Menu.__index = OCUI.Menu\13\n\13\nfunction OCUI.Menu.new(ocui, posX, posY, content, args)--posX == [int], posY == [int], content == [numTable], {backgroundTexture == [OCGLTexture], managed == [{update == [bool], draw == [bool], stop == [bool]}]}\13\n\9local this = setmetatable({}, OCUI.Menu)\13\n\9this.thread = require(\"thread\")\13\n\9this.event = require(\"event\")\13\n\9this.ut = require(\"libs/UT\")\13\n\9this.ocui = ocui\13\n\9this.posX = posX\13\n\9this.posY = posY\9\13\n\9this.content = {}\13\n\9this.backgroundTexture = args.backgroundTexture\13\n\9this.status = true\13\n\9this.markedPos = 0\13\n\9this.markingList = {}\13\n\9this.internOCUI = ocui.initiate(ocui.ocgl)\13\n\9this.inputThread = this.thread.create(function() end)\13\n\9\13\n\9this.cfg_inputMap = {next = {15}}\13\n\9\13\n\9this:add(content)\13\n\9ocui.listAutoManage(this, args.managed or {})\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCUI.Menu.activate(this)\13\n\9for c, v in ipairs(this.markingList) do\13\n\9\9v:activate()\13\n\9end\13\nend\13\n\13\nfunction OCUI.Menu.deactivate(this)\13\n\9for c, v in ipairs(this.markingList) do\13\n\9\9v:deactivate()\13\n\9end\13\nend\13\n\13\nfunction OCUI.Menu.inputManager(this)\13\n\9while this.status and this.markingList[this.markedPos].status do\13\n\9\9local _, _, key, code = this.event.pull(\"key_down\")\13\n\9\9if this.ut.inputCheck(this.cfg_inputMap.next, code) then\13\n\9\9\9this:next()\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCUI.Menu.add(this, content)\13\n\9for c, v in ipairs(content) do\13\n\9\9v[1]:stop()\13\n\9\9v[1]:move(this.posX +v[2], this.posY +v[3])\13\n\9\9\13\n\9\9if this.ut.inputCheck({\"textInput\", \"list\"}, v[1].widgetType) then --WIP\13\n\9\9\9table.insert(this.markingList, v[1])\13\n\9\9\9local mp = #this.markingList\13\n\9\9\9local oldFunction = v[1].update\13\n\9\9\9\13\n\9\9\9v[1].update = function(this2, x, y) \13\n\9\9\9\9oldFunction(this2, x, y)\13\n\9\9\9\9if this2.status then \13\n\9\9\9\9\9this.markedPos = mp\13\n\9\9\9\9end \13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9if v[1].widgetType == \"textInput\" then\13\n\9\9\9\9for c2, v2 in ipairs(this.cfg_inputMap.next) do\13\n\9\9\9\9\9table.insert(v[1].cfg_inputMap.forbidden, v2)\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9\9\13\n\9\9v[1].ocui = this.internOCUI\13\n\9\9this.internOCUI.listAutoManage(v[1], {})\13\n\9\9table.insert(this.content, v)\13\n\9end\13\nend\13\n\13\nfunction OCUI.Menu.next(this) --WIP\13\n\9if this.status and this.markingList[this.markedPos].status then\13\n\9\9if this.markedPos == #this.markingList then\13\n\9\9\9this.markedPos = 0\13\n\9\9end\13\n\9\9if this.markingList[this.markedPos +1].widgetType == \"textInput\" then\13\n\9\9\9this.internOCUI:update(this.markingList[this.markedPos +1].posX +this.markingList[this.markedPos +1].size -1, this.markingList[this.markedPos +1].posY)\13\n\9\9elseif this.markingList[this.markedPos +1].widgetType == \"list\" then\13\n\9\9\9this.markingList[this.markedPos +1].pClickTime = 0\13\n\9\9\9if this.markingList[this.markedPos +1].upButton == nil then\13\n\9\9\9\9this.internOCUI:update(this.markingList[this.markedPos +1].posX, this.markingList[this.markedPos +1].posY +this.markingList[this.markedPos +1].markedPosition -1)\13\n\9\9\9else\13\n\9\9\9\9this.internOCUI:update(this.markingList[this.markedPos +1].posX, this.markingList[this.markedPos +1].posY +this.markingList[this.markedPos +1].markedPosition)\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCUI.Menu.move(this, x, y)\13\n\9this.posX, this.posY = x, y\13\n\9for c, v in ipairs(this.content) do\13\n\9\9v[1]:move(this.posX +v[2], this.posY +v[3])\13\n\9end\13\nend\13\n\13\nfunction OCUI.Menu.update(this, x, y)\13\n\9if this.status then\13\n\9\9this.internOCUI:update(x, y)\13\n\9\9if this.inputThread:status() ~= \"running\" then\13\n\9\9\9this.inputThread = this.thread.create(this.inputManager, this)\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCUI.Menu.draw(this)\13\n\9if this.status then\13\n\9\9if this.backgroundTexture ~= nil then\13\n\9\9\9this.ocui.ocgl:draw(this.posX, this.posY, this.backgroundTexture)\13\n\9\9end\13\n\9\9this.internOCUI:draw()\13\n\9end\13\nend\13\n\13\nfunction OCUI.Menu.stop(this)\13\n\9this.ocui.ignoreAutoManage(this)\13\n\9this.internOCUI:stop()\13\n\9this.inputThread:kill()\13\nend\13\n\13\n--===== List =====--\13\nOCUI.List = {widgetType = \"list\"}\13\nOCUI.List.__index = OCUI.List\13\n\13\nfunction OCUI.List.new(ocui, posX, posY, sizeX, sizeY, content, args) --posX == [int], posY == [int], sizeX == [int], sizeY == [int], content == [numTable], {colors == [numTable], listedFunction == [function()], config == [table], managed == [{update == [bool], draw == [bool], stop == [bool]}]}\13\n\13\n\9local this = setmetatable({}, OCUI.List)\13\n\9this.computer = require(\"computer\")\13\n\9this.event = require(\"event\")\13\n\9this.thread = require(\"thread\") \13\n\9this.ut = require(\"libs/UT\")\13\n\9this.listedFunction = args.listedFunction or function() end\13\n\9this.ocui = ocui\13\n\9this.posX = posX\13\n\9this.posY = posY\13\n\9this.sizeX = sizeX\13\n\9this.sizeY = sizeY\13\n\9\13\n\9args.colors = args.colors or {}\13\n\9this.cfg_normalForegroundColor = args.colors[1] or 0xaaaaaa\13\n\9this.cfg_normalBackgroundColor = args.colors[2] or 0x555555\13\n\9this.cfg_clickedForegroundColor = args.colors[3] or 0xffffff\13\n\9this.cfg_clickedBackgroundColor = args.colors[4] or 0xaaaaaa\13\n\9\13\n\9this.cfg_inputMap = {up = {200}, down = {208}, enter = {28}, pos1 = {199}, endKey = {207}}\13\n\9config = args.config or {}\13\n\9this.cfg_pingByEveryClick = config[1] or false\13\n\9this.cfg_doubleClickTime = config[2] or .5\13\n\9\13\n\9this.status = false\13\n\9this.tmpStatus = false\13\n\9this.markedPosition = 1\13\n\9this.pClickPos = 1\13\n\9this.pClickTime = 0\13\n\9this.content = content or {}\13\n\9this.internOCUI = ocui.initiate(ocui.ocgl, this.ocui.onError)\13\n\9this.buttons = {}\13\n\9this.inputThread = this.thread.create(function() end)\13\n\9this.backgroundTexture = ocui.ocgl.generateTexture({this.cfg_normalForegroundColor, this.cfg_normalBackgroundColor, this.sizeX, this.sizeY, \" \"})\13\n\9this.listButton = this.ocui.Button.new(this.internOCUI, posX, posY, sizeX, sizeY, {listedFunction = function() \13\n\9\9this.status = true \13\n\9\9this.tmpStatus = true \13\n\9\9if this.inputThread:status() ~= \"running\" then\13\n\9\9\9this.inputThread = this.thread.create(this.inputManager, this)\13\n\9\9end\13\n\9end})\13\n\9\13\n\9--ButtonGenerating {\13\n\9this.scrollPos = nil\13\n\9this.buttonCount = 0\13\n\9\13\n\9local buttonStartPos = 0\13\n\9\13\n\9if #this.content > this.sizeY then\13\n\9\9this.buttonCount = this.sizeY -2\13\n\9\9this.scrollPos = 0\13\n\9\9buttonStartPos = 1\13\n\9\9\13\n\9\9local function ScrollContent()\13\n\9\9\9for c, v in ipairs(this.buttons) do\13\n\9\9\9\9v.texture0 = ocui.ocgl.generateTexture({this.cfg_normalForegroundColor, this.cfg_normalBackgroundColor, this.ut.fillString(content[this.scrollPos +c], sizeX - #content[this.scrollPos +c], \" \")})\13\n\9\9\9\9v.texture1 = ocui.ocgl.generateTexture({this.cfg_clickedForegroundColor, this.cfg_clickedBackgroundColor, this.ut.fillString(content[this.scrollPos +c], sizeX - #content[this.scrollPos +c], \" \")})\13\n\9\9\9end\13\n\9\9end\13\n\9\9this.upButton = this.internOCUI.Button.new(this.internOCUI, posX, posY, sizeX, 1, {texture0 = this.ocui.ocgl.generateTexture({this.cfg_normalForegroundColor, this.cfg_normalBackgroundColor, \"^\"}), texture1 = this.ocui.ocgl.generateTexture({this.cfg_clickedForegroundColor, this.cfg_clickedBackgroundColor, this.ut.fillString(\"^\", this.sizeX -1, \" \")}), listedFunction = function(_)\13\n\9\9\9if this.scrollPos > 0 then\13\n\9\9\9\9this.scrollPos = this.scrollPos -1\13\n\9\9\9\9ScrollContent()\13\n\9\9\9end\13\n\9\9end})\13\n\9\9this.downButton = this.internOCUI.Button.new(this.internOCUI, posX, posY +sizeY -1, sizeX, 1, {texture0 = this.ocui.ocgl.generateTexture({this.cfg_normalForegroundColor, this.cfg_normalBackgroundColor, \"v\"}), texture1 = this.ocui.ocgl.generateTexture({this.cfg_clickedForegroundColor, this.cfg_clickedBackgroundColor, this.ut.fillString(\"v\", this.sizeX -1, \" \")}), listedFunction = function(_)\13\n\9\9\9if this.scrollPos < this.sizeY -2 then\13\n\9\9\9\9this.scrollPos = this.scrollPos +1\13\n\9\9\9\9ScrollContent()\13\n\9\9\9end\13\n\9\9end})\13\n\9else\13\n\9\9this.buttonCount = #this.content\13\n\9end\13\n\9\13\n\9for c = 1, this.buttonCount, 1 do\13\n\9\9this.buttons[c] = this.internOCUI.Button.new(this.internOCUI, posX, posY +c -1 +buttonStartPos, sizeX, 1, {texture0 = this.ocui.ocgl.generateTexture({this.cfg_normalForegroundColor, this.cfg_normalBackgroundColor, this.ut.fillString(content[c], sizeX - #content[c], \" \")}), texture1 = this.ocui.ocgl.generateTexture({this.cfg_clickedForegroundColor, this.cfg_clickedBackgroundColor, this.ut.fillString(content[c], sizeX - #content[c], \" \")}), listedFunction = function(_) \13\n\9\9\9if this.computer.uptime() - this.pClickTime < this.cfg_doubleClickTime and this.pClickPos == c or this.cfg_doubleClickTime == -1 then\13\n\9\9\9\9this:buttonPress(c, true)\13\n\9\9\9else\13\n\9\9\9\9this.buttons[this.pClickPos].status = false\13\n\9\9\9\9this.buttons[c].status = true\13\n\9\9\9\9if this.cfg_pingByEveryClick then\13\n\9\9\9\9\9this:buttonPress(c, false)\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9\9this.pClickTime = this.computer.uptime()\13\n\9\9\9this.pClickPos = c\13\n\9\9\9this.markedPosition = c\13\n\9\9end})\13\n\9\9if this.cfg_doubleClickTime ~= -1 then\13\n\9\9\9this.buttons[c].cfg_clickTime = -1\13\n\9\9end\13\n\9end\13\n\9--}\13\n\9\13\n\9ocui.listAutoManage(this, managed or {})\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCUI.List.activate(this)\13\n\9this.pClickTime = 0\13\n\9if this.upButton ~= nil then\13\n\9\9this:update(this.posX, this.posY +this.markedPosition)\13\n\9else\13\n\9\9this:update(this.posX, this.posY)\13\n\9end\13\nend\13\n\13\nfunction OCUI.List.deactivate(this)\13\n\9this:update(-1, this.posY -1)\13\nend\13\n\13\nfunction OCUI.List.inputManager(this)\13\n\9local m = this.cfg_inputMap\13\n\9while this.cfg_doubleClickTime ~= -1 and this.status do\13\n\9\9local eventType, _, key, code, direction = this.event.pull()\13\n\9\9if eventType == \"key_down\" then\13\n\9\9\9if this.ut.inputCheck(m.enter, code) then\13\n\9\9\9\9this.pClickTime = this.computer.uptime()\13\n\9\9\9\9this.buttons[this.markedPosition]:listedFunction()\13\n\9\9\9elseif this.ut.inputCheck(m.pos1, code) then\13\n\9\9\9\9if this.scrollPos ~= nil then\13\n\9\9\9\9\9this.scrollPos = 1\13\n\9\9\9\9\9this.upButton:listedFunction()\13\n\9\9\9\9end\13\n\9\9\9\9this.buttons[1]:listedFunction()\13\n\9\9\9elseif this.ut.inputCheck(m.endKey, code) then\13\n\9\9\9\9if this.scrollPos ~= nil then\13\n\9\9\9\9\9this.scrollPos = #this.content - this.buttonCount -1\13\n\9\9\9\9\9this.downButton:listedFunction()\13\n\9\9\9\9end\13\n\9\9\9\9this.buttons[this.buttonCount]:listedFunction()\13\n\9\9\9elseif this.ut.inputCheck(m.up, code) then\13\n\9\9\9\9if this.markedPosition > 1 then\13\n\9\9\9\9\9this.buttons[this.markedPosition -1]:listedFunction()\13\n\9\9\9\9elseif this.scrollPos ~= nil then\13\n\9\9\9\9\9this.upButton:listedFunction()\13\n\9\9\9\9end\13\n\9\9\9elseif this.ut.inputCheck(m.down, code) then\13\n\9\9\9\9if this.markedPosition < this.buttonCount then\13\n\9\9\9\9\9this.buttons[this.markedPosition +1]:listedFunction()\13\n\9\9\9\9elseif this.scrollPos ~= nil then\13\n\9\9\9\9\9this.downButton:listedFunction()\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9elseif eventType == \"scroll\" then\13\n\9\9\9if this.scrollPos ~= nil and direction == 1 then\13\n\9\9\9\9this.upButton:listedFunction()\13\n\9\9\9elseif this.scrollPos ~= nil and direction == -1 then\13\n\9\9\9\9this.downButton:listedFunction()\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCUI.List.buttonPress(this, pos, isDoubleClicked)\13\n\9if this.scrollPos == nil then\13\n\9\9this:listedFunction(this.content[pos], pos, isDoubleClicked, pos)\13\n\9else\13\n\9\9this:listedFunction(this.content[pos +this.scrollPos], pos +this.scrollPos, isDoubleClicked, pos)\13\n\9end\13\nend\13\n\13\nfunction OCUI.List.update(this, x, y)\9\13\n\9this.internOCUI:update(x, y)\13\n\9if this.tmpStatus == false and #this.buttons > 0 then\13\n\9\9this.status = false\13\n\9\9this.buttons[this.markedPosition].status = false\13\n\9\9if this.inputThread.status ~= nil then\13\n\9\9\9this.inputThread:kill()\13\n\9\9end\13\n\9elseif #this.buttons > 0 then\13\n\9\9this.buttons[this.markedPosition].status = true\13\n\9end\13\n\9this.tmpStatus = false\13\nend\13\n\13\nfunction OCUI.List.draw(this)\13\n\9this.ocui.ocgl:draw(this.posX, this.posY, this.backgroundTexture)\13\n\9this.internOCUI:draw()\13\nend\13\n\13\nfunction OCUI.List.move(this, x, y)\13\n\9this.posX, this.posY = x, y\13\n\9this.listButton:move(x, y)\13\n\9if this.upButton ~= nil then\13\n\9\9this.upButton:move(x, y)\13\n\9\9this.downButton:move(x, y +this.sizeY -1)\13\n\9\9for c, v in ipairs(this.buttons) do\13\n\9\9\9v:move(x, y +c)\13\n\9\9end\13\n\9else\13\n\9\9for c, v in ipairs(this.buttons) do\13\n\9\9\9v:move(x, y +c -1)\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCUI.List.stop(this)\13\n\9this.inputThread:kill()\13\n\9\13\n\9this.ocui.ignoreAutoManage(this)\13\nend\13\n\13\n\13\n\13\n--===== TextInput =====--\13\nOCUI.TextInput = {widgetType = \"textInput\"}\13\nOCUI.TextInput.__index = OCUI.TextInput\13\n\13\nfunction OCUI.TextInput.new(ocui, posX, posY, size, args) --posX == [int], posY == [int], size == [int], args == {colors == [numTable], listedFunction == [function()], managed == [{update == [bool], draw == [bool], stop == [bool]}]}\13\n\13\n\9local this = setmetatable({}, OCUI.TextInput)\13\n\9this.computer = require(\"computer\")\13\n\9this.event = require(\"event\")\13\n\9this.thread = require(\"thread\") \13\n\9package.loaded.UT = nil\13\n\9this.ut = require(\"libs/UT\")\13\n\9this.ocui = ocui\13\n\9this.posX = posX\13\n\9this.posY = posY\13\n\9this.size = size\13\n\9this.listedFunction = args.listedFunction or function() end\13\n\9\13\n\9args.colors = args.colors or {}\13\n\9this.cfg_normalForegroundColor = args.colors[1] or 0xaaaaaa\13\n\9this.cfg_normalBackgroundColor = args.colors[2] or 0x555555\13\n\9this.cfg_clickedForegroundColor = args.colors[3] or 0xffffff\13\n\9this.cfg_clickedBackgroundColor = args.colors[4] or 0xaaaaaa\13\n\9this.cfg_cursorForegroundColor = args.colors[5] or 0x444444\13\n\9this.cfg_cursorBackgroundColor = args.colors[6] or 0xffffff\13\n\9\13\n\9this.cfg_showCursor = true\13\n\9this.cfg_cursorBlinkTime = .5\13\n\9this.cfg_keepText = false\13\n\9this.cfg_maxHistoryLength = -1\13\n\9this.cfg_hiddenText = args.hiddenText or false\13\n\9\13\n\9this.cfg_inputMap = {back = {14}, left = {203}, right = {205}, up = {200}, down = {208}, enter = {28}, pos1 = {199}, endKey = {207}, del = {211}, autoComplete = {15}, forbidden = {}, allowed = {}}\13\n\9\13\n\9this.autoComplete = args.autoComplete or {}\13\n\9\13\n\9this.status = false\13\n\9this.text = \"t\"\13\n\9this.stringPosition = 0\13\n\9this.cursorPosition = 1\13\n\9this.cursorPTime = 0\13\n\9this.history = {}\13\n\9this.historyPosition = -1\13\n\9this.userInput = \"\"\13\n\9this.autoCompBase = \"\" --for auto complete\13\n\9this.autoCompPos = 1\13\n\9\13\n\9this.inputThread = this.thread.create(function() end)\13\n\9\13\n\9ocui.listAutoManage(this, args.managed or {})\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCUI.TextInput.activate(this) \13\n\9this:update(this.posX +this.size -1, this.posY)\13\nend\13\n\13\nfunction OCUI.TextInput.deactivate(this)\13\n\9this:update(-1, this.posY -1)\13\nend\13\n\13\nfunction OCUI.TextInput.inputManager(this)\13\n\9local inputCheck = this.ut.inputCheck\13\n\9local function MoveCursor(c)\13\n\9\9if 0 +c > 0 then\13\n\9\9\9if this.cursorPosition +c > this.size and #this.text -this.stringPosition >= this.size then\13\n\9\9\9\9this.stringPosition = this.stringPosition +(c - (this.size - this.cursorPosition))\13\n\9\9\9\9this.cursorPosition = this.size\13\n\9\9\9elseif this.cursorPosition < this.size and this.cursorPosition <= #this.text then\13\n\9\9\9\9this.cursorPosition = this.cursorPosition +c\13\n\9\9\9end\13\n\9\9else\13\n\9\9\9if this.cursorPosition +c < 1 and this.stringPosition > 0 then\13\n\9\9\9\9this.stringPosition = this.stringPosition +c\13\n\9\9\9\9this.cursorPosition = 1\13\n\9\9\9elseif this.cursorPosition > 1 then\13\n\9\9\9\9this.cursorPosition = this.cursorPosition +c\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9local function RSC() --reset cursor\13\n\9\9this.cursorPosition = 1\13\n\9\9this.stringPosition = 0\13\n\9end\13\n\9local m = this.cfg_inputMap\13\n\9\13\n\9while this.status do\13\n\9\9local _, _, key, code = this.event.pull(\"key_down\")\13\n\9\9this.cursorPTime = this.computer.uptime()\13\n\9\9if key ~= nil then\9\9\9\13\n\9\9\9if inputCheck(m.enter, code) then\13\n\9\9\9\9if #this.history >= this.cfg_maxHistoryLength and this.cfg_maxHistoryLength ~= -1 and this.cfg_maxHistoryLength ~= 0 then\13\n\9\9\9\9\9for c = 1, this.cfg_maxHistoryLength, 1 do\13\n\9\9\9\9\9\9this.history[c] = this.history[c +1]\13\n\9\9\9\9\9end\13\n\9\9\9\9\9this.history[this.cfg_maxHistoryLength] = this.text\13\n\9\9\9\9elseif this.cfg_maxHistoryLength ~= 0 then\13\n\9\9\9\9\9table.insert(this.history, this.text)\13\n\9\9\9\9end\13\n\9\9\9\9this.historyPosition = -1\13\n\9\9\9\9local success, errorMsg = xpcall(this.listedFunction, debug.traceback, this)\13\n\9\9\9\9if success == false then\13\n\9\9\9\9\9this.ocui.onError(this, errorMsg)\13\n\9\9\9\9end\13\n\9\9\9\9if this.cfg_keepText == false then\13\n\9\9\9\9\9this.text = \"\"\13\n\9\9\9\9\9RSC()\13\n\9\9\9\9end\13\n\9\9\9elseif inputCheck(m.left, code) then\13\n\9\9\9\9MoveCursor(-1)\13\n\9\9\9elseif inputCheck(m.right, code) then\13\n\9\9\9\9MoveCursor(1)\13\n\9\9\9elseif inputCheck(m.pos1, code) then\13\n\9\9\9\9RSC()\13\n\9\9\9elseif inputCheck(m.endKey, code) then\13\n\9\9\9\9MoveCursor(#this.text)\13\n\9\9\9elseif inputCheck(m.back, code) then\13\n\9\9\9\9if #this.text > 0 and this.cursorPosition > 1 then\13\n\9\9\9\9\9local ct = this.ut.getChars(this.text)\13\n\9\9\9\9\9table.remove(ct, this.cursorPosition + this.stringPosition -1)\13\n\9\9\9\9\9this.text = this.ut.makeString(ct)\13\n\9\9\9\9\9if #this.text >= this.size -1 then\13\n\9\9\9\9\9\9this.stringPosition = this.stringPosition -1\13\n\9\9\9\9\9else\13\n\9\9\9\9\9\9MoveCursor(-1)\13\n\9\9\9\9\9end\13\n\9\9\9\9end\13\n\9\9\9elseif inputCheck(m.del, code) then\13\n\9\9\9\9if #this.text - (this.cursorPosition + this.stringPosition) >= 0 then\13\n\9\9\9\9\9local ct = this.ut.getChars(this.text)\13\n\9\9\9\9\9table.remove(ct, this.cursorPosition + this.stringPosition)\13\n\9\9\9\9\9this.text = this.ut.makeString(ct)\13\n\9\9\9\9end\13\n\9\9\9elseif inputCheck(m.up, code) then\13\n\9\9\9\9if this.historyPosition == -1 and this.cfg_maxHistoryLength ~= 0 and #this.history > 0 then\13\n\9\9\9\9\9this.userInput = this.text\13\n\9\9\9\9\9this.historyPosition = #this.history\13\n\9\9\9\9\9this.text = this.history[this.historyPosition]\13\n\9\9\9\9elseif this.historyPosition > 1 then\13\n\9\9\9\9\9this.historyPosition = this.historyPosition -1\13\n\9\9\9\9\9this.text = this.history[this.historyPosition]\13\n\9\9\9\9end\13\n\9\9\9\9RSC()\13\n\9\9\9\9MoveCursor(#this.text)\13\n\9\9\9\9this.autoCompBase = this.text\13\n\9\9\9elseif inputCheck(m.down, code) then\13\n\9\9\9\9if this.historyPosition < #this.history and this.historyPosition ~= -1 then\13\n\9\9\9\9\9this.historyPosition = this.historyPosition +1\13\n\9\9\9\9\9this.text = this.history[this.historyPosition]\13\n\9\9\9\9elseif #this.history > 0 then\13\n\9\9\9\9\9this.historyPosition = -1\13\n\9\9\9\9\9this.text = this.userInput\13\n\9\9\9\9end\13\n\9\9\9\9RSC()\13\n\9\9\9\9MoveCursor(#this.text)\13\n\9\9\9\9this.autoCompBase = this.text\13\n\9\9\9elseif inputCheck(m.autoComplete, code) then\13\n\9\9\9\9local clear = true\13\n\9\9\9\9if this.autoCompBase ~= string.sub(this.text, 0, #this.autoCompBase) or this.autoCompBase == \"\" then\13\n\9\9\9\9\9this.autoCompBase = this.text\13\n\9\9\9\9end\13\n\9\9\9\9for i = this.autoCompPos, #this.autoComplete do\13\n\9\9\9\9\9this.autoCompPos = i +1\13\n\9\9\9\9\9print(string.sub(this.autoComplete[i], 0, #this.autoCompBase))\13\n\9\9\9\9\9if this.autoCompBase == string.sub(this.autoComplete[i], 0, #this.autoCompBase) then\13\n\9\9\9\9\9\9this.text = this.autoComplete[i]\13\n\9\9\9\9\9\9clear = false\13\n\9\9\9\9\9\9break\13\n\9\9\9\9\9end\13\n\9\9\9\9end\13\n\9\9\9\9if this.autoCompPos > #this.autoComplete and clear then\13\n\9\9\9\9\9this.autoCompPos = 1\13\n\9\9\9\9\9this.text = this.autoCompBase\13\n\9\9\9\9end\13\n\9\9\9\9RSC()\13\n\9\9\9\9MoveCursor(#this.text)\13\n\9\9\9elseif key ~= 0 and inputCheck(m.forbidden, code) == false and #m.allowed == 0 or inputCheck(m.allowed, code) then\13\n\9\9\9\9--this.text = this.text .. string.char(key)\13\n\9\9\9\9local ct = this.ut.getChars(this.text)\13\n\9\9\9\9table.insert(ct, this.cursorPosition +this.stringPosition, string.char(key))\13\n\9\9\9\9this.text = this.ut.makeString(ct)\13\n\9\9\9\9this.cursorPTime = this.computer.uptime()\13\n\9\9\9\9MoveCursor(1)\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCUI.TextInput.update(this, x, y)\9\13\n\9if x > this.posX -1 and x < this.posX + this.size and\13\n\9\9y > this.posY -1 and y < this.posY + 1\13\n\9then\13\n\9\9this.status = true\13\n\9\9if this.inputThread:status() ~= \"running\" then\13\n\9\9\9this.inputThread = this.thread.create(this.inputManager, this)\13\n\9\9\9this.inputThread:detach()\13\n\9\9\9this.ocui.stopList[this.stopListPos] = this\13\n\9\9end\13\n\9\9if x - this.posX > #this.text - this.stringPosition then\13\n\9\9\9this.cursorPosition = #this.text - this.stringPosition +1\13\n\9\9else\13\n\9\9\9this.cursorPosition = x - this.posX +1\13\n\9\9end\13\n\9else \13\n\9\9this.status = false\13\n\9\9this.inputThread:kill()\13\n\9end\13\nend\13\n\13\nfunction OCUI.TextInput.draw(this)\13\n\9local function generateTexture(t)\13\n\9\9return {textureFormat = \"OCGLT\", version = \"v0.1\", drawCalls = {{\"f\", t[1]}, {\"b\", t[2]}, {0, 0, t[3]}}}\13\n\9end\13\n\9local text = this.text\13\n\9if this.cfg_hiddenText then\13\n\9\9text = this.ut.fillString(\"\", #this.text, \"*\")\13\n\9end\13\n\9\13\n\9for c = #this.text, this.size -1, 1 do\13\n\9\9text = text .. \" \"\13\n\9end\13\n\9if #this.text > this.size -1 then\13\n\9\9local tm = #this.text - (this.size -1)\13\n\9\9tm = tm - this.stringPosition \13\n\9\9if tm > 0 then\13\n\9\9\9text = string.sub(this.text, this.stringPosition +1, -tm)\13\n\9\9else\13\n\9\9\9text = string.sub(this.text, this.stringPosition +1)\13\n\9\9\9text = text .. \" \"\13\n\9\9end\13\n\9end\13\n\9\13\n\9if this.status then\13\n\9\9this.ocui.ocgl:draw(this.posX, this.posY, generateTexture({this.cfg_clickedForegroundColor, this.cfg_clickedBackgroundColor, text}))\13\n\9\9local dt = this.computer.uptime() - this.cursorPTime\13\n\9\9if this.cfg_showCursor and dt < this.cfg_cursorBlinkTime then\13\n\9\9\9this.ocui.ocgl:draw(this.posX +this.cursorPosition -1, this.posY, generateTexture({this.cfg_cursorForegroundColor, this.cfg_cursorBackgroundColor, string.sub(text, this.cursorPosition, this.cursorPosition)}))\13\n\9\9elseif dt > this.cfg_cursorBlinkTime *2 then\13\n\9\9\9this.cursorPTime = this.computer.uptime()\13\n\9\9end\13\n\9else\13\n\9\9this.ocui.ocgl:draw(this.posX, this.posY, generateTexture({this.cfg_normalForegroundColor, this.cfg_normalBackgroundColor, text}))\13\n\9end\13\nend\13\n\13\nfunction OCUI.TextInput.move(this, x, y)\13\n\9this.posX, this.posY = x, y\13\nend\13\n\13\nfunction OCUI.TextInput.stop(this)\13\n\9this.inputThread:kill()\13\n\9\13\n\9this.ocui.ignoreAutoManage(this)\13\nend\13\n\13\n\13\n\13\n--===== Button/Switch =====--\13\nOCUI.Button = {widgetType = \"button\"}\13\nOCUI.Button.__index = OCUI.Button\13\n\13\nfunction OCUI.Button.new(ocui, posX, posY, sizeX, sizeY, args) --posX == [int], posY == [int], sizeX == [int], sizeY == [int], args == {listedFunction == [function()], managed == [{update == [bool], draw == [bool]}]}\13\n\13\n\9local this = setmetatable({}, OCUI.Button)\13\n\9this.computer = require(\"computer\")\13\n\9this.ocui = ocui\13\n\9this.posX = posX\13\n\9this.posY = posY\13\n\9this.sizeX = sizeX\13\n\9this.sizeY = sizeY\13\n\9this.listedFunction = args.listedFunction or function() end\13\n\9\13\n\9this.texture0 = args.texture0 or ocui.ocgl.generateTexture({})\13\n\9this.texture1 = args.texture1 or ocui.ocgl.generateTexture({})\13\n\9\13\n\9this.cfg_clickTime = .3 --Time the button have to be the clicked texture. If this -1 the button is a switch.\13\n\9this.clickTime = 0 --Time the button was clicked.\13\n\9this.status = false\13\n\9\13\n\9ocui.listAutoManage(this, args.managed or {})\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCUI.Button.update(this, x, y)\9\13\n\9if x > this.posX -1 and x < this.posX + this.sizeX and\13\n\9\9y > this.posY -1 and y < this.posY + this.sizeY\13\n\9then\13\n\9\9if this.cfg_clickTime ~= -1 then\13\n\9\9\9this.clickTime = this.computer.uptime()\13\n\9\9\9this.status = true\13\n\9\9else\13\n\9\9\9if this.status then\13\n\9\9\9\9this.status = false\13\n\9\9\9else\13\n\9\9\9\9this.status = true\13\n\9\9\9end\13\n\9\9end\13\n\9\9local success, errorMsg = xpcall(this.listedFunction, debug.traceback, this)\13\n\9\9if success == false then\13\n\9\9\9this.ocui.onError(this, errorMsg)\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCUI.Button.draw(this)\13\n\9local dt = -2\13\n\9if this.cfg_clickTime ~= -1 then\13\n\9\9dt = this.computer.uptime() - this.clickTime\13\n\9end\13\n\9\13\n\9if this.status and dt < this.cfg_clickTime then\13\n\9\9this.ocui.ocgl:draw(this.posX, this.posY, this.texture1)\13\n\9else\13\n\9\9this.ocui.ocgl:draw(this.posX, this.posY, this.texture0)\13\n\9\9this.status = false\13\n\9end\13\nend\13\n\13\nfunction OCUI.Button.move(this, x, y)\13\n\9this.posX, this.posY = x, y\13\nend\13\n\13\nfunction OCUI.Button.stop(this)\9\13\n\9this.ocui.ignoreAutoManage(this)\13\nend\13\n\13\nreturn OCUI\13\n",["//libs/UT.lua"] = "--[[\13\n    UT Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This library is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    This library is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with this library.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\n--[[UsefullThings libary\13\n\9Written by:\13\n\9\9MisterNoNameLP\13\n]]\13\nlocal UT = {version = \"v0.6.1\"}\13\n\13\nfunction UT.parseArgs(...) --returns the first non nil value.\13\n\9for _, a in pairs({...}) do\13\n\9\9if a ~= nil then\13\n\9\9\9return a\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction UT.seperatePath(path) --seperates a data path [\"./DIR/FILE.ENDING\"] into the dir path [\"./DIR/\"], the file name [\"FILE\"], and the file ending [\".ENDING\" or nil]\13\n\9if string.sub(path, #path) == \"/\" then\13\n\9\9return path\13\n\9end\13\n\9\13\n\9local dir, fileName, fileEnd = \"\", \"\", nil\13\n\9local tmpLatest = \"\"\13\n\9for s in string.gmatch(tostring(path), \"[^/]+\") do\13\n\9\9tmpLatest = s\13\n\9end\13\n\9dir = string.sub(path, 0, #path -#tmpLatest)\13\n\9for s in string.gmatch(tostring(tmpLatest), \"[^.]+\") do\13\n\9\9fileName = fileName .. s\13\n\9\9tmpLatest = s\13\n\9end\13\n\9if fileName == tmpLatest then\13\n\9\9fileName = tmpLatest\13\n\9else\13\n\9\9fileEnd = \".\" .. tmpLatest\13\n\9\9fileName = string.sub(fileName, 0, #fileName - #fileEnd +1)\13\n\9end\13\n\9\13\n\9return dir, fileName, fileEnd\13\nend\13\n\13\nfunction UT.getChars(s) --returns a array with the chars of the string.\13\n\9local chars = {}\13\n\9for c = 1, #s do\13\n\9\9chars[c] = string.sub(s, c, c)\13\n\9end\13\n\9return chars\13\nend\13\n\13\nfunction UT.makeString(c) --genetares a string from and array of chars/strings.\13\n\9local s = \"\"\13\n\9for c, v in ipairs(c) do\13\n\9\9s = s ..v\13\n\9end\13\n\9return s\13\nend\13\n\13\nfunction UT.inputCheck(m, c) --checks if a array (m) contains a value (c).\13\n\9for _, v in pairs(m) do\13\n\9\9if v == c then\13\n\9\9\9return true\13\n\9\9end\13\n\9end\13\n\9return false\13\nend\13\n\13\nfunction UT.fillString(s, amout, c) --fills a string (s) up with a (amout) of chars/strings (c).\13\n\9local s2 = s\13\n\9for c2 = 1, amout, 1 do\13\n\9\9s2 = s2 .. c\13\n\9end\13\n\9return s2\13\nend\13\n\13\nreturn UT",["//libs/ocgf.lua"] = "--[[\13\n    ocgf Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This library is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    This library is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with this library.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\n--[[OpenComputersGamingFramework:\13\n\9ToDo:\13\n\9\13\n\9Written by:\13\n\9\9MisterNoNameLP\13\n]]\13\n\13\nlocal OCGF = {version = \"v0.9.2\"} \13\nOCGF.__index = OCGF\13\n\13\n--===== local vars =====--\13\nlocal ut = require(\"libs/UT\")\13\nlocal serialization = require(\"serialization\")\13\n\13\n--===== Functions =====--\13\nlocal function posSizeCheck(this)\13\n\9if this.sizeX == nil or this.sizeY == nil then\13\n\9\9return false, \"No sizeX or sizeY given\"\13\n\9end\13\n\9if this.posX == nil or this.posY == nil then\13\n\9\9return false, \"No posX or posY given\"\13\n\9end\13\n\9return this\13\nend\13\n\13\nlocal function posEqualizer(args, x, y)\13\n\9local posX = ut.parseArgs(args.x, args.posX, 0) +x\13\n\9local posY = ut.parseArgs(args.y, args.posY, 0) +y\13\n\9return posX, posY\13\nend\13\n\13\nlocal function calculateStiffness(speed, stiffness)\13\n\9if speed > 0 then\13\n\9\9return math.max(speed - stiffness, 0)\13\n\9else\13\n\9\9return math.min(speed + stiffness, 0)\13\n\9end\13\nend\13\n\13\nlocal function calculateCollision(this, oc, c) --ownCollider, (other) collider\13\n\9local sides = {false, false, false, false} -- -x, x, -y, y\13\n\9local disMap = {0, 0, 0, 0}\13\n\9\13\n\9disMap[1] = (c.posX + c.sizeX) - oc.posX\13\n\9disMap[2] = (oc.posX + oc.sizeX) - c.posX\13\n\9disMap[3] = (c.posY + c.sizeY) - oc.posY\13\n\9disMap[4] = (oc.posY + oc.sizeY) - c.posY\13\n\9\13\n\9local nearest, dis = 0, 2^32\13\n\9for i, d in ipairs(disMap) do\13\n\9\9if d <= dis then --change <= to == if you want x collision \"priorized\".\13\n\9\9\9dis = d\13\n\9\9\9nearest = i\13\n\9\9end\13\n\9end\13\n\9sides[nearest] = true\13\n\9\13\n\9if sides[1] then\13\n\9\9this.speedX = math.max(0, this.speedX)\13\n\9\9this.gameObject:move(disMap[nearest], 0, false)\13\n\9elseif sides[2] then\13\n\9\9this.speedX = math.min(0, this.speedX)\13\n\9\9this.gameObject:move(-disMap[nearest], 0, false)\13\n\9elseif sides[3] then\13\n\9\9this.speedY = math.max(0, this.speedY)\13\n\9\9this.gameObject:move(0, disMap[nearest], false)\13\n\9elseif sides[4] then\13\n\9\9this.speedY = math.min(0, this.speedY)\13\n\9\9this.gameObject:move(0, -disMap[nearest], false)\13\n\9end\13\n\9\13\n\9return sides\13\n\9\13\n\9--print(serialization.serialize({math.floor(disMap[1]), math.floor(disMap[2]), math.floor(disMap[3]), math.floor(disMap[4])}))\13\n\9--print(serialization.serialize(sides))\13\nend\13\n\13\nlocal function setLastPos(this, slp, x, y)\13\n\9x = x or this.posX\13\n\9y = y or this.posY\13\n\9slp = ut.parseArgs(slp, true)\13\n\9if slp then\13\n\9\9this.lastPosX, this.lastPosY = this.posX, this.posY\13\n\9end\13\nend\13\n\13\n--===== MainClass =====--\13\nfunction OCGF.initiate(args)\13\n\9local this = setmetatable({}, OCGF)\13\n\9args = args or {}\13\n\9\13\n\9this.component = require(\"component\")\13\n\9this.gpu = args.gpu or this.component.gpu\13\n\9this.ut = require(\"libs/UT\")\13\n\9this.ocgl = args.ocgl or require(\13\n\9\9args.ocglPath or \"libs/ocgl\"\13\n\9).initiate(\13\n\9\9this.gpu\13\n\9)\13\n\9\13\n\9this.resX, this.resY = this.gpu.getResolution()\13\n\9\13\n\9return this\13\nend\13\n\13\n\13\n--===== GameObject (parent of other game objects) =====--\13\nOCGF.GameObject = {widgetType = \"GameObject\"}\13\nOCGF.GameObject.__index = OCGF.GameObject\13\n\13\nfunction OCGF.GameObject.new(ocgf, args)\13\n\9local this = setmetatable({}, OCGF.GameObject)\13\n\9args = args or {}\13\n\9this.ocgf = ocgf\13\n\9\13\n\9this.drawTrigger = ut.parseArgs(args.dt, args.drawTrigger, false)\13\n\9this.drawCollider = ut.parseArgs(args.dc, args.drawCollider, false)\13\n\9this.log = args.logFunc or args.logFunction or function() end --WIP\13\n\9\13\n\9this.posX = args.x or args.posX or 0\13\n\9this.posY = args.y or args.posY or 0\13\n\9\13\n\9this.parent = args.parent\13\n\9\13\n\9this.boxTrigger = {}\13\n\9this.boxCollider = {}\13\n\9this.rigidBodys = {}\13\n\9this.sprites = {}\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCGF.GameObject.setLastPos(this, x, y)\13\n\9for i, o in ipairs(this.boxTrigger) do\13\n\9\9setLastPos(o, nil, x + (o.posX - this.posX), y + (o.posY - this.posY))\13\n\9end\13\n\9for i, o in ipairs(this.boxCollider) do\13\n\9\9setLastPos(o, nil, x + (o.posX - this.posX), y + (o.posY - this.posY))\13\n\9end\13\n\9for i, o in ipairs(this.sprites) do\13\n\9\9setLastPos(o, nil, x + (o.posX - this.posX), y + (o.posY - this.posY))\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.stop(this)\13\n\9for _, rb in ipairs(this.rigidBodys) do\13\n\9\9rb.speedX = 0\13\n\9\9rb.speedY = 0\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.setSpeed(this, x, y)\13\n\9for _, rb in ipairs(this.rigidBodys) do\13\n\9\9rb.speedX = x\13\n\9\9rb.speedY = y\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.addForce(this, x, y, maxSpeed)\13\n\9maxSpeed = maxSpeed or 2^32\13\n\9for _, rb in ipairs(this.rigidBodys) do\13\n\9\9if x ~= 0 then\13\n\9\9\9if rb.speedX + x >= maxSpeed then\13\n\9\9\9\9rb.speedX = maxSpeed\13\n\9\9\9elseif rb.speedX + x <= -maxSpeed then\13\n\9\9\9\9rb.speedX = -maxSpeed\13\n\9\9\9else\13\n\9\9\9\9rb.speedX = rb.speedX +x\13\n\9\9\9end\13\n\9\9end\13\n\9\9if y ~= 0 then\13\n\9\9\9if rb.speedY + y >= maxSpeed then\13\n\9\9\9\9rb.speedY = maxSpeed\13\n\9\9\9elseif rb.speedY + y <= -maxSpeed then\13\n\9\9\9\9rb.speedY = -maxSpeed\13\n\9\9\9else\13\n\9\9\9\9rb.speedY = rb.speedY +y\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.addSprite(this, args)\13\n\9args.x, args.y = posEqualizer(args, this.posX, this.posY)\13\n\9table.insert(this.sprites, OCGF.Sprite.new(this, args))\13\nend\13\n\13\nfunction OCGF.GameObject.addBoxCollider(this, args)\13\n\9args.x, args.y = posEqualizer(args, this.posX, this.posY)\13\n\9args.isCollider = true\13\n\9table.insert(this.boxCollider, OCGF.BoxTrigger.new(this, args))\13\nend\13\n\13\nfunction OCGF.GameObject.addBoxTrigger(this, args)\13\n\9args.x, args.y = posEqualizer(args, this.posX, this.posY)\13\n\9table.insert(this.boxTrigger, OCGF.BoxTrigger.new(this, args))\13\nend\13\n\13\nfunction OCGF.GameObject.addRigidBody(this, args)\13\n\9table.insert(this.rigidBodys, OCGF.RigidBody.new(this, args))\13\nend\13\n\13\nfunction OCGF.GameObject.onCollision(this, gameObject, selfCall)\13\n\9--this.log(\"GO: Collision: \" .. tostring(selfCall))\13\nend\13\n\13\nfunction OCGF.GameObject.onTrigger(this, gameObject, selfCall)\13\n\9--this.log(\"GO: Trigger: \" .. tostring(selfCall))\13\nend\13\n\13\nfunction OCGF.GameObject.getSprites(this)\13\n\9local sprites = {}\13\n\9for _, s in ipairs(this.sprites) do\13\n\9\9table.insert(sprites, s)\13\n\9end\13\n\9return sprites\13\nend\13\n\13\nfunction OCGF.GameObject.getTrigger(this)\13\n\9local trigger = {}\13\n\9for _, bt in ipairs(this.boxTrigger) do\13\n\9\9table.insert(trigger, bt:getTrigger()[1])\13\n\9end\13\n\9return trigger\13\nend\13\n\13\nfunction OCGF.GameObject.getCollider(this)\13\n\9local trigger = {}\13\n\9for _, bc in ipairs(this.boxCollider) do\13\n\9\9table.insert(trigger, bc:getTrigger()[1])\13\n\9end\13\n\9return trigger\13\nend\13\n\13\nfunction OCGF.GameObject.update(this, gameObjects) --gameObject can be collider table\13\n\9for i, c in ipairs(gameObjects) do\13\n\9\9for i, bt in ipairs(this.boxTrigger) do\13\n\9\9\9bt:update(c:getTrigger())\13\n\9\9\9bt:update(c:getCollider())\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.updatePhx(this, gameObjects, dt) --gameObject can be collider table\13\n\9dt = dt or 1\13\n\9for _, rb in ipairs(this.rigidBodys) do\13\n\9\9rb:update(gameObjects, dt)\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.move(this, x, y, setLastPos)\13\n\9for i, o in ipairs(this.boxTrigger) do\13\n\9\9o:move(x, y, setLastPos)\13\n\9end\13\n\9for i, o in ipairs(this.boxCollider) do\13\n\9\9o:move(x, y, setLastPos)\13\n\9end\13\n\9for i, o in ipairs(this.sprites) do\13\n\9\9o:move(x, y, setLastPos)\13\n\9end\13\n\9this.posX = this.posX +x\13\n\9this.posY = this.posY +y\13\nend\13\n\13\nfunction OCGF.GameObject.moveTo(this, x, y, setLastPos) --WIP: bug: ...\13\n\9for i, bt in ipairs(this.boxTrigger) do\13\n\9\9bt:moveTo(x + (bt.posX - this.posX), y + (bt.posY - this.posY), setLastPos)\13\n\9end\13\n\9for i, bc in ipairs(this.boxCollider) do\13\n\9\9bc:moveTo(x + (bc.posX - this.posX), y + (bc.posY - this.posY), setLastPos)\13\n\9end\13\n\9for i, o in ipairs(this.sprites) do\13\n\9\9o:moveTo(x + (o.posX - this.posX), y + (o.posY - this.posY), setLastPos)\13\n\9end\13\n\9this.posX = x\13\n\9this.posY = y\13\nend\13\n\13\nfunction OCGF.GameObject.draw(this, color)\9\13\n\9for i, o in ipairs(this.sprites) do\13\n\9\9o:draw()\13\n\9end\13\n\9if this.drawTrigger then\13\n\9\9for i, bt in ipairs(this.boxTrigger) do\13\n\9\9\9bt:draw(color)\13\n\9\9end\13\n\9end\13\n\9if this.drawCollider then\13\n\9\9for i, bc in ipairs(this.boxCollider) do\13\n\9\9\9bc:draw(color)\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.clear(this, color, actual)\9\13\n\9if this.drawTrigger then\13\n\9\9for i, bt in ipairs(this.boxTrigger) do\13\n\9\9\9bt:clear(color, actual)\13\n\9\9end\13\n\9end\13\n\9if this.drawCollider then\13\n\9\9for i, bc in ipairs(this.boxCollider) do\13\n\9\9\9bc:clear(color, actual)\13\n\9\9end\13\n\9end\13\n\9for i, o in ipairs(this.sprites) do\13\n\9\9o:clear(color, actual)\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.startAnimation(this, speed, frame)\13\n\9for _, s in pairs(this.sprites) do\13\n\9\9s:start(speed, frame)\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.stopAnimation(this, frame, playTilEnd)\13\n\9for _, s in pairs(this.sprites) do\13\n\9\9s:stop(frame, playTilEnd)\13\n\9end\13\nend\13\n\13\nfunction OCGF.GameObject.pauseAnimation(this)\13\n\9for _, s in pairs(this.sprites) do\13\n\9\9s:pause()\13\n\9end\13\n\13\nend\13\nfunction OCGF.GameObject.playAnimation(this, speed, frame)\13\n\9for _, s in pairs(this.sprites) do\13\n\9\9s:play(speed, frame)\13\n\9end\13\nend\13\n\13\n--===== Sprite =====--\13\nOCGF.Sprite = {widgetType = \"Sprite\"}\13\nOCGF.Sprite.__index = OCGF.Sprite\13\n\13\nfunction OCGF.Sprite.new(gameObject, args)\13\n\9local this = setmetatable({}, OCGF.Sprite)\13\n\9args = args or {}\13\n\9this.gameObject = gameObject\13\n\9\13\n\9this.posX = args.x or args.posX or 0\13\n\9this.posY = args.y or args.posY or 0 \13\n\9this.texture = ut.parseArgs(args.t, args.texture, this.gameObject.ocgf.ocgl.generateTexture(0, 0, \"\"))\13\n\9this.background = args.background or 0x000000\13\n\9\13\n\9if this.texture.format == \"OCGLA\" then\13\n\9\9this.animation = gameObject.ocgf.ocgl.Animation.new(gameObject.ocgf.ocgl, this.texture)\13\n\9end\13\n\9\13\n\9this.lastPosX = this.posX\13\n\9this.lastPosY = this.posY\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction OCGF.Sprite.move(this, x, y, slp)\13\n\9setLastPos(this, slp)\13\n\9this.posX = this.posX +x\13\n\9this.posY = this.posY +y\13\n\9return this.posX, this.posY\13\nend\13\n\13\nfunction OCGF.Sprite.moveTo(this, x, y, slp)\9\13\n\9setLastPos(this, slp)\13\n\9this.posX, this.posY = x, y\13\nend\13\n\13\nfunction OCGF.Sprite.draw(this, dt, background)\9\13\n\9--this.gameObject.log(this.background)\13\n\9background = background or this.background\13\n\9if this.animation ~= nil then\13\n\9\9this.animation.background = background\13\n\9\9this.animation:draw(this.posX, this.posY, dt)\13\n\9else\13\n\9\9this.gameObject.ocgf.ocgl:draw(this.posX, this.posY, this.texture)\13\n\9end\13\nend\13\n\13\nfunction OCGF.Sprite.clear(this, color, actual)\13\n\9if actual then\13\n\9\9if this.animation ~= nil then\13\n\9\9\9this.animation:clearBlack(this.posX, this.posY, nil, color)\13\n\9\9else\13\n\9\9\9this.gameObject.ocgf.ocgl:clearBlack(this.posX, this.posY, this.texture, color)\13\n\9\9end\13\n\9else\13\n\9\9if this.animation ~= nil then\13\n\9\9\9this.animation:clearBlack(this.lastPosX, this.lastPosY, nil, color)\13\n\9\9else\13\n\9\9\9this.gameObject.ocgf.ocgl:clearBlack(this.lastPosX, this.lastPosY, this.texture, color)\13\n\9\9end\13\n\9end\13\nend\13\n\13\nfunction OCGF.Sprite.start(this, speed, frame)\13\n\9if this.animation ~= nil then\13\n\9\9this.animation:start(speed, frame)\13\n\9end\13\nend\13\n\13\nfunction OCGF.Sprite.stop(this, frame, playTilEnd)\13\n\9if this.animation ~= nil then\13\n\9\9this.animation:stop(frame, playTilEnd)\13\n\9end\13\nend\13\n\13\nfunction OCGF.Sprite.pause(this)\13\n\9if this.animation ~= nil then\13\n\9\9this.animation:pause()\13\n\9end\13\nend\13\n\13\nfunction OCGF.Sprite.play(this, speed, frame)\13\n\9if this.animation ~= nil then\13\n\9\9this.animation:play(speed)\13\n\9end\13\nend\13\n\13\nfunction OCGF.Sprite.changeTexture(this, newTexture)\13\n\9this.texture = newTexture\13\n\9if this.texture.format == \"OCGLA\" then\13\n\9\9if this.animation ~= nil then\13\n\9\9\9this.animation.animation = this.texture\13\n\9\9else\13\n\9\9\9this.animation = this.gameObject.ocgf.ocgl.Animation.new(this.gameObject.ocgf.ocgl, this.texture)\13\n\9\9end\13\n\9else\13\n\9\9this.animation = nil\13\n\9end\13\nend\13\n\13\n--===== RigidBody =====--\13\nOCGF.RigidBody = {widgetType = \"RigidBody\"}\13\nOCGF.RigidBody.__index = OCGF.RigidBody\13\n\13\nfunction OCGF.RigidBody.new(gameObject, args)\13\n\9local this = setmetatable({}, OCGF.RigidBody)\13\n\9args = args or {}\13\n\9this.gameObject = gameObject\13\n\9\13\n\9this.calculateHalfPixel = ut.parseArgs(args.hp, args.halfPixel, args.calculateHalfPixel, true) -- if true then is speedY == speedY /2\13\n\9this.mass = ut.parseArgs(args.mass, 0)\13\n\9this.bounceFactor = ut.parseArgs(args.bf, args.bounceFactor, 1)\13\n\9this.gravitationFactor = ut.parseArgs(args.g, args.gravitation, args.gravitationFactor, 1)\13\n\9this.stiffness = ut.parseArgs(args.stiffness, 0) -- 1 == 1 speed loss per update, -1 == unmovable.\13\n\9\13\n\9this.speedX = 0\13\n\9this.speedY = 0\13\n\9\13\n\9this.pingGameObject = ut.parseArgs(args.pgo, args.pingGameObject, true)\13\n\9this.callOwnGameObject = ut.parseArgs(args.callOwn, true)\13\n\9\13\n\9return this\13\nend\13\n\13\n--function OCGF.RigidBody.update(this, gameObjects, pingTrigger, pingGameObject, callOwnFunction, slp) --ToDo: add realistic physics.\13\nfunction OCGF.RigidBody.update(this, gameObjects, dt, slp) --ToDo: add realistic physics.\13\n\9this.speedX = calculateStiffness(this.speedX, this.stiffness) * dt\13\n\9this.speedY = this.speedY + (this.gravitationFactor * dt)\13\n\9this.speedY = calculateStiffness(this.speedY, this.stiffness * dt)\13\n\9\13\n\9if this.calculateHalfPixel then\13\n\9\9this.gameObject:move(this.speedX, this.speedY /2, slp)\13\n\9else\13\n\9\9this.gameObject:move(this.speedX, this.speedY, slp)\13\n\9end\13\n\9\13\n\9local collider = {}\13\n\9for _, go in ipairs(gameObjects) do\13\n\9\9for _, c in ipairs(go:getCollider()) do\13\n\9\9\9table.insert(collider, c)\13\n\9\9end\13\n\9end\13\n\9\13\n\9for _, c in ipairs(this.gameObject:getCollider()) do\13\n\9\9for _, collision in ipairs(c:update(collider)) do\13\n\9\9\9calculateCollision(this, c, collision)\13\n\9\9end\13\n\9end\13\n\9\13\n\9return collisions\13\nend\13\n\13\n--===== BoxTrigger =====--\13\nOCGF.BoxTrigger = {widgetType = \"BoxTrigger\"}\13\nOCGF.BoxTrigger.__index = OCGF.BoxTrigger\13\n\13\nfunction OCGF.BoxTrigger.new(gameObject, args)\13\n\9local this = setmetatable({}, OCGF.BoxTrigger)\13\n\9args = args or {}\13\n\9this.gameObject = gameObject\13\n\9\13\n\9this.name = ut.parseArgs(args.n, args.name, nil)\13\n\9\13\n\9this.posX = args.x or args.posX or 0\13\n\9this.posY = args.y or args.posY or 0 \13\n\9this.sizeX = args.sx or args.sizeX or 1\13\n\9this.sizeY = args.sy or args.sizeY or 1\13\n\9this.listedFunction = ut.parseArgs(args.lf, args.listedFunction, function() end)\13\n\9this.pingTrigger = ut.parseArgs(args.pingTrigger, false)\13\n\9this.pingGameObject = ut.parseArgs(args.ping, args.pingGameObject, false)\13\n\9this.callOwnFunction = ut.parseArgs(args.callFunction, args.callOwnFunction, true)\13\n\9this.callOwnGameObject = ut.parseArgs(args.callOwn, true)\13\n\9this.isCollider = ut.parseArgs(args.isCollider, false)\13\n\9\13\n\9this.lastPosX = this.posX\13\n\9this.lastPosY = this.posY\13\n\9\13\n\9return posSizeCheck(this)\13\nend\13\n\13\nfunction OCGF.BoxTrigger.update(this, collider, pingTrigger, pingGameObject, callOwnFunction, callOwnGameObject)\9\13\n\9\13\n\9--this.gameObject.log(this.listedFunction, this.callOwnFunction, this.isCollider, this.hass == \"!!\")\13\n\9\13\n\9\13\n\9pingTrigger = ut.parseArgs(pingTrigger, this.pingTrigger)\13\n\9pingGameObject = ut.parseArgs(pingGameObject, this.pingGameObject)\13\n\9callOwnFunction = ut.parseArgs(callOwnFunction, this.callOwnFunction)\13\n\9callOwnGameObject = ut.parseArgs(callOwnGameObject, this.callOwnGameObject)\13\n\9\13\n\9local collisions = {}\13\n\9local gameObjects = {}\13\n\9\13\n\9for i, c in ipairs(collider) do\13\n\9\9if this.posX + this.sizeX > c.posX and this.posX < c.posX + c.sizeX and\13\n\9\9\9this.posY + this.sizeY > c.posY and this.posY < c.posY + c.sizeY\13\n\9\9then\13\n\9\9\9table.insert(collisions, c)\13\n\9\9\9table.insert(gameObjects, c.gameObject)\13\n\9\9\9if pingTrigger then\13\n\9\9\9\9c:listedFunction(this.gameObject, false, this.gameObject.parent) --other trigger\13\n\9\9\9end\13\n\9\9\9if callOwnFunction then\13\n\9\9\9\9--this.gameObject.log(this.listedFunction, this.callOwnFunction, this.isCollider, this.hass == \"!!\", \"CALL\")\13\n\9\9\9\9this:listedFunction(c.gameObject, true, this.gameObject.parent) --this trigger\13\n\9\9\9end\13\n\9\9\9if pingGameObject then\13\n\9\9\9\9if this.isCollider then\13\n\9\9\9\9\9c.gameObject:onCollision(this.gameObject, false, this.gameObject.parent)\13\n\9\9\9\9else\13\n\9\9\9\9\9c.gameObject:onTrigger(this.gameObject, false, this.gameObject.parent)\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9\9if callOwnGameObject then\13\n\9\9\9\9if this.isCollider then\13\n\9\9\9\9\9this.gameObject:onCollision(c.gameObject, true, this.gameObject.parent)\13\n\9\9\9\9else\13\n\9\9\9\9\9this.gameObject:onTrigger(c.gameObject, true, this.gameObject.parent)\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9return collisions, gameObjects\13\nend\13\n\13\nfunction OCGF.BoxTrigger.move(this, x, y, slp)\13\n\9setLastPos(this, slp)\13\n\9this.posX = this.posX +x\13\n\9this.posY = this.posY +y\13\n\9\13\n\9return this.posX, this.posY\13\nend\13\n\13\nfunction OCGF.BoxTrigger.moveTo(this, x, y, slp)\9\13\n\9setLastPos(this, slp)\13\n\9this.posX, this.posY = x, y\13\nend\13\n\13\nfunction OCGF.BoxTrigger.getTrigger(this)\13\n\9return {this}\13\nend\13\n\13\nfunction OCGF.BoxTrigger.draw(this, color)\13\n\9local gpu = this.gameObject.ocgf.gpu\13\n\9local ut = this.gameObject.ocgf.ut\13\n\9gpu.setBackground(color or 0xFF69B4)\13\n\9\13\n\9gpu.set(this.posX, this.posY, ut.fillString(\"\", this.sizeX, \" \"))\13\n\9gpu.set(this.posX, this.posY +this.sizeY -1, ut.fillString(\"\", this.sizeX, \" \"))\13\n\9gpu.set(this.posX, this.posY, ut.fillString(\"\", this.sizeY, \" \"), true)\13\n\9gpu.set(this.posX +this.sizeX -1, this.posY, ut.fillString(\"\", this.sizeY, \" \"), true)\13\nend\13\n\13\nfunction OCGF.BoxTrigger.clear(this, color, actual)\13\n\9local gpu = this.gameObject.ocgf.gpu\13\n\9local ut = this.gameObject.ocgf.ut\13\n\9gpu.setBackground(color or 0x000000)\13\n\9\13\n\9if actual then\13\n\9\9gpu.set(this.posX, this.posY, ut.fillString(\"\", this.sizeX, \" \"))\13\n\9\9gpu.set(this.posX, this.posY +this.sizeY -1, ut.fillString(\"\", this.sizeX, \" \"))\13\n\9\9gpu.set(this.posX, this.posY, ut.fillString(\"\", this.sizeY, \" \"), true)\13\n\9\9gpu.set(this.posX +this.sizeX -1, this.posY, ut.fillString(\"\", this.sizeY, \" \"), true)\13\n\9else\13\n\9\9gpu.set(this.lastPosX, this.lastPosY, ut.fillString(\"\", this.sizeX, \" \"))\13\n\9\9gpu.set(this.lastPosX, this.lastPosY +this.sizeY -1, ut.fillString(\"\", this.sizeX, \" \"))\13\n\9\9gpu.set(this.lastPosX, this.lastPosY, ut.fillString(\"\", this.sizeY, \" \"), true)\13\n\9\9gpu.set(this.lastPosX +this.sizeX -1, this.lastPosY, ut.fillString(\"\", this.sizeY, \" \"), true)\13\n\9end\13\nend\13\n\13\nreturn OCGF.initiate()\13\n\13\n\13\n\13\n\13\n\13\n",["//libs/"] = 0,["//controls.lua"] = "local controls = {\13\n\9--=== mouse ===--\13\n\9place = 0, --u can hold alt to switch these keys.\13\n\9broke = 1, --u can hold alt to switch these keys.\13\n\9\13\n\9--=== keys ===--\13\n\9left = \"a\",\13\n\9right = \"d\",\13\n\9jump = \"w\",\13\n\9sneak = \"s\",\13\n\9\13\n\9inv = 18,\13\n\9\13\n\9cameraUp = 200, --arrow up\13\n\9cameraDown = 208, --arrow down\13\n\9cameraLeft = 203, --arrow left\13\n\9cameraRight = 205, --arrow right\13\n\9\13\n\9debug = {\13\n\9\9showConsole = 59, --default: 59 (f1)\13\n\9\9showDebug = 61, --default: 61 (f3)\13\n\9\9reloadState = 63, --reloadrs the current state and all data groups defined in the config. default: 63 (f5)\13\n\9\9rerenderScreen = 64, --rerenders the screen (removes graphic errors). default: 64 (f6)\13\n\9}\13\n}\13\n\13\nreturn controls",["//debug/testClass2.lua"] = "local global = ...\13\n\13\nlocal Test2 = {}\13\nTest2.__index = Test2\13\n\13\nfunction Test2.new(args)\13\n\9local this = setmetatable(dofile(\"debug/testClass1.lua\").new(), Test2)\13\n\9\13\n\9this.test = function()\13\n\9\9cprint(\"test3\")\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction Test2.test2()\13\n\9cprint(\"test4\")\13\nend\13\n\13\nreturn Test2",["//debug/animationTest.lua"] = "local fs = require(\"filesystem\")\13\nlocal gpu = require(\"component\").gpu\13\nlocal ocgl = require(\"libs/ocgl\").initiate(gpu)\13\nlocal term = require(\"term\")\13\nlocal keyboard = require(\"keyboard\")\13\nlocal event = require(\"event\")\13\n\13\nterm.clear()\13\n\13\nlocal texture = \"pig\"\13\n\13\nlocal global = {conf = {texturePack = \"default\"}, fs = fs, shell = require(\"shell\")}\13\n\13\nwhile true do\13\n\9gpu.setBackground(0x000000)\13\n\9gpu.fill(1, 1, 1000, 1000, \" \")\13\n\9\13\n\9local t = nil\13\n\9while t == nil do\13\n\9\9t = dofile(\"mods/exampleMod/textures/\" .. texture .. \".lua\")\13\n\9\9os.sleep()\13\n\9end\13\n\9\13\n\9ocgl:draw(2, 10, t)\13\n\9\13\n\9for c = 0, 90, 6 do\13\n\9\9ocgl:draw(15 +c, 10, t)\13\n\9end\13\n\9\13\n\9if keyboard.isKeyDown(\"r\") then\13\n\9\9gpu.setBackground(0x000000)\13\n\9\9gpu.fill(1, 1, 1000, 1000, \" \")\13\n\9end\13\n\9\13\n\9os.sleep(.01)\13\nend\13\n",["//debug/textureTest.lua"] = "local fs = require(\"filesystem\")\13\nlocal gpu = require(\"component\").gpu\13\nlocal ocgl = require(\"libs/ocgl\").initiate(gpu)\13\nlocal term = require(\"term\")\13\nlocal keyboard = require(\"keyboard\")\13\nlocal event = require(\"event\")\13\n\13\nterm.clear()\13\n\13\nlocal texture = \"wheat\"\13\n\13\nlocal global = {conf = {texturePack = \"default\"}, fs = fs, shell = require(\"shell\")}\13\n\13\nwhile true do\13\n\9gpu.setBackground(0x000000)\13\n\9gpu.fill(1, 1, 1000, 1000, \" \")\13\n\9\13\n\9local t = nil\13\n\9while t == nil do\13\n\9\9t = dofile(\"texturePacks/default/textures/\" .. texture .. \".lua\")\13\n\9\9os.sleep()\13\n\9end\13\n\9\13\n\9ocgl:draw(2, 10, t)\13\n\9\13\n\9for c = 0, 90, 6 do\13\n\9\9ocgl:draw(15 +c, 10, t)\13\n\9end\13\n\9\13\n\9if keyboard.isKeyDown(\"r\") then\13\n\9\9gpu.setBackground(0x000000)\13\n\9\9gpu.fill(1, 1, 1000, 1000, \" \")\13\n\9end\13\n\9\13\n\9os.sleep(.01)\13\nend\13\n",["//debug/testTexture.lua"] = "local t2 = {\13\n\9{\"b\", 0xaa770a},\13\n\9{\"f\", 0xbb9933},\13\n\9{1, 0, \"2222\"},\13\n}\13\n\13\nlocal t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.2\",\13\n\9\13\n\9drawCalls = {\13\n\9\9--{0, -1, t2},\13\n\9\9{t2},\13\n\9\9\13\n\9\9{\"b\", 0xa66330a},\13\n\9\9{\"f\", 0xa88660a},\13\n\9\9{1, 1, \"   o\"},\13\n\9\9{1, 2, \"   -\"},\13\n\9\9\13\n\9\9{\"b\", 0x133399},\13\n\9\9{\"f\", 0x0f1155},\13\n\9\9{0, 3, 6, 2, \"#\"},\13\n\9\9\13\n\9\9{\"b\", 0xaa1122},\13\n\9\9{\"f\", 0x660011},\13\n\9\9{1, 5, \"L\"},\13\n\9\9{4, 5, \"L\"},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//debug/testClass1.lua"] = "local global = ...\13\n\13\nlocal Entity = {}\13\nEntity.__index = Entity\13\n\13\nfunction Entity.new(args)\13\n\9local this = setmetatable({}, Entity)\13\n\9\13\n\9this.test = function()\13\n\9\9cprint(\"test\")\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nfunction Entity.test2()\13\n\9cprint(\"test2\")\13\nend\13\n\13\nreturn Entity",["//debug/ocgfTest.lua"] = "--[PROG_NAME] (NNSPT_v1.2)\13\nlocal version = \"v0.0d\"\13\n\13\n--===== Requires =====--\13\nlocal component = require(\"component\")\13\nlocal computer = require(\"computer\")\13\nlocal event = require(\"event\")\13\nlocal term = require(\"term\")\13\nlocal gpu = component.gpu\13\nlocal ocgf = dofile(\"libs/ocgf.lua\")\13\nlocal ocgl = dofile(\"libs/ocgl.lua\").initiate(gpu)\13\nlocal ocui = dofile(\"libs/ocui.lua\").initiate(ocgl)\13\n\13\n--===== Variables =====--\13\nlocal orgPrint = print\13\nlocal textures = {\13\n\9test = dofile(\"texturePacks/default/textures/player.lua\"),\13\n\9test2 = dofile(\"texturePacks/default/textures/dirt.lua\"),\13\n}\13\nlocal animation = dofile(\"debug/testAnimation.lua\")\13\nlocal animation2 = dofile(\"debug/testAnimation2.lua\")\13\nlocal anim = ocgl.Animation.new(ocgl, animation)\13\n\13\nlocal lastTime = computer.uptime()\13\nlocal dt = 0\13\n\13\nlocal clockStart = 0\13\nlocal clockEnd = 0\13\n\13\nlocal textBox = ocui.TextBox.new(ocui, {x=1, y=18, sx=80, sy=30, lineBreak = true, foregroundColor=0xcccccc, backgroundColor=0x333333})\13\n\13\nlocal function textFunc(...) textBox:add(...) end\13\n\13\nlocal gameObject1 = ocgf.GameObject.new(ocgf, {dt = true, dc = true, logFunc = textFunc, x = 20})\13\nlocal gameObject2 = ocgf.GameObject.new(ocgf, {dt = true, dc = true, logFunc = textFunc})\13\nlocal gameObject3 = ocgf.GameObject.new(ocgf, {dt = true, dc = true, logFunc = textFunc})\13\n\13\ngameObject1:addBoxCollider({sx = 7, sy = 4, x = 0, y = 0, lf = function(this) this.gameObject.log(computer.uptime() - clockStart) end, n = \"collider1\"})\13\ngameObject1:addRigidBody({mass = 1, g = 5, stiffness = .5})\13\ngameObject1:addBoxTrigger({x = 0, y = 0, sx = 3, sy = 10, lf = function()\13\n\9\13\nend})\13\n--gameObject1:addSprite({x = 0, y = -6, t = textures.test})\13\ngameObject1:addSprite({x = 0, y = -6, t = textures.test})\13\n\13\ngameObject2:addBoxCollider({sx = 50, sy = 3, x = 8, y = 17, lf = function(this) this.gameObject.log(\"trigger2\") end, n = \"collider2\"})\13\ngameObject2:addRigidBody({stiffness = -1})\13\n\13\n\13\ngameObject3:addBoxCollider({sx = 3, sy = 4, x = 10, y = 2, n = \"collider1\"})\13\n\13\n--===== Functions =====--\13\nlocal function print(text)\13\n\9textBox:add(text)\13\nend\13\n\13\nlocal function start()\13\n\9term.clear()\13\n\9--gameObject1:moveTo(10, 10)\13\n\9\13\n\9gameObject1:getSprites()\13\n\9\13\n\9for _, s in pairs(gameObject1:getSprites()) do\13\n\9\9s:changeTexture(animation2)\13\n\9end\13\n\9\13\n\9clockStart = computer.uptime()\13\nend\13\n\13\nlocal function update()\9\13\n\9gameObject1:update({gameObject2, gameObject3})\13\n\9gameObject1:updatePhx({gameObject2, gameObject3}, dt)\13\n\9--textFunc(gameObject1.rigidBodys[1].update)\13\nend\13\n\13\nlocal c = 1\13\nlocal function draw()\13\n\9gpu.setBackground(0x000000)\13\n\9--gpu.fill(1, 1, 100, 100, \" \")\13\n\9\13\n\9gameObject1:clear()\13\n\9\13\n\9gameObject1:draw()\13\n\9gameObject2:draw()\13\n\9gameObject3:draw()\13\n\9\13\n\9ocui:draw()\13\n\9--event.push(\"key_down\", 3, 3) --stops program\13\n\9gpu.set(1, 1, \"DT: \" .. tostring(dt))\13\nend\13\n\13\nlocal function touch(_, _, x, y, _, _)\13\n\9\13\nend\13\n\13\nlocal function keyDown(_, _, c, k, _, _)\13\n\9if c == 119 then --w\13\n\9\9gameObject1:addForce(0, -2)\13\n\9end\13\n\9if c == 97 then --a\13\n\9\9gameObject1:addForce(-1, 0)\13\n\9end\13\n\9if c == 115 then --s\13\n\9\9gameObject1:addForce(0, 1)\13\n\9end\13\n\9if c == 100 then --d\13\n\9\9gameObject1:addForce(1, 0)\13\n\9end\13\n\9\13\n\9if c == 114 then\13\n\9\9gameObject1:moveTo(0, 0)\13\n\9\9print(\"RESET\")\13\n\9end\13\nend\13\n\13\nlocal function progamEnd()\13\n\9event.ignore(\"touch\", touch)\13\n\9event.ignore(\"key_down\", keyDown)\13\nend\13\n\13\n--===== Event listening =====--\13\nevent.listen(\"touch\", touch)\13\nevent.listen(\"key_down\", keyDown)\13\n\13\n--===== std program structure / main while =====--\13\nlocal std_sleepTime = .1\13\nlocal std_programIsRunning = true\13\nlocal std_previousScreenResolution = {gpu.getResolution()}\13\nlocal function std_onError(f, ...)\13\n\9print = orgPrint\13\n\9std_programIsRunning = false\13\n\9gpu.setForeground(0xff0000)\13\n\9gpu.setBackground(0x000000)\13\n\9print(\"[ERROR] in func: \" .. f)\13\n\9print(...)\13\n\9gpu.setForeground(0xffffff)\13\nend\13\n\13\nlocal s, m = xpcall(start, debug.traceback)\13\nif s == false then\13\n\9std_onError(\"start()\", m, debug.traceback())\13\nend\13\n\13\nwhile std_programIsRunning do\13\n\9local s, m = xpcall(update, debug.traceback)\13\n\9if s == false then\13\n\9\9std_onError(\"update()\", m, debug.traceback())\13\n\9\9break\13\n\9end\13\n\9\13\n\9local s, m = xpcall(draw, debug.traceback)\13\n\9if s == false then\13\n\9\9std_onError(\"draw()\", m, debug.traceback())\13\n\9\9break\13\n\9end\13\n\9\13\n\9--local _, _, key = event.pull(\"key_down\")\13\n\9local _, _, key = event.pull(std_sleepTime, \"key_down\")\13\n\9if key == 3 then --ctrl+c\13\n\9\9std_programIsRunning = false\13\n\9\9break\13\n\9end\13\n\9dt = computer.uptime() - lastTime\13\n\9lastTime = computer.uptime()\13\nend\13\n\13\nprogamEnd()\13\ngpu.setForeground(0xffffff)\13\ngpu.setBackground(0x000000)\13\ngpu.setResolution(std_previousScreenResolution[1], std_previousScreenResolution[2])\13\n",["//debug/ocglTest.lua"] = "--[PROG_NAME] (NNSPT_v1.2)\13\nlocal version = \"v0.0\"\13\n\13\n--===== Requires =====--\13\nlocal component = require(\"component\")\13\nlocal computer = require(\"computer\")\13\nlocal event = require(\"event\")\13\nlocal term = require(\"term\")\13\nlocal serialization = require(\"serialization\")\13\nlocal gpu = component.gpu\13\nlocal mainOcgl = dofile(\"libs/ocgl.lua\").initiate(gpu)\13\nlocal ocui = dofile(\"libs/ocui.lua\").initiate(mainOcgl)\13\nlocal ocgl = dofile(\"libs/ocgl.lua\").initiate(gpu)\13\n\13\n--===== Variables =====--\13\nlocal consoleSizeY = 30\13\n\13\nlocal orgPrint = print\13\nlocal texture = dofile(\"debug/testTexture.lua\")\13\nlocal animation = dofile(\"debug/testAnimation.lua\")\13\nlocal background = dofile(\"texturePacks/default/textures/grass.lua\")\13\n\13\nlocal tbConsole = ocui.TextBox.new(ocui, {x=1, y=10, sx=0, sy=0, lineBreak = true, foregroundColor=0xcccccc, backgroundColor=0x333333})\13\n\13\nlocal anim = ocgl.Animation.new(ocgl, animation, {})\13\n\13\n--===== Functions =====--\13\nlocal function print(...)\13\n\9tbConsole:add(...)\13\nend\13\nfunction cprint(...)\13\n\9tbConsole:add(...)\13\nend\13\nfunction sprint(...)\13\n\9tbConsole:add(serialization.serialize(...))\13\n\9ocui:draw()\13\nend\13\n\13\nlocal function start()\13\n\9term.clear()\13\n\9local resX, resY = gpu.getResolution()\13\n\9tbConsole.sizeX = resX\13\n\9tbConsole.sizeY = resY - (resY - consoleSizeY)\13\n\9tbConsole.posY = resY - consoleSizeY\13\n\9\13\nend\13\n\13\nlocal function update()\13\n\9texture = dofile(\"debug/testTexture.lua\")\13\n\9\13\nend\13\n\13\nlocal function draw()\13\n\9gpu.setBackground(0x000000)\13\n\9--term.clear()\13\n\9--cgl:draw(40, 1, texture)\13\n\9anim:stop(nil, true)\13\n\9anim:play(-1)\13\n\9anim:draw(40, 1, .1)\13\n\9\13\n\9\13\n\9gpu.set(1, 1, tostring(anim.currentFrame))\13\n\9gpu.set(1, 2, tostring(anim.lastFrame))\13\n\9\13\n\9ocui:draw()\13\nend\13\n\13\nlocal function touch(_, _, x, y, _, _)\13\n\9\13\nend\13\n\13\nlocal function progamEnd()\13\n\9event.ignore(\"touch\", touch)\13\nend\13\n\13\n--===== Event listening =====--\13\nevent.listen(\"touch\", touch)\13\n\13\n--===== std program structure / main while =====--\13\n--local std_sleepTime = 2^32\13\nlocal std_sleepTime = .1\13\nlocal std_programIsRunning = true\13\nlocal std_previousScreenResolution = {gpu.getResolution()}\13\nlocal function std_onError(f, ...)\13\n\9print = orgPrint\13\n\9std_programIsRunning = false\13\n\9gpu.setForeground(0xff0000)\13\n\9gpu.setBackground(0x000000)\13\n\9print(\"[ERROR] in func: \" .. f)\13\n\9print(...)\13\n\9gpu.setForeground(0xffffff)\13\nend\13\n\13\nlocal s, m = xpcall(start, debug.traceback)\13\nif s == false then\13\n\9std_onError(\"start()\", m, debug.traceback())\13\nend\13\n\13\nwhile std_programIsRunning do\13\n\9local s, m = xpcall(update, debug.traceback)\13\n\9if s == false then\13\n\9\9std_onError(\"update()\", m, debug.traceback())\13\n\9\9break\13\n\9end\13\n\9\13\n\9local s, m = xpcall(draw, debug.traceback)\13\n\9if s == false then\13\n\9\9std_onError(\"draw()\", m, debug.traceback())\13\n\9\9break\13\n\9end\13\n\9\13\n\9local _, _, key = event.pull(std_sleepTime, \"key_down\")\13\n\9if key == 3 then --ctrl+c\13\n\9\9std_programIsRunning = false\13\n\9\9break\13\n\9end\13\nend\13\n\13\nprogamEnd()\13\ngpu.setForeground(0xffffff)\13\ngpu.setBackground(0x000000)\13\ngpu.setResolution(std_previousScreenResolution[1], std_previousScreenResolution[2])\13\n",["//debug/test.lua"] = "local fs = require(\"filesystem\")\13\nlocal gpu = require(\"component\").gpu\13\nlocal ocgl = require(\"libs/ocgl\").initiate(gpu)\13\nlocal term = require(\"term\")\13\nlocal keyboard = require(\"keyboard\")\13\nlocal event = require(\"event\")\13\nlocal computer = require(\"computer\")\13\nlocal serialize = require(\"serialization\").serialize\13\n\13\n--term.clear()\13\n\13\n\13\n--[[\13\ncprint = print\13\n\13\nlocal t1 = dofile(\"debug/testClass1.lua\").new()\13\nlocal t2 = dofile(\"debug/testClass2.lua\").new()\13\n\13\nt1.test()\13\nt1.test2()\13\n\13\nt2.test()\13\nt2.test2()\13\n]]\13\n--[[\13\nlocal texture = dofile(\"texturePacks/default/testTexture.lua\")\13\n\13\nlocal lt, dt = computer.uptime(), 0\13\n\13\nwhile true do\13\n\9--gpu.setBackground(0x000000)\13\n\9--gpu.fill(1, 1, 1000, 1000, \" \")\13\n\9\13\n\9for c = 0, 10 do\13\n\9\9ocgl:draw(10, 10, texture)\13\n\9end\13\n\9\13\n\9\13\n\9dt = computer.uptime() -lt\13\n\9lt = computer.uptime()\13\n\9\13\n\9os.sleep()\13\n\9gpu.set(1, 1, tostring(dt) .. \"                        \")\13\n\9if dt > 0.05 then\13\n\9\9--print(\">\")\13\n\9end\13\nend\13\n]]",["//debug/testAnimation2.lua"] = "local body = {\13\n\9{\"b\", 0xaa770a},\13\n\9{\"f\", 0xbb9933},\13\n\9{1, 0, \"2222\"},\13\n\9\13\n\9{\"b\", 0xa66330a},\13\n\9{\"f\", 0xa88660a},\13\n\9{1, 1, \"   o\"},\13\n\9{1, 2, \"   -\"},\13\n\9\13\n\9{\"b\", 0x993311},\13\n\9{\"f\", 0x0f1155},\13\n\9{0, 3, 6, 2, \"#\"},\13\n}\13\n\13\nlocal colors = {\13\n\9legs = {\13\n\9\9{\"b\", 0xaa1122},\13\n\9\9{\"f\", 0x000000},\13\n\9},\13\n}\13\n\13\nlocal legs = {\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{1, 5, \" \"},\13\n\9\9{4, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{1, 5, \"â–„\"},\13\n\9\9{4, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{2, 5, \"â–„\"},\13\n\9\9{3, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{3, 5, \"â–„\"},\13\n\9\9{2, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{4, 5, \"â–„\"},\13\n\9\9{1, 5, \" \"},\13\n\9},\13\n}\13\n\13\nlocal t = {\13\n\9format = \"OCGLA\",\13\n\9version = \"v0.1\",\13\n\9frameTime = .1,\13\n\9\13\n\9frames = {\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[1]},\13\n\9\9},\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[2]},\13\n\9\9},\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[3]},\13\n\9\9},\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[4]},\13\n\9\9},\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[5]},\13\n\9\9},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//debug/export.lua"] = "local licenseNotice = [[\13\n\9export Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This program is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    This program is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\n--[[A very simple project exporter.\13\n\9Written by:\13\n\9\9MisterNoNameLP.\13\n]]\13\nlocal version = \"v1.0.4\"\13\n\13\nlocal installScript = [[\13\n--===== local functions =====--\13\nfunction seperatePath(path) --Ripped from UT_v0.6.1\13\n--seperates a data path [\"./DIR/FILE.ENDING\"] into the dir path [\"./DIR/\"], the file name [\"FILE\"], and the file ending [\".ENDING\" or nil]\13\n\9if string.sub(path, #path) == \"/\" then\13\n\9\9return path\13\n\9end\13\n\9\13\n\9local dir, fileName, fileEnd = \"\", \"\", nil\13\n\9local tmpLatest = \"\"\13\n\9for s in string.gmatch(tostring(path), \"[^/]+\") do\13\n\9\9tmpLatest = s\13\n\9end\13\n\9dir = string.sub(path, 0, #path -#tmpLatest)\13\n\9for s in string.gmatch(tostring(tmpLatest), \"[^.]+\") do\13\n\9\9fileName = fileName .. s\13\n\9\9tmpLatest = s\13\n\9end\13\n\9if fileName == tmpLatest then\13\n\9\9fileName = tmpLatest\13\n\9else\13\n\9\9fileEnd = \".\" .. tmpLatest\13\n\9\9fileName = string.sub(fileName, 0, #fileName - #fileEnd +1)\13\n\9end\13\n\9\13\n\9return dir, fileName, fileEnd\13\nend\13\n\13\n--===== prog start =====--\13\nlocal fs = require(\"filesystem\")\13\nlocal shell = require(\"shell\")\13\nlocal serialization = require(\"serialization\")\13\n\13\nlocal args, opts = shell.parse(...)\13\nlocal emptyBufferSpace = 10\13\n\13\nif opts.h or #args == 0 then\13\n\9\13\n\9print(\"Usage: SETUP [OPTIONS]... [TARGET_DIR]...\")\13\n\9print(\"  -h\9\9\9Shows this text.\")\13\n\9print(\"  -o \9\9\9Overwrite the EXPORT_DIR.\")\13\n\9\13\n\9return true\13\nend\13\n\13\nprint(licenseNotice)\13\n\13\nif not opts.o then\13\n\9if string.sub(args[1], 0, 1) == \"/\" and fs.exists(args[1]) then\13\n\9\9return false, \"Folder exists already.\"\13\n\9elseif fs.exists(shell.getWorkingDirectory() .. args[1]) then\13\n\9\9return false, \"Folder exists already.\"\13\n\9end\13\nend\13\n\13\nfor i, s in pairs(data) do\13\n\9local path, file, ending = seperatePath(i)\13\n\9file = (file or \"\") .. (ending or \"\")\13\n\9if string.sub(args[1], 0, 1) == \"/\" then\13\n\9\9path = \"/\" .. args[1] .. \"/\" .. (path or \"\")\13\n\9else\13\n\9\9path = shell.getWorkingDirectory() .. \"/\" .. args[1] .. \"/\" .. (path or \"\")\13\n\9end\13\n\9\13\n\9print(\"Create file: \" .. path .. file)\13\n\9\13\n\9fs.makeDirectory(path)\13\n\9if s ~= 0 then\13\n\9\9local f = io.open(path .. file, \"w\")\13\n\9\9for c = 1, #s, (f.bufferSize - emptyBufferSpace) +1 do\13\n\9\9\9f:write(string.sub(s, c, c + f.bufferSize - emptyBufferSpace))\13\n\9\9\9f:flush()\13\n\9\9end\13\n\9\9f:close()\13\n\9end\13\nend\13\n]]\13\n\13\nlocal fs = require(\"filesystem\")\13\nlocal shell = require(\"shell\")\13\nlocal serialization = require(\"serialization\")\13\n\13\nlocal args, opts = shell.parse(...)\13\n\13\nlocal dirs = 0\13\nlocal files = 0\13\nlocal linesOfCode = 0\13\nlocal exportFile = nil\13\nlocal relativePath = \"\"\13\n\13\nlocal function write(file, s, emptyBufferSpace)\13\n\9emptyBufferSpace = emptyBufferSpace or 10\13\n\9for c = 1, #s, (file.bufferSize - emptyBufferSpace) +1 do\13\n\9\9file:write(string.sub(s, c, c + file.bufferSize - emptyBufferSpace))\13\n\9\9file:flush()\13\n\9end\13\nend\13\n\13\nlocal function parseFiles(path, countLines, export)\13\n\9if string.sub(path, 0, 1) ~= \"/\"  then\13\n\9\9path = path or \"\"\13\n\9\9path = shell.getWorkingDirectory() .. \"/\" .. path .. \"/\"\13\n\9\9relativePath = shell.getWorkingDirectory()\13\n\9end\13\n\9print(path)\13\n\9for file in fs.list(path) do\13\n\9\9if string.sub(file, #file) == \"/\" then\13\n\9\9\9parseFiles(path .. file, countLines, export)\13\n\9\9\9dirs = dirs +1\13\n\9\9\9if export then\13\n\9\9\9\9write(exportFile, \"[\\\"\" .. string.sub(path .. file, #relativePath + #args[1] +1) .. \"\\\"] = 0,\")\13\n\9\9\9end\13\n\9\9else\13\n\9\9\9local tmpPath = \"/\" .. path .. file\13\n\9\9\9\13\n\9\9\9if export then\13\n\9\9\9\9\13\n\9\9\9\9local emptyBufferSpace = #tmpPath +20\13\n\9\9\9\9local f = io.open(tmpPath, \"r\")\13\n\9\9\9\9local ss = serialization.serialize(f:read(\"*all\"))\13\n\9\9\9\9f:close()\13\n\9\9\9\9\13\n\9\9\9\9write(exportFile, \"[\\\"\" .. string.sub(path .. file, #relativePath + #args[1] +1) .. \"\\\"] = \", emptyBufferSpace)\13\n\9\9\9\9write(exportFile, ss, emptyBufferSpace)\13\n\9\9\9\9exportFile:write(\",\")\13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9if countLines then\13\n\9\9\9\9files = files +1\13\n\9\9\9\9for l in io.lines(tmpPath) do\13\n\9\9\9\9\9linesOfCode = linesOfCode +1\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\nend\13\n\13\nif opts.v then\13\n\9print(\"exporter \" .. version)\13\n\9if not opts.h then\13\n\9\9return true\13\n\9end\13\nend\13\n\13\nif opts.h or #args == 0 then\13\n\9print([[\13\nUsage: export [OPTIONS]... [DIR]... [EXPORT_FILE]...\13\n  -e\9\9\9Exports the DIR with all sub dirs/files as installer script to EXPORT_FILE.\13\n  -h\9\9\9Shows this text.\13\n  -i \9\9\9Collects some infos (dirs, files, lines of text) about DIR with all sub dirs/files (can take a while on big projects).\13\n  -o \9\9\9Overwrite the EXPORT_FILE.\13\n\9]])\13\n\9return true\13\nend\13\n\13\nif opts.e then\13\n\9if args[2] == nil then\13\n\9\9return false, \"No export file name given.\"\13\n\9end\13\n\9\13\n\9if io.open(args[2], \"r\") == nil or opts.o then\13\n\9\9exportFile = io.open(args[2], \"w\")\13\n\9\9write(exportFile, \"local licenseNotice = [[This installation script is createt by MisterNoNameLPs OC project exporter \" .. version .. \" <https://github.com/MisterNoNameLP/ocCraft/blob/master/src/debug/export.lua>.\\n\")\13\n\9\9\13\n\9\9write(exportFile, \"\\nThis installer DO NOT give ANY WARRANTY for stored/installed data.\\n\")\13\n\9\9write(exportFile, \"All stored/installed data are third party content i am not responsible for. \\n\")\13\n\9\9\13\n\9\9write(exportFile, \"\\n\" .. licenseNotice .. \"]]\\n\")\13\n\9\9\13\n\9\9write(exportFile, \"local data = {\")\13\n\9else\13\n\9\9return false, \"File are existing already.\"\13\n\9end\13\nend\13\n\13\nparseFiles(args[1], opts.i, opts.e)\13\n\13\nif opts.e then\13\n\9exportFile:write(\"} \\n\")\13\n\9\13\n\9write(exportFile, installScript, 10)\13\n\9\13\n\9exportFile:close()\13\nend\13\n\13\nif opts.i then\13\n\9print(\"--===== Project infos =====--\")\13\n\9print(\"folders: \" .. tostring(dirs) .. \" | files: \" .. tostring(files) .. \" | lines: \" .. tostring(linesOfCode))\13\nend\13\n",["//debug/ocuiTest.lua"] = "--[PROG_NAME] (NNSPT_v1.2)\13\nlocal version = \"v0.0d\"\13\n\13\n--===== Requires =====--\13\nlocal component = require(\"component\")\13\nlocal computer = require(\"computer\")\13\nlocal event = require(\"event\")\13\nlocal term = require(\"term\")\13\nlocal gpu = component.gpu\13\nlocal ocgf = dofile(\"libs/ocgf.lua\")\13\nlocal ocgl = dofile(\"libs/ocgl.lua\").initiate(gpu)\13\nlocal ocui = dofile(\"libs/ocui.lua\").initiate(ocgl)\13\n\13\n--===== Variables =====--\13\nlocal orgPrint = print\13\nlocal textures = {\13\n\9test = dofile(\"texturePacks/default/textures/player.lua\"),\9\13\n}\13\n\13\nlocal lastTime = computer.uptime()\13\nlocal dt = 0\13\n\13\nlocal clockStart = 0\13\nlocal clockEnd = 0\13\n\13\nlocal textBox = ocui.TextBox.new(ocui, {x=1, y=18, sx=80, sy=30, lineBreak = true, foregroundColor=0xcccccc, backgroundColor=0x333333})\13\n\13\n\13\n\13\n--===== Functions =====--\13\nlocal function print(text)\13\n\9textBox:add(text)\13\nend\13\n\13\nlocal function start()\13\n\9term.clear()\13\n\9\13\n\9--loadfile(\"test.lua\")()\13\n\9local suc, err = xpcall(loadfile(\"test.lua\"), debug.traceback)\13\n\9\13\n\9orgPrint(err)\13\n\9orgPrint(\"====================================================\")\13\n\9\13\n\9print(err)\13\n\9--print(\"test ocCraft test\")\13\nend\13\n\13\nlocal function update()\9\13\n\9\13\nend\13\n\13\nlocal c = 1\13\nlocal function draw()\13\n\9ocui:draw()\13\nend\13\n\13\nlocal function touch(_, _, x, y, _, _)\13\n\9ocui:update(x, y)\13\nend\13\n\13\nlocal function keyDown(_, _, c, k, _, _)\13\n\9if c == 119 then --w\13\n\9\9gameObject1:addForce(0, -2)\13\n\9end\13\n\9if c == 97 then --a\13\n\9\9gameObject1:addForce(-1, 0)\13\n\9end\13\n\9if c == 115 then --s\13\n\9\9gameObject1:addForce(0, 1)\13\n\9end\13\n\9if c == 100 then --d\13\n\9\9gameObject1:addForce(1, 0)\13\n\9end\13\n\9\13\n\9if c == 114 then\13\n\9\9gameObject1:moveTo(0, 0)\13\n\9\9print(\"RESET\")\13\n\9end\13\nend\13\n\13\nlocal function progamEnd()\13\n\9event.ignore(\"touch\", touch)\13\n\9event.ignore(\"key_down\", keyDown)\13\nend\13\n\13\n--===== Event listening =====--\13\nevent.listen(\"touch\", touch)\13\nevent.listen(\"key_down\", keyDown)\13\n\13\n--===== std program structure / main while =====--\13\nlocal std_sleepTime = .1\13\nlocal std_programIsRunning = true\13\nlocal std_previousScreenResolution = {gpu.getResolution()}\13\nlocal function std_onError(f, ...)\13\n\9print = orgPrint\13\n\9std_programIsRunning = false\13\n\9gpu.setForeground(0xff0000)\13\n\9gpu.setBackground(0x000000)\13\n\9print(\"[ERROR] in func: \" .. f)\13\n\9print(...)\13\n\9gpu.setForeground(0xffffff)\13\nend\13\n\13\nlocal s, m = xpcall(start, debug.traceback)\13\nif s == false then\13\n\9std_onError(\"start()\", m, debug.traceback())\13\nend\13\n\13\nwhile std_programIsRunning do\13\n\9local s, m = xpcall(update, debug.traceback)\13\n\9if s == false then\13\n\9\9std_onError(\"update()\", m, debug.traceback())\13\n\9\9break\13\n\9end\13\n\9\13\n\9local s, m = xpcall(draw, debug.traceback)\13\n\9if s == false then\13\n\9\9std_onError(\"draw()\", m, debug.traceback())\13\n\9\9break\13\n\9end\13\n\9\13\n\9--local _, _, key = event.pull(\"key_down\")\13\n\9local _, _, key = event.pull(std_sleepTime, \"key_down\")\13\n\9if key == 3 then --ctrl+c\13\n\9\9std_programIsRunning = false\13\n\9\9break\13\n\9end\13\n\9dt = computer.uptime() - lastTime\13\n\9lastTime = computer.uptime()\13\nend\13\n\13\nprogamEnd()\13\ngpu.setForeground(0xffffff)\13\ngpu.setBackground(0x000000)\13\ngpu.setResolution(std_previousScreenResolution[1], std_previousScreenResolution[2])\13\n",["//debug/testAnimation.lua"] = "local body = {\13\n\9{\"b\", 0xaa770a},\13\n\9{\"f\", 0xbb9933},\13\n\9{1, 0, \"2222\"},\13\n\9\13\n\9{\"b\", 0xa66330a},\13\n\9{\"f\", 0xa88660a},\13\n\9{1, 1, \"   o\"},\13\n\9{1, 2, \"   -\"},\13\n\9\13\n\9{\"b\", 0x133399},\13\n\9{\"f\", 0x0f1155},\13\n\9{0, 3, 6, 2, \"#\"},\13\n}\13\n\13\nlocal colors = {\13\n\9legs = {\13\n\9\9{\"b\", 0xaa1122},\13\n\9\9{\"f\", 0x000000},\13\n\9},\13\n}\13\n\13\nlocal legs = {\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{1, 5, \" \"},\13\n\9\9{4, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{1, 5, \"â–„\"},\13\n\9\9{4, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{2, 5, \"â–„\"},\13\n\9\9{3, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{3, 5, \"â–„\"},\13\n\9\9{2, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{4, 5, \"â–„\"},\13\n\9\9{1, 5, \" \"},\13\n\9},\13\n}\13\n\13\nlocal t = {\13\n\9format = \"OCGLA\",\13\n\9version = \"v0.1\",\13\n\9frameTime = .1,\13\n\9\13\n\9frames = {\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[1]},\13\n\9\9},\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[2]},\13\n\9\9},\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[3]},\13\n\9\9},\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[4]},\13\n\9\9},\13\n\9\9{\13\n\9\9\9{body},\13\n\9\9\9{legs[5]},\13\n\9\9},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//debug/"] = 0,["//COPYING"] = "                    GNU GENERAL PUBLIC LICENSE\13\n                       Version 3, 29 June 2007\13\n\13\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\13\n Everyone is permitted to copy and distribute verbatim copies\13\n of this license document, but changing it is not allowed.\13\n\13\n                            Preamble\13\n\13\n  The GNU General Public License is a free, copyleft license for\13\nsoftware and other kinds of works.\13\n\13\n  The licenses for most software and other practical works are designed\13\nto take away your freedom to share and change the works.  By contrast,\13\nthe GNU General Public License is intended to guarantee your freedom to\13\nshare and change all versions of a program--to make sure it remains free\13\nsoftware for all its users.  We, the Free Software Foundation, use the\13\nGNU General Public License for most of our software; it applies also to\13\nany other work released this way by its authors.  You can apply it to\13\nyour programs, too.\13\n\13\n  When we speak of free software, we are referring to freedom, not\13\nprice.  Our General Public Licenses are designed to make sure that you\13\nhave the freedom to distribute copies of free software (and charge for\13\nthem if you wish), that you receive source code or can get it if you\13\nwant it, that you can change the software or use pieces of it in new\13\nfree programs, and that you know you can do these things.\13\n\13\n  To protect your rights, we need to prevent others from denying you\13\nthese rights or asking you to surrender the rights.  Therefore, you have\13\ncertain responsibilities if you distribute copies of the software, or if\13\nyou modify it: responsibilities to respect the freedom of others.\13\n\13\n  For example, if you distribute copies of such a program, whether\13\ngratis or for a fee, you must pass on to the recipients the same\13\nfreedoms that you received.  You must make sure that they, too, receive\13\nor can get the source code.  And you must show them these terms so they\13\nknow their rights.\13\n\13\n  Developers that use the GNU GPL protect your rights with two steps:\13\n(1) assert copyright on the software, and (2) offer you this License\13\ngiving you legal permission to copy, distribute and/or modify it.\13\n\13\n  For the developers' and authors' protection, the GPL clearly explains\13\nthat there is no warranty for this free software.  For both users' and\13\nauthors' sake, the GPL requires that modified versions be marked as\13\nchanged, so that their problems will not be attributed erroneously to\13\nauthors of previous versions.\13\n\13\n  Some devices are designed to deny users access to install or run\13\nmodified versions of the software inside them, although the manufacturer\13\ncan do so.  This is fundamentally incompatible with the aim of\13\nprotecting users' freedom to change the software.  The systematic\13\npattern of such abuse occurs in the area of products for individuals to\13\nuse, which is precisely where it is most unacceptable.  Therefore, we\13\nhave designed this version of the GPL to prohibit the practice for those\13\nproducts.  If such problems arise substantially in other domains, we\13\nstand ready to extend this provision to those domains in future versions\13\nof the GPL, as needed to protect the freedom of users.\13\n\13\n  Finally, every program is threatened constantly by software patents.\13\nStates should not allow patents to restrict development and use of\13\nsoftware on general-purpose computers, but in those that do, we wish to\13\navoid the special danger that patents applied to a free program could\13\nmake it effectively proprietary.  To prevent this, the GPL assures that\13\npatents cannot be used to render the program non-free.\13\n\13\n  The precise terms and conditions for copying, distribution and\13\nmodification follow.\13\n\13\n                       TERMS AND CONDITIONS\13\n\13\n  0. Definitions.\13\n\13\n  \"This License\" refers to version 3 of the GNU General Public License.\13\n\13\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\13\nworks, such as semiconductor masks.\13\n\13\n  \"The Program\" refers to any copyrightable work licensed under this\13\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\13\n\"recipients\" may be individuals or organizations.\13\n\13\n  To \"modify\" a work means to copy from or adapt all or part of the work\13\nin a fashion requiring copyright permission, other than the making of an\13\nexact copy.  The resulting work is called a \"modified version\" of the\13\nearlier work or a work \"based on\" the earlier work.\13\n\13\n  A \"covered work\" means either the unmodified Program or a work based\13\non the Program.\13\n\13\n  To \"propagate\" a work means to do anything with it that, without\13\npermission, would make you directly or secondarily liable for\13\ninfringement under applicable copyright law, except executing it on a\13\ncomputer or modifying a private copy.  Propagation includes copying,\13\ndistribution (with or without modification), making available to the\13\npublic, and in some countries other activities as well.\13\n\13\n  To \"convey\" a work means any kind of propagation that enables other\13\nparties to make or receive copies.  Mere interaction with a user through\13\na computer network, with no transfer of a copy, is not conveying.\13\n\13\n  An interactive user interface displays \"Appropriate Legal Notices\"\13\nto the extent that it includes a convenient and prominently visible\13\nfeature that (1) displays an appropriate copyright notice, and (2)\13\ntells the user that there is no warranty for the work (except to the\13\nextent that warranties are provided), that licensees may convey the\13\nwork under this License, and how to view a copy of this License.  If\13\nthe interface presents a list of user commands or options, such as a\13\nmenu, a prominent item in the list meets this criterion.\13\n\13\n  1. Source Code.\13\n\13\n  The \"source code\" for a work means the preferred form of the work\13\nfor making modifications to it.  \"Object code\" means any non-source\13\nform of a work.\13\n\13\n  A \"Standard Interface\" means an interface that either is an official\13\nstandard defined by a recognized standards body, or, in the case of\13\ninterfaces specified for a particular programming language, one that\13\nis widely used among developers working in that language.\13\n\13\n  The \"System Libraries\" of an executable work include anything, other\13\nthan the work as a whole, that (a) is included in the normal form of\13\npackaging a Major Component, but which is not part of that Major\13\nComponent, and (b) serves only to enable use of the work with that\13\nMajor Component, or to implement a Standard Interface for which an\13\nimplementation is available to the public in source code form.  A\13\n\"Major Component\", in this context, means a major essential component\13\n(kernel, window system, and so on) of the specific operating system\13\n(if any) on which the executable work runs, or a compiler used to\13\nproduce the work, or an object code interpreter used to run it.\13\n\13\n  The \"Corresponding Source\" for a work in object code form means all\13\nthe source code needed to generate, install, and (for an executable\13\nwork) run the object code and to modify the work, including scripts to\13\ncontrol those activities.  However, it does not include the work's\13\nSystem Libraries, or general-purpose tools or generally available free\13\nprograms which are used unmodified in performing those activities but\13\nwhich are not part of the work.  For example, Corresponding Source\13\nincludes interface definition files associated with source files for\13\nthe work, and the source code for shared libraries and dynamically\13\nlinked subprograms that the work is specifically designed to require,\13\nsuch as by intimate data communication or control flow between those\13\nsubprograms and other parts of the work.\13\n\13\n  The Corresponding Source need not include anything that users\13\ncan regenerate automatically from other parts of the Corresponding\13\nSource.\13\n\13\n  The Corresponding Source for a work in source code form is that\13\nsame work.\13\n\13\n  2. Basic Permissions.\13\n\13\n  All rights granted under this License are granted for the term of\13\ncopyright on the Program, and are irrevocable provided the stated\13\nconditions are met.  This License explicitly affirms your unlimited\13\npermission to run the unmodified Program.  The output from running a\13\ncovered work is covered by this License only if the output, given its\13\ncontent, constitutes a covered work.  This License acknowledges your\13\nrights of fair use or other equivalent, as provided by copyright law.\13\n\13\n  You may make, run and propagate covered works that you do not\13\nconvey, without conditions so long as your license otherwise remains\13\nin force.  You may convey covered works to others for the sole purpose\13\nof having them make modifications exclusively for you, or provide you\13\nwith facilities for running those works, provided that you comply with\13\nthe terms of this License in conveying all material for which you do\13\nnot control copyright.  Those thus making or running the covered works\13\nfor you must do so exclusively on your behalf, under your direction\13\nand control, on terms that prohibit them from making any copies of\13\nyour copyrighted material outside their relationship with you.\13\n\13\n  Conveying under any other circumstances is permitted solely under\13\nthe conditions stated below.  Sublicensing is not allowed; section 10\13\nmakes it unnecessary.\13\n\13\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\13\n\13\n  No covered work shall be deemed part of an effective technological\13\nmeasure under any applicable law fulfilling obligations under article\13\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\13\nsimilar laws prohibiting or restricting circumvention of such\13\nmeasures.\13\n\13\n  When you convey a covered work, you waive any legal power to forbid\13\ncircumvention of technological measures to the extent such circumvention\13\nis effected by exercising rights under this License with respect to\13\nthe covered work, and you disclaim any intention to limit operation or\13\nmodification of the work as a means of enforcing, against the work's\13\nusers, your or third parties' legal rights to forbid circumvention of\13\ntechnological measures.\13\n\13\n  4. Conveying Verbatim Copies.\13\n\13\n  You may convey verbatim copies of the Program's source code as you\13\nreceive it, in any medium, provided that you conspicuously and\13\nappropriately publish on each copy an appropriate copyright notice;\13\nkeep intact all notices stating that this License and any\13\nnon-permissive terms added in accord with section 7 apply to the code;\13\nkeep intact all notices of the absence of any warranty; and give all\13\nrecipients a copy of this License along with the Program.\13\n\13\n  You may charge any price or no price for each copy that you convey,\13\nand you may offer support or warranty protection for a fee.\13\n\13\n  5. Conveying Modified Source Versions.\13\n\13\n  You may convey a work based on the Program, or the modifications to\13\nproduce it from the Program, in the form of source code under the\13\nterms of section 4, provided that you also meet all of these conditions:\13\n\13\n    a) The work must carry prominent notices stating that you modified\13\n    it, and giving a relevant date.\13\n\13\n    b) The work must carry prominent notices stating that it is\13\n    released under this License and any conditions added under section\13\n    7.  This requirement modifies the requirement in section 4 to\13\n    \"keep intact all notices\".\13\n\13\n    c) You must license the entire work, as a whole, under this\13\n    License to anyone who comes into possession of a copy.  This\13\n    License will therefore apply, along with any applicable section 7\13\n    additional terms, to the whole of the work, and all its parts,\13\n    regardless of how they are packaged.  This License gives no\13\n    permission to license the work in any other way, but it does not\13\n    invalidate such permission if you have separately received it.\13\n\13\n    d) If the work has interactive user interfaces, each must display\13\n    Appropriate Legal Notices; however, if the Program has interactive\13\n    interfaces that do not display Appropriate Legal Notices, your\13\n    work need not make them do so.\13\n\13\n  A compilation of a covered work with other separate and independent\13\nworks, which are not by their nature extensions of the covered work,\13\nand which are not combined with it such as to form a larger program,\13\nin or on a volume of a storage or distribution medium, is called an\13\n\"aggregate\" if the compilation and its resulting copyright are not\13\nused to limit the access or legal rights of the compilation's users\13\nbeyond what the individual works permit.  Inclusion of a covered work\13\nin an aggregate does not cause this License to apply to the other\13\nparts of the aggregate.\13\n\13\n  6. Conveying Non-Source Forms.\13\n\13\n  You may convey a covered work in object code form under the terms\13\nof sections 4 and 5, provided that you also convey the\13\nmachine-readable Corresponding Source under the terms of this License,\13\nin one of these ways:\13\n\13\n    a) Convey the object code in, or embodied in, a physical product\13\n    (including a physical distribution medium), accompanied by the\13\n    Corresponding Source fixed on a durable physical medium\13\n    customarily used for software interchange.\13\n\13\n    b) Convey the object code in, or embodied in, a physical product\13\n    (including a physical distribution medium), accompanied by a\13\n    written offer, valid for at least three years and valid for as\13\n    long as you offer spare parts or customer support for that product\13\n    model, to give anyone who possesses the object code either (1) a\13\n    copy of the Corresponding Source for all the software in the\13\n    product that is covered by this License, on a durable physical\13\n    medium customarily used for software interchange, for a price no\13\n    more than your reasonable cost of physically performing this\13\n    conveying of source, or (2) access to copy the\13\n    Corresponding Source from a network server at no charge.\13\n\13\n    c) Convey individual copies of the object code with a copy of the\13\n    written offer to provide the Corresponding Source.  This\13\n    alternative is allowed only occasionally and noncommercially, and\13\n    only if you received the object code with such an offer, in accord\13\n    with subsection 6b.\13\n\13\n    d) Convey the object code by offering access from a designated\13\n    place (gratis or for a charge), and offer equivalent access to the\13\n    Corresponding Source in the same way through the same place at no\13\n    further charge.  You need not require recipients to copy the\13\n    Corresponding Source along with the object code.  If the place to\13\n    copy the object code is a network server, the Corresponding Source\13\n    may be on a different server (operated by you or a third party)\13\n    that supports equivalent copying facilities, provided you maintain\13\n    clear directions next to the object code saying where to find the\13\n    Corresponding Source.  Regardless of what server hosts the\13\n    Corresponding Source, you remain obligated to ensure that it is\13\n    available for as long as needed to satisfy these requirements.\13\n\13\n    e) Convey the object code using peer-to-peer transmission, provided\13\n    you inform other peers where the object code and Corresponding\13\n    Source of the work are being offered to the general public at no\13\n    charge under subsection 6d.\13\n\13\n  A separable portion of the object code, whose source code is excluded\13\nfrom the Corresponding Source as a System Library, need not be\13\nincluded in conveying the object code work.\13\n\13\n  A \"User Product\" is either (1) a \"consumer product\", which means any\13\ntangible personal property which is normally used for personal, family,\13\nor household purposes, or (2) anything designed or sold for incorporation\13\ninto a dwelling.  In determining whether a product is a consumer product,\13\ndoubtful cases shall be resolved in favor of coverage.  For a particular\13\nproduct received by a particular user, \"normally used\" refers to a\13\ntypical or common use of that class of product, regardless of the status\13\nof the particular user or of the way in which the particular user\13\nactually uses, or expects or is expected to use, the product.  A product\13\nis a consumer product regardless of whether the product has substantial\13\ncommercial, industrial or non-consumer uses, unless such uses represent\13\nthe only significant mode of use of the product.\13\n\13\n  \"Installation Information\" for a User Product means any methods,\13\nprocedures, authorization keys, or other information required to install\13\nand execute modified versions of a covered work in that User Product from\13\na modified version of its Corresponding Source.  The information must\13\nsuffice to ensure that the continued functioning of the modified object\13\ncode is in no case prevented or interfered with solely because\13\nmodification has been made.\13\n\13\n  If you convey an object code work under this section in, or with, or\13\nspecifically for use in, a User Product, and the conveying occurs as\13\npart of a transaction in which the right of possession and use of the\13\nUser Product is transferred to the recipient in perpetuity or for a\13\nfixed term (regardless of how the transaction is characterized), the\13\nCorresponding Source conveyed under this section must be accompanied\13\nby the Installation Information.  But this requirement does not apply\13\nif neither you nor any third party retains the ability to install\13\nmodified object code on the User Product (for example, the work has\13\nbeen installed in ROM).\13\n\13\n  The requirement to provide Installation Information does not include a\13\nrequirement to continue to provide support service, warranty, or updates\13\nfor a work that has been modified or installed by the recipient, or for\13\nthe User Product in which it has been modified or installed.  Access to a\13\nnetwork may be denied when the modification itself materially and\13\nadversely affects the operation of the network or violates the rules and\13\nprotocols for communication across the network.\13\n\13\n  Corresponding Source conveyed, and Installation Information provided,\13\nin accord with this section must be in a format that is publicly\13\ndocumented (and with an implementation available to the public in\13\nsource code form), and must require no special password or key for\13\nunpacking, reading or copying.\13\n\13\n  7. Additional Terms.\13\n\13\n  \"Additional permissions\" are terms that supplement the terms of this\13\nLicense by making exceptions from one or more of its conditions.\13\nAdditional permissions that are applicable to the entire Program shall\13\nbe treated as though they were included in this License, to the extent\13\nthat they are valid under applicable law.  If additional permissions\13\napply only to part of the Program, that part may be used separately\13\nunder those permissions, but the entire Program remains governed by\13\nthis License without regard to the additional permissions.\13\n\13\n  When you convey a copy of a covered work, you may at your option\13\nremove any additional permissions from that copy, or from any part of\13\nit.  (Additional permissions may be written to require their own\13\nremoval in certain cases when you modify the work.)  You may place\13\nadditional permissions on material, added by you to a covered work,\13\nfor which you have or can give appropriate copyright permission.\13\n\13\n  Notwithstanding any other provision of this License, for material you\13\nadd to a covered work, you may (if authorized by the copyright holders of\13\nthat material) supplement the terms of this License with terms:\13\n\13\n    a) Disclaiming warranty or limiting liability differently from the\13\n    terms of sections 15 and 16 of this License; or\13\n\13\n    b) Requiring preservation of specified reasonable legal notices or\13\n    author attributions in that material or in the Appropriate Legal\13\n    Notices displayed by works containing it; or\13\n\13\n    c) Prohibiting misrepresentation of the origin of that material, or\13\n    requiring that modified versions of such material be marked in\13\n    reasonable ways as different from the original version; or\13\n\13\n    d) Limiting the use for publicity purposes of names of licensors or\13\n    authors of the material; or\13\n\13\n    e) Declining to grant rights under trademark law for use of some\13\n    trade names, trademarks, or service marks; or\13\n\13\n    f) Requiring indemnification of licensors and authors of that\13\n    material by anyone who conveys the material (or modified versions of\13\n    it) with contractual assumptions of liability to the recipient, for\13\n    any liability that these contractual assumptions directly impose on\13\n    those licensors and authors.\13\n\13\n  All other non-permissive additional terms are considered \"further\13\nrestrictions\" within the meaning of section 10.  If the Program as you\13\nreceived it, or any part of it, contains a notice stating that it is\13\ngoverned by this License along with a term that is a further\13\nrestriction, you may remove that term.  If a license document contains\13\na further restriction but permits relicensing or conveying under this\13\nLicense, you may add to a covered work material governed by the terms\13\nof that license document, provided that the further restriction does\13\nnot survive such relicensing or conveying.\13\n\13\n  If you add terms to a covered work in accord with this section, you\13\nmust place, in the relevant source files, a statement of the\13\nadditional terms that apply to those files, or a notice indicating\13\nwhere to find the applicable terms.\13\n\13\n  Additional terms, permissive or non-permissive, may be stated in the\13\nform of a separately written license, or stated as exceptions;\13\nthe above requirements apply either way.\13\n\13\n  8. Termination.\13\n\13\n  You may not propagate or modify a covered work except as expressly\13\nprovided under this License.  Any attempt otherwise to propagate or\13\nmodify it is void, and will automatically terminate your rights under\13\nthis License (including any patent licenses granted under the third\13\nparagraph of section 11).\13\n\13\n  However, if you cease all violation of this License, then your\13\nlicense from a particular copyright holder is reinstated (a)\13\nprovisionally, unless and until the copyright holder explicitly and\13\nfinally terminates your license, and (b) permanently, if the copyright\13\nholder fails to notify you of the violation by some reasonable means\13\nprior to 60 days after the cessation.\13\n\13\n  Moreover, your license from a particular copyright holder is\13\nreinstated permanently if the copyright holder notifies you of the\13\nviolation by some reasonable means, this is the first time you have\13\nreceived notice of violation of this License (for any work) from that\13\ncopyright holder, and you cure the violation prior to 30 days after\13\nyour receipt of the notice.\13\n\13\n  Termination of your rights under this section does not terminate the\13\nlicenses of parties who have received copies or rights from you under\13\nthis License.  If your rights have been terminated and not permanently\13\nreinstated, you do not qualify to receive new licenses for the same\13\nmaterial under section 10.\13\n\13\n  9. Acceptance Not Required for Having Copies.\13\n\13\n  You are not required to accept this License in order to receive or\13\nrun a copy of the Program.  Ancillary propagation of a covered work\13\noccurring solely as a consequence of using peer-to-peer transmission\13\nto receive a copy likewise does not require acceptance.  However,\13\nnothing other than this License grants you permission to propagate or\13\nmodify any covered work.  These actions infringe copyright if you do\13\nnot accept this License.  Therefore, by modifying or propagating a\13\ncovered work, you indicate your acceptance of this License to do so.\13\n\13\n  10. Automatic Licensing of Downstream Recipients.\13\n\13\n  Each time you convey a covered work, the recipient automatically\13\nreceives a license from the original licensors, to run, modify and\13\npropagate that work, subject to this License.  You are not responsible\13\nfor enforcing compliance by third parties with this License.\13\n\13\n  An \"entity transaction\" is a transaction transferring control of an\13\norganization, or substantially all assets of one, or subdividing an\13\norganization, or merging organizations.  If propagation of a covered\13\nwork results from an entity transaction, each party to that\13\ntransaction who receives a copy of the work also receives whatever\13\nlicenses to the work the party's predecessor in interest had or could\13\ngive under the previous paragraph, plus a right to possession of the\13\nCorresponding Source of the work from the predecessor in interest, if\13\nthe predecessor has it or can get it with reasonable efforts.\13\n\13\n  You may not impose any further restrictions on the exercise of the\13\nrights granted or affirmed under this License.  For example, you may\13\nnot impose a license fee, royalty, or other charge for exercise of\13\nrights granted under this License, and you may not initiate litigation\13\n(including a cross-claim or counterclaim in a lawsuit) alleging that\13\nany patent claim is infringed by making, using, selling, offering for\13\nsale, or importing the Program or any portion of it.\13\n\13\n  11. Patents.\13\n\13\n  A \"contributor\" is a copyright holder who authorizes use under this\13\nLicense of the Program or a work on which the Program is based.  The\13\nwork thus licensed is called the contributor's \"contributor version\".\13\n\13\n  A contributor's \"essential patent claims\" are all patent claims\13\nowned or controlled by the contributor, whether already acquired or\13\nhereafter acquired, that would be infringed by some manner, permitted\13\nby this License, of making, using, or selling its contributor version,\13\nbut do not include claims that would be infringed only as a\13\nconsequence of further modification of the contributor version.  For\13\npurposes of this definition, \"control\" includes the right to grant\13\npatent sublicenses in a manner consistent with the requirements of\13\nthis License.\13\n\13\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\13\npatent license under the contributor's essential patent claims, to\13\nmake, use, sell, offer for sale, import and otherwise run, modify and\13\npropagate the contents of its contributor version.\13\n\13\n  In the following three paragraphs, a \"patent license\" is any express\13\nagreement or commitment, however denominated, not to enforce a patent\13\n(such as an express permission to practice a patent or covenant not to\13\nsue for patent infringement).  To \"grant\" such a patent license to a\13\nparty means to make such an agreement or commitment not to enforce a\13\npatent against the party.\13\n\13\n  If you convey a covered work, knowingly relying on a patent license,\13\nand the Corresponding Source of the work is not available for anyone\13\nto copy, free of charge and under the terms of this License, through a\13\npublicly available network server or other readily accessible means,\13\nthen you must either (1) cause the Corresponding Source to be so\13\navailable, or (2) arrange to deprive yourself of the benefit of the\13\npatent license for this particular work, or (3) arrange, in a manner\13\nconsistent with the requirements of this License, to extend the patent\13\nlicense to downstream recipients.  \"Knowingly relying\" means you have\13\nactual knowledge that, but for the patent license, your conveying the\13\ncovered work in a country, or your recipient's use of the covered work\13\nin a country, would infringe one or more identifiable patents in that\13\ncountry that you have reason to believe are valid.\13\n\13\n  If, pursuant to or in connection with a single transaction or\13\narrangement, you convey, or propagate by procuring conveyance of, a\13\ncovered work, and grant a patent license to some of the parties\13\nreceiving the covered work authorizing them to use, propagate, modify\13\nor convey a specific copy of the covered work, then the patent license\13\nyou grant is automatically extended to all recipients of the covered\13\nwork and works based on it.\13\n\13\n  A patent license is \"discriminatory\" if it does not include within\13\nthe scope of its coverage, prohibits the exercise of, or is\13\nconditioned on the non-exercise of one or more of the rights that are\13\nspecifically granted under this License.  You may not convey a covered\13\nwork if you are a party to an arrangement with a third party that is\13\nin the business of distributing software, under which you make payment\13\nto the third party based on the extent of your activity of conveying\13\nthe work, and under which the third party grants, to any of the\13\nparties who would receive the covered work from you, a discriminatory\13\npatent license (a) in connection with copies of the covered work\13\nconveyed by you (or copies made from those copies), or (b) primarily\13\nfor and in connection with specific products or compilations that\13\ncontain the covered work, unless you entered into that arrangement,\13\nor that patent license was granted, prior to 28 March 2007.\13\n\13\n  Nothing in this License shall be construed as excluding or limiting\13\nany implied license or other defenses to infringement that may\13\notherwise be available to you under applicable patent law.\13\n\13\n  12. No Surrender of Others' Freedom.\13\n\13\n  If conditions are imposed on you (whether by court order, agreement or\13\notherwise) that contradict the conditions of this License, they do not\13\nexcuse you from the conditions of this License.  If you cannot convey a\13\ncovered work so as to satisfy simultaneously your obligations under this\13\nLicense and any other pertinent obligations, then as a consequence you may\13\nnot convey it at all.  For example, if you agree to terms that obligate you\13\nto collect a royalty for further conveying from those to whom you convey\13\nthe Program, the only way you could satisfy both those terms and this\13\nLicense would be to refrain entirely from conveying the Program.\13\n\13\n  13. Use with the GNU Affero General Public License.\13\n\13\n  Notwithstanding any other provision of this License, you have\13\npermission to link or combine any covered work with a work licensed\13\nunder version 3 of the GNU Affero General Public License into a single\13\ncombined work, and to convey the resulting work.  The terms of this\13\nLicense will continue to apply to the part which is the covered work,\13\nbut the special requirements of the GNU Affero General Public License,\13\nsection 13, concerning interaction through a network will apply to the\13\ncombination as such.\13\n\13\n  14. Revised Versions of this License.\13\n\13\n  The Free Software Foundation may publish revised and/or new versions of\13\nthe GNU General Public License from time to time.  Such new versions will\13\nbe similar in spirit to the present version, but may differ in detail to\13\naddress new problems or concerns.\13\n\13\n  Each version is given a distinguishing version number.  If the\13\nProgram specifies that a certain numbered version of the GNU General\13\nPublic License \"or any later version\" applies to it, you have the\13\noption of following the terms and conditions either of that numbered\13\nversion or of any later version published by the Free Software\13\nFoundation.  If the Program does not specify a version number of the\13\nGNU General Public License, you may choose any version ever published\13\nby the Free Software Foundation.\13\n\13\n  If the Program specifies that a proxy can decide which future\13\nversions of the GNU General Public License can be used, that proxy's\13\npublic statement of acceptance of a version permanently authorizes you\13\nto choose that version for the Program.\13\n\13\n  Later license versions may give you additional or different\13\npermissions.  However, no additional obligations are imposed on any\13\nauthor or copyright holder as a result of your choosing to follow a\13\nlater version.\13\n\13\n  15. Disclaimer of Warranty.\13\n\13\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\13\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\13\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\13\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\13\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\13\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\13\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\13\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\13\n\13\n  16. Limitation of Liability.\13\n\13\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\13\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\13\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\13\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\13\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\13\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\13\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\13\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\13\nSUCH DAMAGES.\13\n\13\n  17. Interpretation of Sections 15 and 16.\13\n\13\n  If the disclaimer of warranty and limitation of liability provided\13\nabove cannot be given local legal effect according to their terms,\13\nreviewing courts shall apply local law that most closely approximates\13\nan absolute waiver of all civil liability in connection with the\13\nProgram, unless a warranty or assumption of liability accompanies a\13\ncopy of the Program in return for a fee.\13\n\13\n                     END OF TERMS AND CONDITIONS\13\n\13\n            How to Apply These Terms to Your New Programs\13\n\13\n  If you develop a new program, and you want it to be of the greatest\13\npossible use to the public, the best way to achieve this is to make it\13\nfree software which everyone can redistribute and change under these terms.\13\n\13\n  To do so, attach the following notices to the program.  It is safest\13\nto attach them to the start of each source file to most effectively\13\nstate the exclusion of warranty; and each file should have at least\13\nthe \"copyright\" line and a pointer to where the full notice is found.\13\n\13\n    <one line to give the program's name and a brief idea of what it does.>\13\n    Copyright (C) <year>  <name of author>\13\n\13\n    This program is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    This program is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\13\n\13\nAlso add information on how to contact you by electronic and paper mail.\13\n\13\n  If the program does terminal interaction, make it output a short\13\nnotice like this when it starts in an interactive mode:\13\n\13\n    <program>  Copyright (C) <year>  <name of author>\13\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\13\n    This is free software, and you are welcome to redistribute it\13\n    under certain conditions; type `show c' for details.\13\n\13\nThe hypothetical commands `show w' and `show c' should show the appropriate\13\nparts of the General Public License.  Of course, your program's commands\13\nmight be different; for a GUI interface, you would use an \"about box\".\13\n\13\n  You should also get your employer (if you work as a programmer) or school,\13\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\13\nFor more information on this, and how to apply and follow the GNU GPL, see\13\n<https://www.gnu.org/licenses/>.\13\n\13\n  The GNU General Public License does not permit incorporating your program\13\ninto proprietary programs.  If your program is a subroutine library, you\13\nmay consider it more useful to permit linking proprietary applications with\13\nthe library.  If this is what you want to do, use the GNU Lesser General\13\nPublic License instead of this License.  But first, please read\13\n<https://www.gnu.org/licenses/why-not-lgpl.html>.",["//texturePacks/default/info.lua"] = "local info = {\13\n\9size = 3, --defines the y size of every block, x size is always the double.\9\13\n}\13\n\13\nreturn info",["//texturePacks/default/textures/wheat.lua"] = "local t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.1\",\13\n\9\13\n\9drawCalls = {\13\n\9\9{\"b\", 0xccaa33},\13\n\9\9{\"f\", 0x777711},\13\n\9\9{0, 0, 6, 3, \"#\"},\13\n\9\9{0, 0, \"|####|\"},\13\n\9\9{0, 1, \"|####|\"},\13\n\9\9{0, 2, \"|####|\"},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/bedrock.lua"] = "local t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.1\",\13\n\9\13\n\9drawCalls = {\13\n\9\9{\"b\", 0x111111},\13\n\9\9{\"f\", 0x333333},\13\n\9\9{0, 0, 6, 3, \"#\"},\13\n\9\9--{1, 1, \"######\"},\13\n\9\9--{1, 2, \"######\"},\13\n\9\9--{1, 3, \"######\"},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/buttons.lua"] = "local t = {\13\n\13\n\9bTextureTest = {\13\n\9\9textureFormat = \"OCGLT\",\13\n\9\9version = \"v0.1\",\13\n\9\9\13\n\9\9drawCalls = {\13\n\9\9\9{\"b\", 0x777777},\13\n\9\9\9{\"f\", 0x333333},\13\n\9\9\9{1, 1, 40, 3, \" \"},\13\n\9\9\9{3, 2, \"TextureTest\"},\13\n\9\9},\13\n\9},\13\n\9\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/player.lua"] = "local colors = {\13\n\9legs = {\13\n\9\9{\"b\", 0xaa1122},\13\n\9\9{\"f\", 0x00409f}, --WIP (OCCC_ToDo)\13\n\9},\13\n}\13\n\13\nlocal left = {\13\n\9{\"b\", 0xa66330a},\13\n\9{\"f\", 0xa88660a},\13\n\9{1, 1, \"o   \"},\13\n\9{1, 2, \"-   \"},\13\n}\13\n\13\nlocal right = {\13\n\9{\"b\", 0xa66330a},\13\n\9{\"f\", 0xa88660a},\13\n\9{1, 1, \"   o\"},\13\n\9{1, 2, \"   -\"},\13\n}\13\n\13\nlocal body = {\13\n\9{\"b\", 0xaa770a},\13\n\9{\"f\", 0xbb9933},\13\n\9{1, 0, \"2222\"},\13\n\9\13\n\9{\"b\", 0x133399},\13\n\9{\"f\", 0x0f1155},\13\n\9{0, 3, 6, 2, \"#\"},\13\n}\13\n\13\nlocal legs = {\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{1, 5, \" \"},\13\n\9\9{4, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{1, 5, \"â–„\"},\13\n\9\9{4, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{2, 5, \"â–„\"},\13\n\9\9{3, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{3, 5, \"â–„\"},\13\n\9\9{2, 5, \" \"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{4, 5, \"â–„\"},\13\n\9\9{1, 5, \" \"},\13\n\9},\13\n}\13\n\13\nlocal t = {\13\n\9left = {\13\n\9\9format = \"OCGLA\",\13\n\9\9version = \"v0.1\",\13\n\9\9frameTime = .1,\13\n\9\9\13\n\9\9frames = {\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[1]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[2]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[3]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[4]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[5]},\13\n\9\9\9},\13\n\9\9},\13\n\9},\13\n\9\13\n\9right = {\13\n\9\9format = \"OCGLA\",\13\n\9\9version = \"v0.1\",\13\n\9\9frameTime = .1,\13\n\9\9\13\n\9\9frames = {\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[1]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[2]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[3]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[4]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{body},\13\n\9\9\9\9{legs[5]},\13\n\9\9\9},\13\n\9\9},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/leaves.lua"] = "local t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.1\",\13\n\9\13\n\9drawCalls = {\13\n\9\9{\"f\", 0x005610},\13\n\9\9{\"b\", 0x003410},\13\n\9\9{0, 0, 6, 3, \"#\"},\13\n\9\9\13\n\9\9\13\n\9\9--{0, 0, \" / // \"},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/woodLog.lua"] = "local t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.1\",\13\n\9\13\n\9drawCalls = {\13\n\9\9{\"b\", 0x331110},\13\n\9\9{\"f\", 0x40180f},\13\n\9\9{0, 0, 6, 3, \"|\"},\13\n\9\9\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/grass.lua"] = "local t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.1\",\13\n\9\13\n\9drawCalls = {\13\n\9\9{\"b\", 0x441100},\13\n\9\9{\"f\", 0x501800},\13\n\9\9{0, 0, 6, 3, \"#\"},\13\n\9\9--{0, 1, \"######\"},\13\n\9\9--{0, 2, \"######\"},\13\n\9\9\13\n\9\9{\"b\", 0x005600},\13\n\9\9{\"f\", 0x003400},\13\n\9\9{0, 0, \"//////\"},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/dirt.lua"] = "local t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.1\",\13\n\9\13\n\9drawCalls = {\13\n\9\9{\"b\", 0x441110},\13\n\9\9{\"f\", 0x501810},\13\n\9\9{0, 0, 6, 3, \"#\"},\13\n\9\9--{0, 0, \"######\"},\13\n\9\9--{0, 1, \"######\"},\13\n\9\9--{0, 2, \"######\"},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/stone.lua"] = "local t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.1\",\13\n\9\13\n\9drawCalls = {\13\n\9\9{\"b\", 0x444444},\13\n\9\9{\"f\", 0x333333},\13\n\9\9{0, 0, 6, 3, \"#\"},\13\n\9\9--{1, 1, \"######\"},\13\n\9\9--{1, 2, \"######\"},\13\n\9\9--{1, 3, \"######\"},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//texturePacks/default/textures/"] = 0,["//texturePacks/default/"] = 0,["//texturePacks/"] = 0,["//logs/"] = 0,["//mods/exampleMod/textures/pig.lua"] = "--This is a compressed animation file (OCGLA_v0.1).\13\n--its acting almost same as a compressed texture (OCGLT_v0.2).\13\n\13\nlocal global = ...\13\n\13\n--===== textures =====--\13\nlocal colors = {\13\n\9legs = {\13\n\9\9{\"f\", 0x802820},\13\n\9\9--{\"b\", global.backgroundColor}, --WIP (ocCraft.lua_ToDo)(dynamic color system)\13\n\9},\13\n}\13\n\13\nlocal face = {\13\n\9{\"f\", 0x7F2944},\13\n\9{0, 0, \"o\"},\13\n\9{0, 1, \"-\"},\13\n}\13\n\13\nlocal body = {\13\n\9{\"b\", 0xbF4984},\13\n\9{\"f\", 0x501810},\13\n\9{0, 0, 5, 2, \" \"},\13\n}\13\n\13\nlocal left = {\13\n\9{1, 0, body},\13\n\9{0, 0, face}, --takes background color from \"body\".\13\n\9{5, 1, \"Ɔ\"}, --takes colors from \"face\".\13\n\9\13\n\9{\"b\", global.backgroundColor},\13\n\9{\"f\", 0xbF4984},\13\n\9{6, 0, \"&\"},\13\n}\13\n\13\nlocal right = {\13\n\9{body},\13\n\9{5, 0, face}, --takes background color from \"body\".\13\n\9{0, 1, \"C\"}, --takes colors from \"face\".\13\n\9\13\n\9{\"b\", global.backgroundColor},\13\n\9{\"f\", 0xbF4984},\13\n\9{-1, 0, \"&\"},\13\n}\13\n\13\nlocal legs = { --takes background color from \"right\".\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{1, 2, \"â–ˆ\"},\13\n\9\9{4, 2, \"â–ˆ\"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{1, 2, \"â–€\"},\13\n\9\9{4, 2, \"â–ˆ\"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{2, 2, \"â–€\"},\13\n\9\9{3, 2, \"â–ˆ\"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{3, 2, \"â–€\"},\13\n\9\9{2, 2, \"â–ˆ\"},\13\n\9},\13\n\9{\13\n\9\9{colors.legs},\13\n\9\9{4, 2, \"â–€\"},\13\n\9\9{1, 2, \"â–ˆ\"},\13\n\9},\13\n}\13\n\13\n--===== animation =====--\13\n\13\n--any entity can have a normal texture (OCGLT_v0.1+), a normal animation (OCGLA_v0.1) or a table that stores a texture/animation for left and right facing.\13\n--tha facing can be changed with Entity:turn(turnToLeft: boolean) (see \"Pig.lua\").\13\n\13\nlocal t = {\13\n\9left = {\13\n\9\9format = \"OCGLA\",\13\n\9\9version = \"v0.1\",\13\n\9\9\13\n\9\9frameTime = .1, --here you define how long a songle frame are shown (frames can be skipped if a tick need to long or the frame time is to low).\13\n\9\9\13\n\9\9frames = { --here you store all the single frames (OCGLT_v0.1+)\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{legs[1]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{legs[2]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{legs[3]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{legs[4]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{left},\13\n\9\9\9\9{legs[5]},\13\n\9\9\9},\13\n\9\9},\13\n\9},\13\n\9\13\n\9right = {\13\n\9\9format = \"OCGLA\",\13\n\9\9version = \"v0.1\",\13\n\9\9frameTime = .1,\13\n\9\9\13\n\9\9frames = {\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{legs[1]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{legs[2]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{legs[3]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{legs[4]},\13\n\9\9\9},\13\n\9\9\9{\13\n\9\9\9\9{right},\13\n\9\9\9\9{legs[5]},\13\n\9\9\9},\13\n\9\9},\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//mods/exampleMod/textures/pinkstone.lua"] = "local t = {\13\n\13\n\9textureFormat = \"OCGLT\",\13\n\9version = \"v0.1\",\13\n\9\13\n\9drawCalls = {\13\n\9\9{\"b\", 0xbF4984}, -- == gpu.setBackground(0xFF69B4)\13\n\9\9{\"f\", 0x8a3974}, -- == gpu.setBackground(0xaa4984)\13\n\9\9{0, 0, 6, 3, \"#\"}, -- == gpu.fill(0, 0, 6, 3, \"#\")\13\n\9\9--{0, 1, \"######\"}, -- == gpu.set(0, 1, \"######\")\13\n\9},\13\n}\13\n\13\n\13\nreturn t",["//mods/exampleMod/textures/"] = 0,["//mods/exampleMod/biomes/flat.lua"] = "local global = ...\13\n\13\nlocal flat = {\13\n\9height = 5,\13\n}\13\n\13\nfunction flat.generate() --will calles every game tick.\13\n\9local fromX, toX, fromY, toY = global.getFOV() --gives fov in blocks.\13\n\9\13\n\9for x = fromX, toX do\13\n\9\9for y = fromY, toY do\13\n\9\9\9if y >= flat.height then\13\n\9\9\9\9if y < flat.height +3 then\13\n\9\9\9\9\13\n\9\9\9\9\9--wg.addBlock() is for biome/worldGen usage only, \13\n\9\9\9\9\9--cause its only adds the block one time at the pos at all.\13\n\9\9\9\9\9--for anything else you should use wre.addBlock().\13\n\9\9\9\9\9if global.wg.addBlock(x, y, \"Grass\") then\13\n\9\9\9\9\9\9--global.log(\"TT\")\13\n\9\9\9\9\9end\13\n\9\9\9\9\9\13\n\9\9\9\9else\13\n\9\9\9\9\9global.wg.addBlock(x, y, \"Stone\")\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\nend\9\13\n\13\nreturn flat",["//mods/exampleMod/biomes/"] = 0,["//mods/exampleMod/info.lua"] = "--[[This is a little example mod.\13\n\9This file is to store infos about the mod but thats currently not used.\13\n]]",["//mods/exampleMod/entities/Pig.lua"] = "--[[This is a example class for an entity.\13\n\9Currently the the game state is spawing any loaded entity once at start.\13\n]]\13\n\13\nlocal global = ...\13\n\13\nPig = {}\13\nPig.__index = Pig\13\n\13\n\13\nfunction Pig.new(args)\13\n\9args.sizeY = 1\13\n\9args.texture = \"pig\"\13\n\9\13\n\9local this = global.Entity.new(args)\13\n\9this = setmetatable(this, Pig)\13\n\9\13\n\9this.facingLeft = false\13\n\9this.toWalk = 0 --time to walk in seconds.\13\n\9\13\n\9this.acceleraion = 10\13\n\9this.maxSpeed = 20 --bug: to high value can cause in glitching through walls/ground (physic/ocgf.RigidBody glitch).\13\n\9this.jumpForce = 1\13\n\9\13\n\9this.update = function(this) --will called on every game tick.\13\n\9\9this.toWalk = this.toWalk - global.dt --dt (delta time) is the time the last gametick has take.\13\n\9\9\13\n\9\9if this.toWalk <= 0 then\13\n\9\9\9this.toWalk = math.random() * 3\13\n\9\9\9\13\n\9\9\9local way = math.random(3)\13\n\9\9\9if way == 1 then\13\n\9\9\9\9this:turn(true)\13\n\9\9\9\9this.facingLeft = true\13\n\9\9\9\9this.gameObject:playAnimation(-1) --playAnimation(speed: float)\13\n\9\9\9elseif way == 2 then\13\n\9\9\9\9this:turn(false)\13\n\9\9\9\9this.facingLeft = false\13\n\9\9\9\9this.gameObject:playAnimation(1) --playAnimation(speed: float)\13\n\9\9\9elseif way == 3 then --stand still\13\n\9\9\9\9this.facingLeft = nil\13\n\9\9\9\9this.gameObject:stopAnimation(1, true) --stopAnimation(frame: float, playTilEnd: bolean)\13\n\9\9\9end\13\n\9\9end\13\n\9\9\13\n\9\9if this.facingLeft == true then\13\n\9\9\9this:addForce(- this.acceleraion, 0, this.maxSpeed)\13\n\9\9elseif this.facingLeft == false then\13\n\9\9\9this:addForce(this.acceleraion, 0, this.maxSpeed)\13\n\9\9end\13\n\9\9\13\n\9\9if math.random() > .98 then --can fly if true multiple time in a row, will fixed after ocgf update.\13\n\9\9\9this:addForce(0, - this.jumpForce)\13\n\9\9end\13\n\9end\13\n\9\13\n\9this.draw = function(this) --will called every time the entity will drawed.\13\n\9\9\13\n\9end\13\n\9\13\n\9this.clear = function(this, acctual) --will called when the sntity graphics are removed.\13\n\9\9\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Pig",["//mods/exampleMod/entities/TestEnt.lua"] = "--[[This is a example class for an entity.\13\n\9Currently the the game state is spawing any loaded entity once at start.\13\n]]\13\n\13\nlocal texture = \"pinkstone\"\13\n\13\nlocal global = ...\13\n\13\nTestEnt = {}\13\nTestEnt.__index = TestEnt\13\n\13\nfunction TestEnt.init(this) --will calles when the block become loaded/reloaded.\13\n\9--global.log(\"TESTENT: init\")\13\nend\13\n\13\nfunction TestEnt.new(args)\13\n\9args.sizeY = 1\13\n\9--args.texture = texture\13\n\9local this = global.Entity.new(args)\13\n\9this = setmetatable(this, TestEnt)\13\n\9\13\n\9\13\n\9this.spawn = function(this) --will called if entity become spawned.\13\n\9\9--global.log(\"TESTENT: spawned\")\13\n\9end\13\n\9\13\n\9this.despawn = function(this) --will called if entity become despawned (not implemented yet).\13\n\9\9global.log(\"TESTENT: despawned\")\13\n\9end\13\n\9\13\n\9this.start = function(this) --will called everytime a new object of the entity is created.\13\n\9\9--global.log(\"TESTENT: start\")\13\n\9end\13\n\9\13\n\9this.stop = function(this) --will called when entity object becomes deloaded (e.g. out of screen)\13\n\9\9--global.log(\"TESTENT: stop\")\13\n\9end\13\n\9\13\n\9this.update = function(this) --will called on every game tick.\13\n\9\9--global.log(\"TESTENT: update\")\13\n\9end\13\n\9\13\n\9this.draw = function(this) --will called every time the entity will drawed.\13\n\9\9--global.log(\"TESTENT: draw\")\13\n\9end\13\n\9\13\n\9this.clear = function(this, acctual) --will called when the sntity graphics are removed.\13\n\9\9--global.log(\"TESTENT: clear\")\13\n\9end\13\n\9\13\n\9this.activate = function(this) --will called when the entity get activated by player or signal (not implemented yet).\13\n\9\9global.log(\"TESTENT: activate\")\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn TestEnt",["//mods/exampleMod/entities/"] = 0,["//mods/exampleMod/blocks/Grass.lua"] = "local global = ...\13\n\13\nGrass = {}\13\nGrass.__index = Grass\13\n\13\nfunction Grass.new(args)\13\n\9args.texture = \"grass\" --can be any loaded texture.\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, Grass)\13\n\9\13\n\9this.update = function(this)\13\n\9\9local posX, posY, blockId = this:getPos()\13\n\9\9\13\n\9\9--===== remove grass if block above it. =====--\13\n\9\9if global.getBlock(posX, posY -1) ~= nil then \13\n\9\9\9global.wre.removeBlock(posX, posY)\13\n\9\9\9global.wre.addBlock(posX, posY, \"Dirt\")\13\n\9\9\9return\13\n\9\9end\13\n\9\9\13\n\9\9--===== convert neighbor dirt to grass. =====--\13\n\9\9for x = posX -1, posX +1 do\13\n\9\9\9for y = posY -1, posY +1 do\13\n\9\9\9\9if global.getBlock(x, y -1) == nil and select(2, global.getBlock(x, y)) == \"Dirt\" then\13\n\9\9\9\9\9global.wre.removeBlock(x, y)\13\n\9\9\9\9\9global.wre.addBlock(x, y, \"Grass\")\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Grass",["//mods/exampleMod/blocks/Teststone.lua"] = "local texture = \"pinkstone\"\13\n\13\nlocal global = ...\13\n\13\nTeststone = {}\13\nTeststone.__index = Teststone\13\n\13\nfunction Teststone.init(this) --will calles when the block become loaded/reloaded.\13\n\9--global.log(\"TESTSTONE: init\")\13\nend\13\n\13\nfunction Teststone.new(args)\13\n\9args.texture = texture\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, Teststone)\13\n\9\13\n\9\13\n\9this.placed = function(this) --will called if block become placed.\13\n\9\9--global.log(\"TESTSTONE: placed\")\13\n\9end\13\n\9\13\n\9this.removed = function(this) --will called if block become remove.\13\n\9\9--global.log(\"TESTSTONE: removed\")\13\n\9end\13\n\9\13\n\9this.start = function(this) --will called everytime a new object of the block is created.\13\n\9\9--global.log(\"TESTSTONE: start\")\13\n\9end\13\n\9\13\n\9this.stop = function(this) --will called when block object becomes removed (e.g. out of screen)\13\n\9\9--global.log(\"TESTSTONE: stop\")\13\n\9end\13\n\9\13\n\9this.update = function(this) --will called on every game tick.\13\n\9\9--global.log(\"TESTSTONE: update\")\13\n\9end\13\n\9\13\n\9this.draw = function(this) --will called every time the block will drawed.\13\n\9\9--global.log(\"TESTSTONE: draw\")\13\n\9end\13\n\9\13\n\9this.clear = function(this, acctual) --will called when the block graphics are removed.\13\n\9\9--global.log(\"TESTSTONE: clear\")\13\n\9end\13\n\9\13\n\9this.activate = function(this) --will called when the block get activated by player or signal (not implemented yet).\13\n\9\9global.log(\"TESTSTONE: activate\")\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Teststone",["//mods/exampleMod/blocks/Pinkstone.lua"] = "local texture = \"pinkstone\"\13\n\13\nlocal global = ...\13\n\13\nPinkstone = {}\13\nPinkstone.__index = Pinkstone\13\n\13\nfunction Pinkstone.new(args)\13\n\9args.texture = texture\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, Pinkstone)\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Pinkstone",["//mods/exampleMod/blocks/"] = 0,["//mods/exampleMod/parents/"] = 0,["//mods/exampleMod/"] = 0,["//mods/"] = 0,["//saves/"] = 0,["//ocCraft.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n--[[ocCraft:\13\n\9Bugs:\13\n\9\9Unconstant jump height (jump glitch):\13\n\9\9\9Higher FPS higher jump glitch effect (trigger more then 1 frame tiggerd)(add collision side return to ocgf.updatePhx()).\13\n\9\9\9\13\n\9\9Memory leak on game restart/stop.\13\n\9\9\13\n\9\9Resolution bug:\13\n\9\9\9You need to restart the PC after you changed the resolution to avoid graphic issues (only if occ was running befor the res change).\13\n\9\9\9Block placing/breaking are working (not properly) but no rendering (ent and blocks).\13\n\9\9\13\n\9\9Entities:\13\n\9\9\9Speed shouldn't be more as the texturePack size (ocgf.RigidBody).\13\n\9\9\9Graphc errors if sprite was over a block.\13\n\9\9\9Despawns sometimes if it goes out of screen (will fixed after wre.updateEntities() rewrite).\13\n\9\13\n\9ToDo:\13\n\9\9Add items:\13\n\9\9\9Basic item class.\13\n\9\9\13\n\9\9Modding:\13\n\9\9\9Database what content is from what mod (wg (save()/load())).\13\n\9\9\13\n\9\9Player.lua:\13\n\9\9\9Add Player.breakDamage > Block.hardness check.\13\n\9\9\9Add way to activate blocks/enities.\13\n\9\9\9Inv rewrite (after new item system).\13\n\9\9\13\n\9\9Add dynamic texture color system (ocgl/ocgf).\13\n\9\9\13\n\9\9Write own event handler.\13\n\9\9\13\n\9\9Source code clean up:\13\n\9\9\9Outsource some functions from \"global.lua\" to seperate file.\13\n\9\9\9Outsource event handling from \"occCore.lua\" (after new event handler).\13\n\9\9\13\n\9\9wre.lua:\13\n\9\9\9updateEntities():\13\n\9\9\9\9Better implementation in the map, may rewrite.\13\n\9\9\13\n\9\9wg.lua:\13\n\9\9\9save()/load():\13\n\9\9\9\9Save/load entities (after wre entity system rewrite).\13\n\9\9\9\9Compress file size.\13\n\9\13\n\9Written by:\13\n\9\9MisterNoNameLP.\13\n]]\13\nlocal version = \"v0.1.2\"\13\n\13\nlocal licenseNotice = [[\13\n    ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This program is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    This program is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\n--===== prog start =====--\13\ndo\13\n\9print(licenseNotice)\13\n\9print(\"Initialize ocCraft \" .. version)\13\n\9local conf = dofile(\"conf.lua\")\13\n\9if conf.debug.isDev then\13\n\9\9print(loadfile(\"data/core/global.lua\"))\13\n\9end\13\n\9local global = loadfile(\"data/core/global.lua\")(conf)\13\n\9global.version = version\13\n\9global.licenseNotice = licenseNotice\13\n\9do\13\n\9\9local f = io.open(\"COPYING\")\13\n\9\9global.license = f:read(\"*all\")\13\n\9\9f:close()\13\n\9end\13\n\9\13\n\9if conf.debug.isDev then\13\n\9\9print(loadfile(\"data/core/init.lua\"))\13\n\9end\13\n\9local initSuccsess, err = loadfile(\"data/core/init.lua\")(global, ...)\13\n\9\13\n\9if initSuccsess then\13\n\9\9local core, err = loadfile(\"data/core/occCore.lua\")\13\n\9\9if global.isDev then\13\n\9\9\9print(core, err)\13\n\9\9end\13\n\9\9local success, returnValues = core(global)\13\n\9\9core = nil\13\n\9\9\13\n\9\9global = nil\13\n\9\9return success, returnValues\13\n\9else\13\n\9\9global = nil\13\n\9\9return false, \"init failed\", err\13\n\9end\13\nend\13\n\13\n--===== prog end =====--",["//conf.lua"] = "local conf = {\13\n\9map = \"world\", --map name in \"saves\" dir.\13\n\9mapBackup = true, --generate a backup anytime the map become loaded (can overflow the disk! (you can check how much space you have left with \"df -h\")).\13\n\9texturePack = \"default\", --can be any installed texturePack.\13\n\9worldGen = \"flat\", --can be any loaded biome.\13\n\9\13\n\9cameraSpeed = 10, --amout of pixels the camera is moving on keyPress.\13\n\9\13\n\9targetFramerate = 20, --default is \"20\". set to \"-1\" for unlimited framerate (can cause in graphical issures).\13\n\9maxTickTime = .2, --if a tick need more as the maxTickTime the engine will handle the ticke like it had needs exacly the maxTickTime.\13\n\9fpsCheckInterval = 10, --defines what amout of frames the engine use to calculate the avg. fps.\13\n\9\13\n\9showConsole = false, --can be changes ingame by pressing f1 by default.\13\n\9showDebug = false, --can be changes ingame by pressing f3 by default.\13\n\9consoleSizeY = 20, --the height of the console.\13\n\9\13\n\9preferModTextures = true, --if true mods can overwrite texturePack textures.\13\n\9\13\n\9debug = { --these options are for developers.\13\n\9\9isDev = false, --activates debug outputs (strongly reconnement if you want to mod the game in any way or something goes wrong and you need a detailed log).\13\n\9\9\13\n\9\9wreDebug = false, --print worldRenderEngine debug (only if isDev).\13\n\9\9wgDebug = false, --print worldGenerator debug (only if isDev).\13\n\9\9dlDebug = false, --print dataLoading debug (only if isDev).\13\n\9\9\13\n\9\9showBlockId = false, --shows block id in inv marked with \"#\".\13\n\9\9drawCollider = false,\13\n\9\9drawTrigger = false,\13\n\9\9\13\n\9\9defaultState = \"loadGame\",\13\n\9\9\13\n\9\9onReload = { --defined what data/libs are reloaded at state reload.\13\n\9\9\9conf = true, --should be always true.\13\n\9\9\9\13\n\9\9\9--=== core ===--\13\n\9\9\9wre = false, --should be true if you want to reload blocks.\13\n\9\9\9wg = false,\13\n\9\9\9map = false,\13\n\9\9\9\13\n\9\9\9--=== data groups ===--\13\n\9\9\9states = false,\13\n\9\9\9textures = false,\13\n\9\9\9blocks = false,\13\n\9\9\9entities = false,\13\n\9\9\9biomes = false,\13\n\9\9\9\13\n\9\9\9mods = true, --just reloads the activated data groups of the mods (if only onReload.blocks = true he only also reloads the blocks from mods). should be always true.\13\n\9\9},\13\n\9}\13\n}\13\n\13\nreturn conf",["//data/states/mainMenu.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\n--===== shared vars =====--\13\nlocal mm = {\13\n\13\n}\13\n\13\n--===== local vars =====--\13\n\13\n--===== local functions =====--\13\n\13\n--===== shared functions =====--\13\nfunction mm.init()\13\n\9--[[\13\n\9global.load({textures = true})\13\n\9mm.ocui = global.ocui.initiate(global.ocgl)\13\n\9\13\n\9mm.bTexturePackTest = mm.ocui.Button.new(mm.ocui, 2, 1, 40, 3, {texture0 = global.textures.buttons.bTextureTest, texture1 = global.textures.buttons.bTextureTest, listedFunction = function()\13\n\9\9global.state = \"game\"\13\n\9\9global.clear() \13\n\9end})\13\n\9]]\13\nend\13\n\13\nfunction mm.start()\13\n\9--global.log(\"MM\")\13\nend\13\n\13\n\13\nfunction mm.update()\13\n\9\13\nend\13\n\13\nfunction mm.draw()\13\n\9mm.ocui:draw()\13\nend\13\n\13\nfunction mm.touch(x, y, b, p)\13\n\9mm.ocui:update(x, y)\13\nend\13\n\13\nreturn mm",["//data/states/test.lua"] = "local global = ...\13\n\13\n--===== shared vars =====--\13\nlocal test = {\13\n\13\n}\13\n\13\n--===== local vars =====--\13\n\13\n--===== local functions =====--\13\n\13\n--===== shared functions =====--\13\nfunction test.start()\13\n\9local thread = require(\"thread\")\13\n\9\13\n\9local t = thread.create(function()\13\n\9\9while true do\13\n\9\9\9global.orgPrint(global.resX)\13\n\9\9\9os.sleep(.5)\13\n\9\9end\13\n\9end)\13\n\9--t:detach()\13\nend\13\n\13\nfunction test.update()\13\n\9\13\nend\13\n\13\nfunction test.draw()\13\n\9--test.block:draw()\13\n\9--global.log(test.block.draw)\13\nend\13\n\13\nreturn test",["//data/states/game.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\n--===== shared vars =====--\13\nlocal game = {\13\n\9blocks = {},\13\n\9alreadyGenerated = {},\13\n\9alreadyRendered = {},\13\n\9\13\n\9player = {},\13\n}\13\n\13\n--===== local vars =====--\13\n\13\n--===== local functions =====--\13\nlocal function print(...)\13\n\9global.log(...)\13\nend\13\n\13\n--===== shared functions =====--\13\nfunction game.init()\13\n\9game.camera = loadfile(\"data/stateData/game/camera.lua\")(global)\13\n\9global.cameraPosX = 0\13\n\9global.cameraPosY = 0\13\n\9\13\n\9print(\"[game]: Start init.\")\13\n\9\13\n\9global.load({\13\n\9\9blocks = true,\13\n\9\9entities = true,\13\n\9\9biomes = true,\13\n\9\9textures = true,\13\n\9\9mods = true,\13\n\9})\13\n\9\13\n\9--===== debug start =====--\13\n\9\13\n\9\13\n\9--=== reload player ===--\13\n\9global.map.loadedEntities = {}\13\n\9game.player = global.wre.addEntity(2, 2, \"Player\")\13\n\9\13\n\9\13\n\9for n, b in pairs(global.blocks) do\13\n\9\9if not b.noBlock and type(b) ~= \"function\" then\13\n\9\9\9game.player:addToInv(n, 1000)\13\n\9\9end\13\n\9end\13\n\9\13\n\9local count = 4\13\n\9for n, e in pairs(global.entities) do\13\n\9\9if n ~= \"Player\" then\13\n\9\9\9if global.wre.addEntity(count, 2, n) then\13\n\9\9\9\9count = count +2\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9--===== debug end =====--\13\n\9\13\n\9print(\"[game]: init done.\")\13\nend\13\n\13\nfunction game.start()\13\n\9global.wg.load(global.conf.map, true)\13\n\9global.clear()\13\n\9global.wg.generate(global.conf.worldGen)\13\n\9global.wre.update()\13\nend\13\n\13\nfunction game.update()\13\n\9game.camera.update(game)\13\n\9\13\n\9--===== calculate game tick =====--\13\n\9global.wg.generate(global.conf.worldGen)\13\n\9global.wre.update()\13\n\9\13\nend\13\n\13\nfunction game.draw()\13\n\9global.wre.draw()\13\n\9\13\n\9game.player:draw()\13\n\9\13\n\9global.drawDebug()\13\nend\13\n\13\nfunction game.keyDown(c, k)\13\n\9if k == 28 and global.isDev then\13\n\9\9print(\"--===== EINGABE =====--\")\13\n\9end \13\n\9\13\n\9game.player:keyDown(c, k, p)\13\n\9\13\n\9--print(c, k)\13\nend\13\n\13\nfunction game.keyUp(c, k)\13\n\9global.run(game.player.keyUp, game.player, c, k, p)\13\nend\13\n\13\nfunction game.touch(x, y, b, p)\13\n\9local posX, posY = global.getBlockPos(x, y)\13\n\9\13\n\9global.run(game.player.touch, game.player, x, y, b, p)\13\nend\13\n\13\nfunction game.drag(x, y, b, p)\13\n\9global.run(game.player.drag, game.player, x, y, b, p)\13\nend\13\n\13\nfunction game.drop(x, y, b, p)\13\n\9global.run(game.player.drop, game.player, x, y, b, p)\13\nend\13\n\13\nfunction game.stop()\13\n\9print(\"Save world: \", global.wg.save(global.conf.map, true))\13\nend\13\n\13\nreturn game\13\n\13\n\13\n\13\n\13\n\13\n",["//data/states/textureTest.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\n--===== shared vars =====--\13\nlocal tt = {\13\n\13\n}\13\n\13\n--===== local vars =====--\13\n\13\n--===== local functions =====--\13\nlocal orgPrint = print\13\nlocal function print(...)\13\n\9global.log(...)\13\nend\13\n\13\n--===== shared functions =====--\13\nfunction tt.init()\13\n\9--tt.ocui = global.ocui.initiate(global.ocgl)\13\n\9\13\n\9--[[\13\n\9local textures = {}\13\n\9\13\n\9print(global.shell.getWorkingDirectory() .. \"texturePacks/\" .. global.conf.texturePack .. \"/textures\")\13\n\9\13\n\9--=== loading textures ===--\13\n\9global.texturePack = dofile(\"texturePacks/\" .. global.conf.texturePack .. \"/info.lua\")\13\n\9global.textures = {}\13\n\9for file in global.fs.list(global.shell.getWorkingDirectory() .. \"texturePacks/\" .. global.conf.texturePack .. \"/textures\") do\13\n\9\9if global.isDev then\13\n\9\9\9print(loadfile(\"texturePacks/\" .. global.conf.texturePack .. \"/textures/\" .. file))\13\n\9\9end\13\n\9\9\13\n\9\9local name = string.sub(file, 0, #file -4)\13\n\9\9global.textures[name] = dofile(\"texturePacks/\" .. global.conf.texturePack ..  \"/textures/\" .. file)\13\n\9end\13\n\9\13\n\9print(#textures)\13\n\9\13\n\9local sizeY  = 0\13\n\9if global.isDev then \13\n\9\9sizeY = global.resY - global.conf.consoleSizeY -2\13\n\9else\13\n\9\9sizeY = global.resY -2\13\n\9end\13\n\9tt.list = tt.ocui.List.new(tt.ocui, 1, 1, 20, sizeY, textures, {listedFunction = function(...) global.log(...) end})\13\n\9]]\13\nend\13\n\13\nfunction tt.start()\13\n\9\13\nend\13\n\13\nfunction tt.update()\13\n\9\13\nend\13\n\13\nfunction tt.draw()\13\n\9tt.ocui:draw()\13\nend\13\n\13\nfunction tt.touch(x, y, b, p)\13\n\9tt.ocui:update(x, y)\13\nend\13\n\13\nfunction tt.stop()\13\n\9\13\nend\13\n\13\nreturn tt",["//data/states/loadGame.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\n--===== shared vars =====--\13\nlocal loadGame = {\13\n\9\13\n}\13\n\13\n--===== local vars =====--\13\n\13\n--===== local functions =====--\13\n\13\n--===== shared functions =====--\13\nfunction loadGame.init()\13\n\9\13\nend\13\n\13\nfunction loadGame.start()\13\n\9global.gpu.setBackground(global.backgroundColor)\13\n\9global.gpu.setForeground(0xffffff)\13\n\9global.term.clear()\13\n\9\13\n\9local s1 = \"ocCraft \" .. global.version\13\n\9local s2 = \"Loading...\"\13\n\9\13\n\9local noticeLines = 0\13\n\9for s in string.gmatch(tostring(global.licenseNotice), \"[^\\r\\n]+\") do\13\n\9\9noticeLines = noticeLines +1\13\n\9end\13\n\9\13\n\9global.gpu.set((global.resX /2) - (#s1 /2), (global.resY /2) -1 - (noticeLines /2), s1)\13\n\9global.gpu.set((global.resX /2) - (#s2 /2), global.resY /2  - (noticeLines /2), s2)\13\n\9\13\n\9local count = 3\13\n\9for s in string.gmatch(tostring(global.licenseNotice), \"[^\\r\\n]+\") do\13\n\9\9global.gpu.set((global.resX /2) - (#s /2), (global.resY /2) + count - (noticeLines /2), s)\13\n\9\9global.log(s)\13\n\9\9count = count +1\13\n\9end\13\n\9\13\n\9global.states[\"game\"].init()\13\n\9global.states[\"game\"].isInitialized = true\13\n\9\13\n\9global.state = \"game\"\13\nend\13\n\13\nfunction loadGame.update()\13\n\9\13\nend\13\n\13\nfunction loadGame.draw()\13\n\9\13\nend\13\n\13\nreturn loadGame",["//data/states/"] = 0,["//data/core/init.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal args = {...}\13\nlocal global = args[1]\13\n\13\n--===== dev =====--\13\nlocal orgRequire = require\13\nlocal require = require\13\nif global.isDev then\13\n\9require = function(s)\13\n\9\9if io.open(s .. \".lua\", \"r\") == nil then\13\n\9\9\9return orgRequire(s)\13\n\9\9else\13\n\9\9\9return dofile(s .. \".lua\")\13\n\9\9end\13\n\9end\13\nend\13\n\13\n--===== global vars =====--\13\n--global.tl = require(\"libs/tl\") --debug/testing\13\nglobal.fs = require(\"filesystem\")\13\nglobal.shell = require(\"shell\")\13\nglobal.event = require(\"event\")\13\nglobal.term = require(\"term\")\13\nglobal.ut = require(\"libs/UT\")\13\nglobal.ocl = require(\"libs/ocl\")\13\nglobal.computer = require(\"computer\")\13\nglobal.keyboard = require(\"keyboard\")\13\nglobal.serialization = require(\"serialization\")\13\nglobal.component = require(\"component\")\13\nglobal.gpu = global.component.gpu\13\nglobal.ocgl = require(\"libs/ocgl\").initiate(global.gpu)\13\nglobal.ocui = require(\"libs/ocui\").initiate(global.ocgl)\13\nglobal.ocgf = require(\"libs/ocgf\")\13\n--print(loadfile(\"data/worldGen.lua\"))\13\nglobal.wg = loadfile(\"data/core/wg.lua\")(global)\13\n--print(loadfile(\"data/core/wre.lua\"))\13\nglobal.wre = loadfile(\"data/core/wre.lua\")(global)\13\n\13\nglobal.resX, global.resY = global.gpu.getResolution()\13\n\13\n--=== debug ===--\13\nglobal.ocl.open()\13\nglobal.tbConsole = global.ocui.TextBox.new(global.ocui, {x=1, y=0, sx=0, sy=0, lineBreak = true, foregroundColor=0xcccccc, backgroundColor=0x333333, managed = {draw = false}})\13\nglobal.setConsoleSize()\13\n\13\n--=== load data ===--\13\nif global.isDev then\13\n\9print(loadfile(\"data/core/dataLoading.lua\"))\13\nend\13\nglobal.load({\13\n\9states = true,\13\n}, global.orgPrint)\13\n\13\n--====== init end ======--\13\nreturn true",["//data/core/dataLoading.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal args = {...}\13\nlocal global = args[1]\13\nlocal toLoad = args[2]\13\nlocal path = \"data\"\13\nlocal loadingMods = false\13\n\13\nif args[4] ~= nil then --onay on mod loading.\13\n\9path = \"mods/\" .. args[4]\13\n\9loadingMods = true\13\nend\13\nif global.alreadyLoaded[path] == nil then\13\n\9global.alreadyLoaded[path] = {}\13\nend\13\n\13\n--===== local functions =====--\13\nlocal print = args[3] or function(...) \13\n\9global.log(...)\13\n\9if global.conf.showConsole then\13\n\9\9global.tbConsole:draw()\13\n\9end\13\nend\13\ndo\13\n\9local p = print\13\n\9print = function(...)\13\n\9\9if global.conf.debug.dlDebug then\13\n\9\9\9p(...)\13\n\9\9end\13\n\9end\13\nend\13\n\13\nlocal function reloadFile(target, path, ...)\13\n\9local debugString = \"[DL]: Reloading file: \" .. path .. \": \"\13\n\9\13\n\9local suc, err = loadfile(path)\13\n\9if suc == nil then\13\n\9\9print(debugString .. tostring(err))\13\n\9else\13\n\9\9print(debugString .. tostring(suc))\13\n\9\9target = nil\13\n\9\9return loadfile(path)(...)\13\n\9end\13\nend\13\n\13\nlocal reloadString = \"\"\13\nfor i, c in pairs(toLoad) do\13\n\9if c then\13\n\9\9if #reloadString > 0 then\13\n\9\9\9reloadString = reloadString .. \", \" .. i\13\n\9\9else\13\n\9\9\9reloadString = reloadString .. i\13\n\9\9end\13\n\9end\13\nend\13\nif loadingMods then\13\n\9global.log(\"[DL]: Loading mod data groups: \" .. reloadString .. \".\")\13\nelse\13\n\9global.log(\"[DL]: Loading data groups: \" .. reloadString .. \".\")\13\nend\13\n\13\n--===== reloadings =====--\13\nif toLoad.map then\13\n\9if toLoad.reload then\13\n\9\9print(\"[INFO]: Reload: global.map.\")\13\n\9\9global.map = {blocks = {}, alreadyGenerated = {}, entities = {}, loadedEntities = {}, blockMap = {}}\13\n\9\9global.wg.load(global.conf.map)\13\n\9end\13\nend\13\n\13\nif toLoad.conf then\13\n\9global.conf = reloadFile(global.conf, \"conf.lua\", global)\13\nend\13\n\13\nif toLoad.wg then\13\n\9global.wg = reloadFile(global.wg, \"data/core/wg.lua\", global)\13\nend\13\n\13\nif toLoad.wre then\13\n\9global.wre = reloadFile(global.wre, \"data/core/wre.lua\", global)\13\nend\13\n\13\nif toLoad.states then\13\n\9global.states = {} \13\n\9global.loadData(global.states, \"data/states\", nil, print)\13\nend\13\n\13\n--===== data loading =====--\13\nif toLoad.textures then\13\n\9if global.alreadyLoaded[path].textures ~= true or toLoad.reload then\13\n\9\9if not loadingMods then\13\n\9\9\9if global.isDev then\13\n\9\9\9\9print(\"[DL]: Loading texturepack info.lua: \" .. tostring(loadfile(\"texturePacks/\" .. global.conf.texturePack .. \"/info.lua\")))\13\n\9\9\9end\13\n\9\9\9global.texturePack = loadfile(\"texturePacks/\" .. global.conf.texturePack .. \"/info.lua\")(global)\13\n\9\9\9print(\"[DL]: Loading textures.\")\13\n\9\9\9global.textures = {}\13\n\9\9\9global.loadData(global.textures, \"texturePacks/\" .. global.conf.texturePack .. \"/textures\", nil, print)\13\n\9\9else\13\n\9\9\9print(\"[DL]: Loading textures.\")\13\n\9\9\9global.loadData(global.textures, path .. \"/textures\", nil, print, global.conf.preferModTextures)\13\n\9\9end\13\n\9\9global.alreadyLoaded[path].textures = true\13\n\9else\13\n\9\9print(\"[DL]: Textures are loaded already.\")\13\n\9end\13\nend\9\13\n\13\nif toLoad.blocks then\13\n\9if global.alreadyLoaded[path].blocks ~= true or toLoad.reload then\13\n\9\9if not loadingMods then\13\n\9\9\9if global.isDev then\13\n\9\9\9\9print(\"[DL]: Loading parrent: Block: \" .. tostring(loadfile(\"data/parents/Block.lua\")))\13\n\9\9\9end\13\n\9\9\9global.Block = loadfile(\"data/parents/Block.lua\")(global)\13\n\9\9\9global.Block:init()\13\n\9\9\9global.blocks = {\13\n\9\9\9\9name = {noBlock = true},\13\n\9\9\9\9id = {noBlock = true},\13\n\9\9\9\9info = {noBlock = true, amout = 0},\13\n\9\9\9}\13\n\9\9end\13\n\9\9print(\"[DL]: Loading blocks.\")\13\n\9\9global.loadData(global.blocks, path .. \"/blocks\", function(name, id)\13\n\9\9\9global.blocks.id[name] = id\13\n\9\9\9global.blocks.name[id] = name\13\n\9\9\9global.blocks.info.amout = global.blocks.info.amout +1\13\n\9\9\9global.run(global.blocks[name].init, id)\13\n\9\9end, print)\13\n\9\9global.alreadyLoaded[path].blocks = true\13\n\9else\13\n\9\9print(\"[DL]: Blocks are loaded already.\")\13\n\9end\13\nend\13\n\13\nif toLoad.entities then\13\n\9if global.alreadyLoaded[path].entities ~= true or toLoad.reload then\13\n\9\9if not loadingMods then\13\n\9\9\9if global.isDev then\13\n\9\9\9\9print(\"[DL]: Loading parrent: Entity: \" .. tostring(loadfile(\"data/parents/Entity.lua\")))\13\n\9\9\9end\13\n\9\9\9global.Entity = loadfile(\"data/parents/Entity.lua\")(global)\13\n\9\9\9global.entities = {name = {}, id = {}, info = {amout = 0}}\13\n\9\9end\13\n\9\9print(\"[DL]: Loading entities.\")\13\n\9\9global.loadData(global.entities, path .. \"/entities\", function(name, id)\13\n\9\9\9global.entities.id[name] = id\13\n\9\9\9global.entities.name[id] = name\13\n\9\9\9global.entities.info.amout = global.entities.info.amout +1\13\n\9\9\9global.run(global.entities[name].init, id)\13\n\9\9end, print)\13\n\9\9global.alreadyLoaded[path].entities = true\13\n\9else\13\n\9\9print(\"[DL]: Entities are loaded already.\")\13\n\9end\13\nend\13\n\13\nif toLoad.biomes then\13\n\9if global.alreadyLoaded[path].biomes ~= true or toLoad.reload then\13\n\9\9if not loadingMods then\13\n\9\9\9global.biomes = {}\13\n\9\9end\13\n\9\9print(\"[DL]: Loading biomes.\")\13\n\9\9global.loadData(global.biomes, path .. \"/biomes\", nil, print)\13\n\9\9global.alreadyLoaded[path].biomes = true\13\n\9else\13\n\9\9print(\"[DL]: Biomes are loaded already.\")\13\n\9end\13\nend\13\n\13\n\13\nif toLoad.mods then --WIP\13\n\9if global.alreadyLoaded.mods ~= true or toLoad.reload then\13\n\9\9print(\"[DL]: Loading mods.\")\13\n\9\9for file in global.fs.list(global.shell.getWorkingDirectory() .. \"/mods/\") do\13\n\9\9\9print(\"[DL]: Loading mod: \" .. file)\13\n\9\9\9global.load({\13\n\9\9\9\9blocks = toLoad.blocks,\13\n\9\9\9\9entities = toLoad.entities,\13\n\9\9\9\9biomes = toLoad.biomes,\13\n\9\9\9\9textures = toLoad.textures,\13\n\9\9\9\9reload = toLoad.reload\13\n\9\9\9}, print, file)\13\n\9\9end\13\n\9else\13\n\9\9print(\"[DL]: Mods are loaded already.\")\13\n\9end\13\nend\13\n\13\nif loadingMods then\13\n\9global.log(\"[DL]: Mod data loading done.\")\13\nelse\13\n\9global.log(\"[DL]: Data loading done.\")\13\nend\13\n\13\nreturn true",["//data/core/wre.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\n--occWorldEenderEngine\13\nlocal global = ...\13\nlocal wre = {\13\n\9blocks = {},\13\n\9alreadyGenerated = {},\13\n\9alreadyRendered = {},\13\n}\13\n\13\n--===== local vars =====--\13\nlocal fromX, toX, fromY, toY = 0, 0, 0, 0 --regenerated every update.\13\nlocal fromPixelX, toPixelX, fromPixelY, toPixelY = 0, 0, 0, 0 --regenerated every update.\13\n\13\n--===== local functions =====--\13\nlocal function consolePrint(...)\13\n\9if global.conf.debug.wreDebug then\13\n\9\9global.debug(...)\13\n\9end\13\nend\13\n\13\nlocal function garbageCollection() --bug: \"clears\" to much\13\n\9local removedBlocks = 0\13\n\9for x, t in pairs(wre.blocks) do\13\n\9\9for y, b in pairs(wre.blocks[x]) do\13\n\9\9\9if x < fromX or x > toX or y < fromY or y > toY then\13\n\9\9\9\9if wre.alreadyGenerated[x] ~= nil then\13\n\9\9\9\9\9wre.alreadyGenerated[x][y] = nil\13\n\9\9\9\9end\13\n\9\9\9\9if wre.alreadyRendered[x] ~= nil then\13\n\9\9\9\9\9wre.alreadyRendered[x][y] = nil\13\n\9\9\9\9end\13\n\9\9\9\9if wre.blocks[x] ~= nil then\13\n\9\9\9\9\9if wre.blocks[x][y] ~= nil then\13\n\9\9\9\9\9\9global.run(wre.blocks[x][y].pStop, wre.blocks[x][y])\13\n\9\9\9\9\9\9wre.blocks[x][y]:pClear(true)\13\n\9\9\9\9\9end\13\n\9\9\9\9\9wre.blocks[x][y] = nil\13\n\9\9\9\9\9removedBlocks = removedBlocks +1\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9if removedBlocks > 0 then\13\n\9\9consolePrint(\"[WRE]:Blocks unloaded: \" ..tostring(removedBlocks))\13\n\9end\13\nend\13\n\13\nlocal function addBlock(x, y, b, draw)\13\n\9draw = global.ut.parseArgs(draw, false)\13\n\9if wre.blocks[x] == nil then\13\n\9\9wre.blocks[x] = {}\13\n\9end\13\n\9\13\n\9local block = b\13\n\9if type(b) == \"number\" then\13\n\9\9block = global.blocks.name[b]\13\n\9end\13\n\9\13\n\9local px, py = global.getPixel(x, y)\13\n\9wre.blocks[x][y] = global.blocks[block].new({posX = px, posY = py})\13\n\9global.run(wre.blocks[x][y].pStart, wre.blocks[x][y])\13\n\9if draw then\13\n\9\9wre.blocks[x][y]:pDraw()\13\n\9end\13\n\9return wre.blocks[x][y]\13\nend\13\n\13\nlocal function updateWorld()\13\n\9local generatedBlocks = 0\13\n\9for x = fromX, toX do\13\n\9\9for y = fromY, toY do\13\n\9\9\9if wre.alreadyGenerated[x] == nil then\13\n\9\9\9\9wre.alreadyGenerated[x] = {}\13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9if wre.alreadyGenerated[x][y] == nil then\13\n\9\9\9\9local block = nil --string\13\n\9\9\9\9if global.map.blocks[x] ~= nil then\13\n\9\9\9\9\9block = global.map.blocks[x][y]\13\n\9\9\9\9end\13\n\9\9\9\9\13\n\9\9\9\9if block ~= nil then\13\n\9\9\9\9\9addBlock(x, y, block)\13\n\9\9\9\9\9generatedBlocks = generatedBlocks +1\13\n\9\9\9\9end\13\n\9\9\9\9wre.alreadyGenerated[x][y] = true\13\n\9\9\9elseif global.lastCameraPosX ~= global.cameraPosX or global.lastCameraPosY ~= global.cameraPosY then \13\n\9\9\9\9if wre.blocks[x] ~= nil and wre.blocks[x][y] ~= nil then\13\n\9\9\9\9\9wre.blocks[x][y].gameObject:move(global.lastCameraPosX - global.cameraPosX, global.lastCameraPosY - global.cameraPosY)\13\n\9\9\9\9\9if wre.alreadyRendered[x] ~= nil then\13\n\9\9\9\9\9\9wre.alreadyRendered[x][y] = nil\13\n\9\9\9\9\9end\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9\9if wre.blocks[x] ~= nil and wre.blocks[x][y] ~= nil and wre.blocks[x][y].update ~= nil then\13\n\9\9\9\9wre.blocks[x][y]:pUpdate()\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9if generatedBlocks > 0 then\13\n\9\9consolePrint(\"[WRE]:Generated block: \" .. tostring(generatedBlocks))\13\n\9end\13\nend\13\n\13\nlocal function drawWorld()\13\n\9local c, d = 0, 0\13\n\9\13\n\9for x, t in pairs(wre.blocks) do\13\n\9\9for y, b in pairs(t) do\13\n\9\9\9if wre.alreadyRendered[x] == nil then\13\n\9\9\9\9wre.alreadyRendered[x] = {}\13\n\9\9\9end\13\n\9\9\9if wre.alreadyRendered[x][y] == nil then\13\n\9\9\9\9b:pClear()\13\n\9\9\9\9c = c +1\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9for x, t in pairs(wre.blocks) do\13\n\9\9for y, b in pairs(t) do\13\n\9\9\9if wre.alreadyRendered[x] == nil then\13\n\9\9\9\9wre.alreadyRendered[x] = {}\13\n\9\9\9end\13\n\9\9\9if wre.alreadyRendered[x][y] == nil then\13\n\9\9\9\9b:pDraw()\13\n\9\9\9\9d = d +1\13\n\9\9\9\9wre.alreadyRendered[x][y] = true\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9if c > 0 then\13\n\9\9consolePrint(\"[WRE]:Clears: \" .. tostring(c))\13\n\9end\13\n\9if d > 0 then\13\n\9\9consolePrint(\"[WRE]:Draws: \" .. tostring(c))\13\n\9end\13\nend\13\n\13\nlocal function updateEntities() --WIP\13\n\9for _, e in ipairs(global.map.loadedEntities) do --unload entites\13\n\9\9\13\n\9\9if (e.gameObject.posX -1) + e.sizeX <= 0 or e.gameObject.posX > global.resX or \13\n\9\9\9(e.gameObject.posY -1) + e.sizeY <= 0 or e.gameObject.posY > global.resY\13\n\9\9then --not on screen\13\n\9\9\9consolePrint(\"[WRE]: Unload entity\")\13\n\9\9\9\13\n\9\9\9e.gameObject:moveTo(\13\n\9\9\9\9e.gameObject.posX - (global.cameraPosX - global.lastCameraPosX), \13\n\9\9\9\9e.gameObject.posY - (global.cameraPosY - global.lastCameraPosY)\13\n\9\9\9)\13\n\9\9\9\13\n\9\9\9e.posX, e.posY = global.getBlockPos(e.gameObject.posX, e.gameObject.posY)\13\n\9\9\9\13\n\9\9\9local index = #global.map.entities +1\13\n\9\9\9global.map.entities[index] = e\13\n\9\9\9global.map.loadedEntities[e.index] = nil\13\n\9\9\9e.index = index\13\n\9\9\9global.run(e.pStop, e, index)\13\n\9\9end\13\n\9end\13\n\9\13\n\9for _, e in ipairs(global.map.entities) do --load entities.\13\n\9\9if e.posX + (e.sizeX / (global.texturePack.size *2)) <= fromX or e.posX > toX or\13\n\9\9\9e.posY + (e.sizeY / (global.texturePack.size)) <= fromY or e.posY > toY\13\n\9\9then else\13\n\9\9\9consolePrint(\"[WRE]: Load entity\")\13\n\9\9\9local index = #global.map.loadedEntities +1\13\n\9\9\9global.map.loadedEntities[index] = e\13\n\9\9\9global.map.entities[e.index] = nil\13\n\9\9\9e.index = index\13\n\9\9\9\13\n\9\9\9local x, y = global.getPixel(e.posX, e.posY)\13\n\9\9\9local offsetX = global.cameraPosX - global.lastCameraPosX\13\n\9\9\9local offsetY = global.cameraPosY - global.lastCameraPosY\13\n\9\9\9e:moveTo(x + offsetX, y + offsetY)\13\n\9\9\9\13\n\9\9\9global.run(e.pStart, e, index)\13\n\9\9end\13\n\9end\13\n\9\13\n\9for _, e in ipairs(global.map.loadedEntities) do --update entities\13\n\9\9local gameObjects = {}\13\n\9\9for x = fromX, toX do\13\n\9\9\9for y = fromY, toY do\13\n\9\9\9\9if global.wre.blocks[x] ~= nil and global.wre.blocks[x][y] ~= nil then\13\n\9\9\9\9\9if global.wre.blocks[x][y].gameObject.getCollider ~= nil then\13\n\9\9\9\9\9\9table.insert(gameObjects, global.wre.blocks[x][y].gameObject)\13\n\9\9\9\9\9end\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9\9\13\n\9\9if global.cameraPosX ~= global.lastCameraPosX or global.cameraPosY ~= global.lastCameraPosY then\13\n\9\9\9e.gameObject:moveTo(\13\n\9\9\9\9e.gameObject.posX - (global.cameraPosX - global.lastCameraPosX), e.gameObject.posY - (global.cameraPosY - global.lastCameraPosY)\13\n\9\9\9)\13\n\9\9\9e.gameObject:clear(global.backgroundColor)\13\n\9\9\9global.run(e.pClear, e, global.backgroundColor)\13\n\9\9end\13\n\9\9\13\n\9\9if global.dt > global.conf.maxTickTime then\13\n\9\9\9global.warn(\"Delta time too high (\" .. tostring(global.dt) .. \"s)!\")\13\n\9\9\9global.dt = global.conf.maxTickTime\13\n\9\9end\13\n\9\9\13\n\9\9e.gameObject:updatePhx(gameObjects, global.dt)\13\n\9\9e.gameObject:update(gameObjects)\13\n\9\9global.run(e.pUpdate, e)\13\n\9end\13\nend\13\n\13\nlocal function drawEntities() --WIP\13\n\9for _, e in ipairs(global.map.loadedEntities) do\13\n\9\9e.gameObject:clear(global.backgroundColor)\13\n\9\9global.run(e.pClear, e)\13\n\9\9e.gameObject:draw()\13\n\9\9global.run(e.pDraw, e)\13\n\9end\13\nend\13\n\13\n--===== global functions =====--\13\nfunction wre.addEntity(x, y, e)\13\n\9local entity = e\13\n\9if type(e) == \"number\" then\13\n\9\9entity = global.entities.name[e]\13\n\9end\13\n\9\13\n\9if global.entities[entity].new == nil then\13\n\9\9return false, \"Entity not found.\"\13\n\9end\13\n\9\13\n\9local index = #global.map.entities +1\13\n\9global.map.entities[index] = global.entities[entity].new({posX = x, posY = y, index = index})\13\n\9global.run(global.map.entities[index].pSpawn, global.map.entities[index], index)\13\n\9return global.map.entities[index]\13\nend\13\n\13\nfunction wre.addBlock(x, y, b, draw)\13\n\9if global.map.blocks[x] == nil then\13\n\9\9global.map.blocks[x] = {}\13\n\9end\13\n\9\13\n\9\13\n\9local block = b\13\n\9if type(b) == \"string\" then\13\n\9\9block = global.blocks.id[b]\13\n\9end\13\n\9\13\n\9if global.map.blocks[x][y] == nil then\13\n\9\9global.map.blocks[x][y] = block\13\n\9\9local b = addBlock(x, y, block, draw)\13\n\9\9global.run(b.pPlaced, b, x, y)\13\n\9\9return true\13\n\9else\13\n\9\9return false\13\n\9end\13\nend\13\n\13\nfunction wre.removeBlock(x, y)\13\n\9local block = -1\13\n\9if global.map.blocks[x] == nil then\13\n\9\9return false\13\n\9else\13\n\9\9block = global.map.blocks[x][y]\13\n\9\9global.map.blocks[x][y] = nil\13\n\9end\13\n\9if wre.alreadyGenerated[x] ~= nil then\13\n\9\9wre.alreadyGenerated[x][y] = nil\13\n\9end\13\n\9if wre.alreadyRendered[x] ~= nil then\13\n\9\9wre.alreadyRendered[x][y] = nil\13\n\9end\13\n\9if wre.blocks[x] ~= nil and wre.blocks[x][y] ~= nil then\13\n\9\9global.run(wre.blocks[x][y].pRemoved, wre.blocks[x][y])\13\n\9\9global.run(wre.blocks[x][y].pStop, wre.blocks[x][y])\13\n\9\9wre.blocks[x][y]:pClear(true)\13\n\9\9wre.blocks[x][y] = nil\13\n\9\9return true, block\13\n\9end\13\n\9return false\13\nend\13\n\13\nfunction wre.update(phx)\13\n\9fromX, toX, fromY, toY = global.getFOV()\13\n\9fromPixelX, toPixelX, fromPixelY, toPixelY = global.getFOVPixel()\13\n\9\13\n\9--fromPixelX, toPixelX, fromPixelY, toPixelY = 0, global.resX, 0, global.resY\13\n\9--global.log(global.getFOVPixel())\13\n\9\13\n\9updateWorld()\13\n\9if phx == nil or phx == true then\13\n\9\9updateEntities()\13\n\9end\13\n\9\13\n\9garbageCollection()\13\nend\13\n\13\nfunction wre.draw()\13\n\9drawWorld()\13\n\9drawEntities()\13\nend\13\n\13\nfunction wre.newUpdate()\13\n\9wre.alreadyGenerated = {}\13\n\9wre.update()\13\nend\13\n\13\nfunction wre.newDraw()\13\n\9wre.alreadyRendered = {}\13\n\9wre.draw()\13\nend\13\n\13\nreturn wre",["//data/core/wg.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\nlocal wg = {\13\n\9\13\n}\13\n--===== local vars =====--\13\n\13\n--===== local functions =====--\13\nlocal function print(...)\13\n\9if global.conf.debug.wgDebug then\13\n\9\9global.debug(...)\13\n\9end\13\nend\13\n\13\nlocal function saveTable(t, dir, f)\13\n\9local data = \"return \" .. global.serialization.serialize(t)\13\n\9\13\n\9local file = io.open(dir .. \"/\" .. f .. \".lua\", \"w\")\13\n\9file:write(data)\13\n\9file:close()\13\nend\13\n\13\nlocal function loadTable(t, dir, f)\13\n\13\nend\13\n\13\n--===== global functions =====--\13\nfunction wg.generate(biome)\13\n\9global.biomes[biome].generate()\13\nend\13\n\13\nfunction wg.save(name, overwrite)\13\n\9dir = global.shell.getWorkingDirectory() .. \"/saves/\" .. name\13\n\9local map = {}\13\n\9local file = {}\13\n\9\13\n\9print(\"[WG]: Save world.\")\13\n\9\13\n\9if global.fs.exists(dir) and overwrite ~= true then\13\n\9\9print(\"[WG]: Map file already exist.\")\13\n\9\9return false, \"Map file already exist\"\13\n\9end\13\n\9\13\n\9if global.conf.mapBackup ~= false then\13\n\9\9local c = 1\13\n\9\9while global.fs.exists(dir .. \"(\" .. tostring(c) .. \")\") do\13\n\9\9\9c = c +1\13\n\9\9end\13\n\9\9os.execute(\"cp -r \" .. dir .. \" \" .. dir .. \"(\" .. tostring(c) .. \")\")\13\n\9end\13\n\9global.fs.makeDirectory(dir)\13\n\9\13\n\9\13\n\9saveTable(global.map.blocks, dir, \"blocks\")\13\n\9saveTable(global.map.alreadyGenerated, dir, \"alreadyGeneratedBlocks\")\13\n\9global.blocks.name.noBlock = nil\13\n\9saveTable(global.blocks.name, dir, \"idList\")\13\n\9global.blocks.name.noBlock = true\13\n\9\13\n\9return true\13\nend\13\n\13\nfunction wg.load(name, forceLoading)\13\n\9local dir = global.shell.getWorkingDirectory() .. \"/saves/\" .. name\13\n\9\13\n\9print(\"[WG]: Load world.\")\13\n\9\13\n\9if not global.fs.exists(dir) then\13\n\9\9return false, \"Map file does not exist\"\13\n\9end\13\n\13\n\9local blocks = dofile(dir .. \"/blocks.lua\")\13\n\9local alreadyGenerated = dofile(dir .. \"/alreadyGeneratedBlocks.lua\")\13\n\9local idList = dofile(dir .. \"/idList.lua\")\13\n\9local toChange = {}\13\n\9\13\n\9print(\"[WG]: Check id changes.\")\13\n\9\13\n\9for id, name in pairs(idList) do\13\n\9\9if global.blocks.name[id] ~= name then\13\n\9\9\9if global.blocks.id[name] ~= nil or forceLoading then\13\n\9\9\9\9if global.blocks.id[name] == nil then\13\n\9\9\9\9\9global.warn(\"[WG]: Block not found but forced to load the map: \", name, id)\13\n\9\9\9\9\9toChange[id] = -1\13\n\9\9\9\9else\13\n\9\9\9\9\9print(\"[WG]: Change block id \\\"\" .. name .. \"#\" .. tostring(id) .. \"\\\" to: \" .. global.blocks.id[name] .. \".\")\13\n\9\9\9\9\9toChange[id] = global.blocks.id[name]\13\n\9\9\9\9end\13\n\9\9\9else\13\n\9\9\9\9print(\"[WG]: Block not found.\", name, id)\13\n\9\9\9\9return false, \"Block not found.\", name, id\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9for x, _ in pairs(blocks) do\13\n\9\9for y, _ in pairs(blocks[x]) do\13\n\9\9\9local id = -1\13\n\9\9\9if blocks[x] ~= nil and blocks[x][y] ~= nil then\13\n\9\9\9\9id = blocks[x][y]\13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9if toChange[id] ~= nil then\13\n\9\9\9\9if toChange[id] == -1 then\13\n\9\9\9\9\9blocks[x][y] = nil\13\n\9\9\9\9else\13\n\9\9\9\9\9blocks[x][y] = toChange[id]\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9global.map.blocks = blocks\13\n\9global.map.alreadyGenerated = alreadyGenerated\13\n\9\13\n\9return true\13\nend\13\n\13\nfunction wg.addBlock(x, y, b)\13\n\9if global.map[x] == nil then\13\n\9\9global.map[x] = {}\13\n\9end\13\n\9if global.map.alreadyGenerated[x] == nil then\13\n\9\9global.map.alreadyGenerated[x] = {}\13\n\9end\13\n\9\13\n\9if global.map[x][y] == nil and global.map.alreadyGenerated[x][y] == nil then\13\n\9\9local suc = global.wre.addBlock(x, y, b)\13\n\9\9if suc then\13\n\9\9\9global.map.alreadyGenerated[x][y] = true\13\n\9\9end\13\n\9\9return true, suc\13\n\9else\13\n\9\9return false, \"Already generated or busy.\"\13\n\9end\13\nend\13\n\13\nreturn wg\13\n\13\n\13\n\13\n\13\n\13\n\13\n\13\n\13\n\13\n\13\n\13\n",["//data/core/global.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal args = {...}\13\nlocal conf = args[1]\13\n\13\n--===== global vars =====--\13\nlocal global = {\13\n\9isRunning = true,\13\n\9isDev = conf.debug.isDev,\13\n\9\13\n\9conf = conf,\13\n\9controls = dofile(\"controls.lua\"),\13\n\9\13\n\9state = \"\",\13\n\9dt = 0, --deltaTime\13\n\9lastUptime = 0,\13\n\9fps = 0,\13\n\9\13\n\9cameraPosX = 0,\13\n\9cameraPosY = 0,\13\n\9lastCameraPosX = 0, --regenerated every update.\13\n\9lastCameraPosY = 0,--regenerated every update.\13\n\9cameraSubPosX = 0,\13\n\9cameraSubPosY = 0,\13\n\9\13\n\9backgroundColor = 0x00409f,\13\n\9\13\n\9resX = 0,\13\n\9resY = 0,\13\n\9\13\n\9map = {\13\n\9\9idMap = {},\13\n\9\9blocks = {}, --2D\13\n\9\9alreadyGenerated = {}, --2D\13\n\9\9entities = {},\13\n\9\9loadedEntities = {},\13\n\9},\13\n\9textures = {},\13\n\9blocks = { --the noBlock tag is necessary 'til the item system is implemented to avoid states[\"game\"].init() crash.\13\n\9\9name = {noBlock = true},\13\n\9\9id = {noBlock = true},\13\n\9\9info = {noBlock = true, amout = 0},\13\n\9},\13\n\9entities = {\13\n\9\9name = {}, \13\n\9\9id = {}, \13\n\9\9info = {amout = 0},\13\n\9},\13\n\9biomes = {},\13\n\9items = {}, --not implemented yet.\13\n\9\13\n\9orgPrint = print,\13\n\9\13\n\9alreadyLoaded = {},\13\n\9loadedMods = {},\13\n}\13\n\13\n--===== global functions =====--\13\nfunction global.log(...)\13\n\9local t = {...}\13\n\9local s = \"[INFO] \" .. tostring(t[1])\13\n\9global.tbConsole:add(s, select(2, ...))\13\n\9global.ocl.add(s, select(2, ...))\13\nend\13\n\13\nfunction global.warn(...)\13\n\9local t = {...}\13\n\9local s = \"[WARN] \" .. tostring(t[1])\13\n\9global.tbConsole:add(s, select(2, ...))\13\n\9global.ocl.add(s, select(2, ...))\13\nend\13\n\13\nfunction global.error(...)\13\n\9local t = {...}\13\n\9local s = \"[ERROR] \" .. tostring(t[1])\13\n\9global.tbConsole:add(s, select(2, ...))\13\n\9global.ocl.add(s, select(2, ...))\13\nend\13\n\13\nfunction global.fatal(...)\13\n\9local t = {...}\13\n\9local s = \"[FATAL] \" .. tostring(t[1])\13\n\9global.tbConsole:add(s, select(2, ...))\13\n\9global.ocl.add(s, select(2, ...))\13\n\9global.isRunning = false\13\n\9global.state = \"\"\13\nend\13\n\13\nfunction global.debug(...)\13\n\9if global.isDev then\13\n\9\9local t = {...}\13\n\9\9local s = \"[DEBUG] \" .. tostring(t[1])\13\n\9\9global.tbConsole:add(s, select(2, ...))\13\n\9\9global.ocl.add(s, select(2, ...))\13\n\9end\13\nend\13\n\13\nfunction global.slog(...)\13\n\9local t = {...}\13\n\9local s = \"[SINFO]: Start: \" .. tostring(t[1])\13\n\9global.tbConsole:add(s, select(2, ...))\13\n\9global.ocl.add(s, select(2, ...))\13\n\9for i, s in ipairs(t) do\13\n\9\9local ss = global.serialization.serialize(t[i]) .. \";\"\13\n\9\9global.tbConsole:add(ss)\13\n\9\9global.ocl.add(ss)\13\n\9end\13\n\9global.tbConsole:add(\"[SINFO]: End.\")\13\n\9global.ocl.add(\"[SINFO]: End.\")\13\nend\13\n\13\nfunction global.run(func, ...)\13\n\9if func ~= nil then\13\n\9\9func(...)\13\n\9end\13\nend\13\n\13\nfunction global.load(...)\13\n\9loadfile(\"data/core/dataLoading.lua\")(global, ...)\13\nend\13\n\13\nfunction global.drawDebug(...)\13\n\9if global.conf.showDebug then\13\n\9\9local debugString = \"\"\13\n\9\9local fillString = \"                                                           \"\13\n\9\9global.gpu.setForeground(0xaaaaaa)\13\n\9\9global.gpu.setBackground(0x333333)\13\n\9\9\13\n\9\9debugString = debugString .. \13\n\9\9\9\"CX:\" .. tostring(global.cameraPosX) .. \" CY:\" .. tostring(global.cameraPosY) .. \13\n\9\9\9\" | freeMemory: \" .. tostring(math.floor((global.computer.freeMemory() /1024) +.5)) .. \"KB\" ..\13\n\9\9\9\" | FPS\" .. tostring(math.floor((global.fps) +.5))\13\n\9\9\9\13\n\9\9for _, s in pairs({...}) do\13\n\9\9\9debugString = debugString .. \" | \" .. s\13\n\9\9end\13\n\9\9\13\n\9\9global.gpu.set(1, 1, debugString .. fillString)\13\n\9end\13\nend\13\n\13\nfunction global.clear()\13\n\9global.gpu.setBackground(global.backgroundColor)\13\n\9global.gpu.fill(1, 1, global.resX, global.resY, \" \")\13\n\9global.wre.newDraw()\13\nend\13\n\13\nfunction global.loadData(target, dir, func, print, overwrite)\13\n\9local id = 1\13\n\9if target.info ~= nil and target.info.amout ~= nil then\13\n\9\9id = target.info.amout +1\13\n\9end\13\n\9\13\n\9path = global.shell.getWorkingDirectory() .. \"/\" .. dir .. \"/\"\13\n\9print = print or global.orgPrint\13\n\9\13\n\9for file in global.fs.list(path) do\13\n\9\9local name = string.sub(file, 0, #file -4)\13\n\9\9\13\n\9\9if global.isDev then\13\n\9\9\9if target[name] == nil or overwrite then\13\n\9\9\9\9local debugString = \"\"\13\n\9\9\9\9if target[name] == nil then\13\n\9\9\9\9\9debugString = \"[global]: Loading file: \" .. dir .. \"/\" .. file .. \": \"\13\n\9\9\9\9else\13\n\9\9\9\9\9debugString = \"[global]: Loading (overwrite) file: \" .. dir .. \"/\" .. file .. \": \"\13\n\9\9\9\9end\13\n\9\9\9\9\13\n\9\9\9\9local suc, err = loadfile(path .. file)\13\n\9\9\9\9if suc == nil then\13\n\9\9\9\9\9print(debugString .. tostring(err))\13\n\9\9\9\9else\13\n\9\9\9\9\9print(debugString .. tostring(suc))\13\n\9\9\9\9end\13\n\9\9\9else\13\n\9\9\9\13\n\9\9\9end\13\n\9\9end\13\n\9\9\13\n\9\9if target[name] == nil or overwrite then\13\n\9\9\9target[name] = loadfile(path .. file)(global)\13\n\9\9\9\13\n\9\9\9if func ~= nil then\13\n\9\9\9\9func(name, id)\13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9id = id +1\13\n\9\9end\13\n\9end\13\n\9return id\13\nend\13\n\13\nfunction global.moveCamera(x, y)\13\n\9global.cameraSubPosX = global.cameraSubPosX +x\13\n\9global.cameraSubPosY = global.cameraSubPosY +y\13\n\9\13\n\9global.cameraPosX = math.floor(global.cameraSubPosX)\13\n\9global.cameraPosY = math.floor(global.cameraSubPosY)\13\n\9\13\n\9global.gpu.setBackground(global.backgroundColor) --debug: wip: todo:...\13\n\9global.gpu.fill(1, 1, global.resX, global.resY, \" \")----debug: wip: todo:...\13\nend\13\n\13\nfunction global.setConsoleSize(size)\13\n\9size = size or global.conf.consoleSizeY\13\n\9global.tbConsole.sizeX = global.resX\13\n\9global.tbConsole.sizeY = global.resY - (global.resY - size)\13\n\9global.tbConsole.posY = global.resY - size\13\nend\13\n\13\nfunction global.getFOVPixel() --gives the FOV in pixels.\13\n\9return global.cameraPosX, global.cameraPosX + global.resX, global.cameraPosY, global.cameraPosY + global.resY\13\nend\13\n\13\nfunction global.getFOV() --gives the FOV in blocks.\13\n\9local startX = global.cameraPosX / (global.texturePack.size *2)\13\n\9local startY = global.cameraPosY / (global.texturePack.size)\13\n\9return math.floor(startX), math.floor(startX + (global.resX / (global.texturePack.size *2))), math.floor(startY), math.floor(startY + (global.resY / (global.texturePack.size)))\13\nend\13\n\13\nfunction global.getBlockPos(x, y) --gives the block pos and id from relative pixel.\13\n\9local posX = math.floor(((x + global.cameraPosX) / (global.texturePack.size *2)))\13\n\9--local posY = math.floor((((y +1) + global.cameraPosY) / global.texturePack.size))\13\n\9local posY = math.floor(((y + global.cameraPosY) / global.texturePack.size))\13\n\9if global.map.blocks[posX] ~= nil then\13\n\9\9return posX, posY, global.map.blocks[posX][posY]\13\n\9else\13\n\9\9return posX, posY, nil\13\n\9end\13\nend\13\n\13\nfunction global.getBlock(x, y) --gives the block id, name and object (if loaded) from block pos in map.\13\n\9local id, name, object = nil, nil, nil\13\n\9if global.map[x] ~= nil then\13\n\9\9id = global.map.blocks[x][y]\13\n\9\9name = global.blocks.name[id]\13\n\9end\13\n\9if global.wre.blocks[x] ~= nil then\13\n\9\9object = global.wre.blocks[x][y]\13\n\9end\13\n\9return id, name, object\13\nend\13\n\13\nfunction global.getPixel(x, y) --give the relative pixel pos from a block\13\n\9local posX = math.floor(((x * global.texturePack.size) *2) - global.cameraPosX)\13\n\9local posY = math.floor((y * global.texturePack.size) - global.cameraPosY)\13\n\9return posX, posY\13\nend\13\n\13\nreturn global",["//data/core/occCore.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\n--===== Requires =====--\13\nlocal global = ...\13\n\13\n--===== Variables =====--\13\nlocal orgPrint = print\13\nlocal lastState = \"\"\13\nlocal frameCount = 0\13\nlocal lastFPSCheck = 0\13\n\13\n--===== Functions =====--\13\n\13\nlocal function print(...)\13\n\9global.log(...)\13\nend\13\n\13\nlocal function run(func, ...)\13\n\9if func ~= nil then\13\n\9\9local suc, err = xpcall(func, debug.traceback, ...)\13\n\9\9if not suc then\13\n\9\9\9print(\"[ERROR][OCCC]: Tryed to call \" .. tostring(func) .. \":\")\13\n\9\9\9print(tostring(err))\13\n\9\9\9print(debug.traceback())\13\n\9\9end\13\n\9end\13\nend\13\n\13\nlocal function updateState() \13\n\9if global.states[global.state] == nil then\13\n\9\9print(\"[ERROR]: State not found: \\\"\" .. global.state .. \"\\\".\")\13\n\9\9global.tbConsole:draw()\13\n\9\9global.isRunning = false\13\n\9else\13\n\9\9while global.state ~= lastState do\13\n\9\9\9if lastState ~= \"\" then\13\n\9\9\9\9run(global.states[lastState].stop)\13\n\9\9\9end\13\n\9\9\9lastState = global.state\13\n\9\9\9if not global.states[global.state].isInitialized then\13\n\9\9\9\9run(global.states[global.state].init)\13\n\9\9\9\9global.states[global.state].isInitialized = true\13\n\9\9\9end\13\n\9\9\9run(global.states[global.state].start)\13\n\9\9end\13\n\9\9if global.states[global.state].update ~= nil then --manual check to avoid log spamming on missing update func.\13\n\9\9\9run(global.states[global.state].update)\13\n\9\9end\13\n\9end\13\nend\13\n\13\nlocal function start()\13\n\9global.gpu.setBackground(0x000000)\13\n\9global.term.clear()\13\n\9\13\n\9if global.isDev then\13\n\9\9--global.state = \"game\"\13\n\9\9global.state = global.conf.debug.defaultState\13\n\9else\13\n\9\9--global.state = \"game\"\13\n\9\9--global.state = \"loadGame\"\13\n\9\9global.state = global.conf.debug.defaultState\13\n\9end\13\n\9\13\n\9global.lastUptime = global.computer.uptime()\13\nend\13\n\13\nlocal function update()\13\n\9global.lastCameraPosX = global.cameraPosX\13\n\9global.lastCameraPosY = global.cameraPosY\13\n\9\13\n\9if frameCount >= global.conf.fpsCheckInterval then\13\n\9\9global.fps = global.conf.fpsCheckInterval / (global.computer.uptime() - lastFPSCheck)\13\n\9\9lastFPSCheck = global.computer.uptime()\13\n\9\9frameCount = 0\13\n\9else\13\n\9\9frameCount = frameCount +1\13\n\9end\13\n\9\13\n\9updateState()\13\n\9\13\n\9\13\n\9\13\n\9--print(global.cameraPosX, global.cameraPosY)\13\nend\13\n\13\nlocal function draw()\13\n\9global.gpu.setBackground(0x000000)\13\n\9--global.gpu.fill(1, 1, global.resX, global.resY, \" \")\13\n\9\13\n\9if global.states[global.state].draw ~= nil then\9--manual check to avoid log spamming on missing draw func.\13\n\9\9run(global.states[global.state].draw)\13\n\9end\13\n\9\13\n\9global.ocui:draw()\13\n\9if global.conf.showConsole then\13\n\9\9global.tbConsole:draw()\13\n\9end\13\nend\13\n\13\nlocal function touch(_, _, x, y, b, p)\13\n\9global.ocui:update(x, y)\13\n\9run(global.states[global.state].touch, x, y, b, p)\13\nend\13\n\13\nlocal function drag(_, _, x, y, b, p)\13\n\9run(global.states[global.state].drag, x, y, b, p)\13\nend\13\n\13\nlocal function drop(_, _, x, y, b, p)\13\n\9run(global.states[global.state].drop, x, y, b, p)\13\nend\13\n\13\nlocal function keyDown(_, _, c, k, p)\13\n\9if c == 3 then --ctrl + c\13\n\9\9print(\"Program stopped by user.\")\13\n\9\9global.isRunning = false\13\n\9end\13\n\9\13\n\9if k == global.controls.debug.showConsole then\13\n\9\9global.conf.showConsole = not global.conf.showConsole\13\n\9\9if not global.conf.showConsole then\13\n\9\9\9global.clear()\13\n\9\9end\13\n\9end\13\n\9\13\n\9run(global.states[global.state].keyDown, c, k, p)\13\n\9\13\n\9if k == global.controls.debug.showDebug then --f3\13\n\9\9global.conf.showDebug = not global.conf.showDebug\13\n\9\9if not global.conf.showDebug then\13\n\9\9\9global.clear()\13\n\9\9end\13\n\9end\13\n\9if k == global.controls.debug.reloadState and global.isDev then --f5\13\n\9\9global.log(\"========== RELOAD STAGE ==========\")\13\n\9\9run(global.states[global.state].stop)\13\n\9\9global.states[global.state] = nil\13\n\9\9\13\n\9\9if global.conf.debug.onReload.conf then\13\n\9\9\9global.conf = dofile(\"conf.lua\")\13\n\9\9end\13\n\9\9global.conf.debug.onReload.reload = true\13\n\9\9global.load(global.conf.debug.onReload)\13\n\9\9global.conf.debug.onReload.reload = nil\13\n\9\9\13\n\9\9global.states[global.state] = loadfile(\"data/states/\" .. global.state .. \".lua\")(global)\13\n\9\9run(global.states[global.state].init)\13\n\9\9run(global.states[global.state].start)\13\n\9\9\13\n\9\9global.clear()\13\n\9end\13\n\9if k == global.controls.debug.rerenderScreen then --f6\13\n\9\9global.clear()\13\n\9end\13\n\9\13\nend\13\n\13\nlocal function keyUp(_, _, c, k, p)\13\n\9run(global.states[global.state].keyUp, c, k, p)\13\nend\13\n\13\nlocal function progamEnd()\13\n\9global.event.ignore(\"touch\", touch)\13\n\9global.event.ignore(\"drag\", drag)\13\n\9global.event.ignore(\"drop\", drop)\13\n\9global.event.ignore(\"key_down\", keyDown)\13\n\9global.event.ignore(\"key_up\", keyUp)\13\n\9\13\n\9for _, s in pairs(global.states) do\13\n\9\9run(s.stop)\13\n\9end\13\n\9\13\n\9global.tbConsole:draw()\13\n\9global.ocl.close()\13\nend\13\n\13\n--===== global.event listening =====--\13\nglobal.event.listen(\"touch\", touch)\13\nglobal.event.listen(\"drop\", drop)\13\nglobal.event.listen(\"drag\", drag)\13\nglobal.event.listen(\"key_down\", keyDown)\13\nglobal.event.listen(\"key_up\", keyUp)\13\n\13\n--===== std program structure / main while =====--\13\nlocal std_previousScreenResolution = {global.gpu.getResolution()}\13\nlocal std_success = true\13\nlocal function std_onError(f, ...)\13\n\9print = orgPrint\13\n\9global.isRunning = false\13\n\9std_success = false\13\n\9global.gpu.setForeground(0xff0000)\13\n\9global.gpu.setBackground(0x000000)\13\n\9print(\"[ERROR] in func: \" .. f)\13\n\9print(...)\13\n\9global.gpu.setForeground(0xffffff)\13\n\9global.fatal(\"In func: \" .. tostring(f))\13\n\9global.fatal(...)\13\nend\13\n\13\nlocal s, m = xpcall(start, debug.traceback)\13\nif s == false then\13\n\9std_onError(\"start()\", m, debug.traceback())\13\nend\13\n\13\nwhile global.isRunning do\13\n\9local s, m = xpcall(update, debug.traceback)\13\n\9if s == false then\13\n\9\9std_onError(\"update()\", m, debug.traceback())\13\n\9\9break\13\n\9end\13\n\9\13\n\9if global.isRunning then\13\n\9\9local s, m = xpcall(draw, debug.traceback)\13\n\9\9if s == false then\13\n\9\9\9std_onError(\"draw()\", m, debug.traceback())\13\n\9\9\9break\13\n\9\9end\13\n\9end\13\n\9\13\n\9global.dt = global.computer.uptime() - global.lastUptime\13\n\9global.lastUptime = global.computer.uptime()\13\n\9\13\n\9if global.conf.targetFramerate == -1 then\13\n\9\9os.sleep()\13\n\9else\13\n\9\9os.sleep((1 / global.conf.targetFramerate) - math.max(global.dt - (1 / global.conf.targetFramerate), 0))\13\n\9end\13\nend\13\n\13\nprogamEnd()\13\nglobal.gpu.setForeground(0xffffff)\13\nglobal.gpu.setBackground(0x000000)\13\nglobal.gpu.setResolution(std_previousScreenResolution[1], std_previousScreenResolution[2])\13\n\13\nreturn std_success, \"failed\"",["//data/core/"] = 0,["//data/stateData/game/camera.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\nlocal camera = {}\13\n\13\nfunction camera.update(game)\13\n\9--===== auto camera movement =====--\13\n\9local edgeSize = 0\13\n\9if game.player.gameObject.posX + (global.texturePack.size *2) + edgeSize *2 > global.resX then\13\n\9\9global.moveCamera(global.resX - ((edgeSize +3) *2) - (global.texturePack.size *2), 0)\13\n\9end\13\n\9if game.player.gameObject.posX < (edgeSize +2) *2 then\13\n\9\9global.moveCamera(- (global.resX - ((edgeSize +3) *2) - (global.texturePack.size *2)), 0)\13\n\9end\13\n\9\13\n\9if game.player.gameObject.posY + (global.texturePack.size *2) + edgeSize *2 > global.resY then\13\n\9\9global.moveCamera(0, global.resY - ((edgeSize +3) *2) - (global.texturePack.size *2))\13\n\9end\13\n\9if game.player.gameObject.posY < (edgeSize +2) *2 then\13\n\9\9global.moveCamera(0, - (global.resY - ((edgeSize +3) *2) - (global.texturePack.size *2)))\13\n\9end\13\n\9\13\n\9--===== manual camera movement =====--\13\n\9if global.keyboard.isKeyDown(global.controls.cameraUp) then\13\n\9\9global.moveCamera(0, - global.conf.cameraSpeed /2)\13\n\9end\13\n\9if global.keyboard.isKeyDown(global.controls.cameraDown) then\13\n\9\9global.moveCamera(0, global.conf.cameraSpeed /2)\13\n\9end\13\n\9if global.keyboard.isKeyDown(global.controls.cameraLeft) then\13\n\9\9global.moveCamera(-global.conf.cameraSpeed, 0)\13\n\9end\13\n\9if global.keyboard.isKeyDown(global.controls.cameraRight) then\13\n\9\9global.moveCamera(global.conf.cameraSpeed, 0)\13\n\9end\13\nend\13\n\13\nreturn camera",["//data/stateData/game/"] = 0,["//data/stateData/"] = 0,["//data/biomes/surface.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\n--global.conf.showConsole = false --debug\13\n\13\nlocal surface = {\13\n\9alreadyGenerated = {},\13\n\9seed = 1,\13\n\9\13\n\9maxHeight = -2,\13\n\9minHeight = -10,\13\n\9actualHeight = -2,\13\n\9\13\n\9minDirtLayerSize = 1,\13\n\9maxDirtLayerSize = 4,\13\n\9\13\n\9treeChance = 5,\13\n}\13\n\13\nlocal function addBlock(x, y, b)\13\n\9y = -y\13\n\9if global.map.blocks[x] == nil then\13\n\9\9global.map.blocks[x] = {}\13\n\9end\13\n\9if global.map.alreadyGenerated[x] == nil then\13\n\9\9global.map.alreadyGenerated[x] = {}\13\n\9end\13\n\9\13\n\9if global.map.blocks[x][y] == nil and global.map.alreadyGenerated[x][y] == nil then\13\n\9\9global.wre.addBlock(x, y, b, false)\13\n\9\9global.map.alreadyGenerated[x][y] = true\13\n\9end\13\nend\13\n\13\nlocal function spawnTree(x, y, s)\13\n\9global.log(\"TREE\")\13\nend\13\n\13\nmath.randomseed(surface.seed)\13\nfunction surface.generate()\13\n\9local fromX, toX, fromY, toY = global.getFOV()\13\n\9--toY = 100\13\n\9\13\n\9for x = fromX, toX do\13\n\9\9if global.map.blocks[x] == nil then\13\n\9\9\9global.map.blocks[x] = {}\13\n\9\9\9\13\n\9\9\9if surface.actualHeight > math.random(surface.minHeight, surface.maxHeight) then\13\n\9\9\9\9surface.actualHeight = math.random(surface.actualHeight, surface.maxHeight)\13\n\9\9\9else\13\n\9\9\9\9surface.actualHeight = math.random(surface.minHeight, surface.actualHeight)\13\n\9\9\9end\13\n\9\9\9global.map.blocks[x].height = surface.actualHeight\13\n\9\9else\13\n\9\9\9surface.actualHeight = global.map.blocks[x].height\13\n\9\9end\13\n\9\9\13\n\9\9for y = fromY, toY do\13\n\9\9\9y = -y\13\n\9\9\9if y < surface.actualHeight then\13\n\9\9\9\9addBlock(x, y, \"Stone\")\13\n\9\9\9else\13\n\9\9\9\9spawnTree()\13\n\9\9\9end\13\n\9\9\9\13\n\9\9end\13\n\9end\13\nend\9\13\n\13\nreturn surface\13\n\13\n\13\n\13\n\13\n\13\n\13\n",["//data/biomes/"] = 0,["//data/blocks/Leaves.lua"] = "local global = ...\13\n\13\nLeaves = {}\13\nLeaves.__index = Leaves\13\n\13\nfunction Leaves.new(args)\13\n\9args.texture = global.textures[\"leaves\"]\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, Leaves)\13\n\9\13\n\9this.update = function(this)\13\n\9\9\13\n\9\9\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Leaves",["//data/blocks/WoodLog.lua"] = "local global = ...\13\n\13\nWoodLog = {}\13\nWoodLog.__index = WoodLog\13\n\13\nfunction WoodLog.new(args)\13\n\9args.texture = global.textures[\"woodLog\"]\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, WoodLog)\13\n\9\13\n\9\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn WoodLog",["//data/blocks/Bedrock.lua"] = "local global = ...\13\n\13\nBedrock = {}\13\nBedrock.__index = Bedrock\13\n\13\nfunction Bedrock.new(args)\13\n\9args.texture = global.textures[\"bedrock\"]\13\n\9args.hardness = -1\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, Bedrock)\13\n\9\13\n\9\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Bedrock",["//data/blocks/Wheat.lua"] = "local global = ...\13\n\13\nWheat = {}\13\nWheat.__index = Wheat\13\n\13\nfunction Wheat.new(args)\13\n\9args.texture = global.textures[\"wheat\"]\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, Wheat)\13\n\9\13\n\9\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Wheat",["//data/blocks/Dirt.lua"] = "local global = ...\13\n\13\nDirt = {}\13\nDirt.__index = Dirt\13\n\13\nfunction Dirt.new(args)\13\n\9args.texture = global.textures[\"dirt\"]\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, Dirt)\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Dirt",["//data/blocks/Stone.lua"] = "local global = ...\13\n\13\nStone = {}\13\nStone.__index = Stone\13\n\13\nfunction Stone.new(args)\13\n\9args.texture = global.textures[\"stone\"]\13\n\9local this = global.Block.new(args)\13\n\9this = setmetatable(this, Stone)\13\n\9\13\n\9\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Stone",["//data/blocks/"] = 0,["//data/entities/Player.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\nPlayer = {}\13\nPlayer.__index = Player\13\n\13\nfunction Player.new(args)\13\n\9args.sizeY = 2\13\n\9args.texture = global.textures[\"player\"]\13\n\9local this = global.Entity.new(args)\13\n\9this = setmetatable(this, Player)\13\n\9\13\n\9this.ocui = global.ocui.initiate(global.ocgl)\13\n\9\13\n\9this.lInv = this.ocui.List.new(this.ocui, 0, 2, 30, 0, {}, {conf = {true}}) --regenerated on inv open.\13\n\9\13\n\9this.inv = {}\13\n\9this.showInv = false\13\n\9this.invKeyIsPressed = false\13\n\9this.selected = 1\13\n\9\13\n\9this.isCreative = false\13\n\9this.range = 1000\13\n\9this.acceleraion = 20\13\n\9this.maxSpeed = 30 --bug: shouldn't be more than the texturepack size (ocgf rigidbody)\13\n\9this.jumpForce = 1\13\n\9this.breakDamage = 1\13\n\9\13\n\9\13\n\9this.gameObject:addBoxTrigger({\13\n\9\9x = 0, \13\n\9\9y = 0, \13\n\9\9sx = global.texturePack.size *2, \13\n\9\9sy = (global.texturePack.size * 2) +1, \13\n\9\9lf = function() \13\n\9\9\9this.isJumping = false\13\n\9\9end,\13\n\9}) --ToDo: trigger y size texturepack bla.\13\n\9\13\n\9this.update = function(this) \13\n\9\9this.gameObject:stopAnimation(nil, true)\13\n\9\9if global.keyboard.isKeyDown(global.controls.left) then\13\n\9\9\9this:addForce(- this.acceleraion, 0, this.maxSpeed)\13\n\9\9\9this.gameObject:playAnimation(-1)\13\n\9\9\9this:turn(true)\13\n\9\9end\13\n\9\9if global.keyboard.isKeyDown(global.controls.right) then\13\n\9\9\9this:addForce(this.acceleraion, 0, this.maxSpeed)\13\n\9\9\9this.gameObject:playAnimation()\13\n\9\9\9this:turn(false)\13\n\9\9end\13\n\9\9\13\n\9\9if global.keyboard.isKeyDown(global.controls.jump) then\13\n\9\9\9if this.isJumping == false then\13\n\9\9\9\9this:addForce(0, - this.jumpForce)\13\n\9\9\9\9this.isJumping = true\13\n\9\9\9end\13\n\9\9\9\13\n\9\9end\13\n\9\9if global.keyboard.isKeyDown(global.controls.sneak) then\13\n\9\9\9\13\n\9\9end\13\n\9end\13\n\9\13\n\9this.draw = function(this)\13\n\9\9if this.showInv then\13\n\9\9\9this.ocui:draw()\13\n\9\9\9\13\n\9\9\9global.gpu.setBackground(0x555555)\13\n\9\9\9global.gpu.setForeground(0xaaaaaa)\13\n\9\9\9global.gpu.set(1, 1, \"  --===== Inventory =====--  \")\13\n\9\9end\13\n\9end\13\n\9\13\n\9this.keyDown = function(this, c, k, p)\13\n\9\9if k == global.controls.inv and this.invKeyIsPressed == false then\13\n\9\9\9this.showInv = not this.showInv\13\n\9\9\9this.invKeyIsPressed = true\13\n\9\9\9if this.showInv then\13\n\9\9\9\9this.lInv:stop()\13\n\9\9\9\9this.lInv = nil\13\n\9\9\9\9\13\n\9\9\9\9local inv = {}\13\n\9\9\9\9for i, c in pairs(this.inv) do\13\n\9\9\9\9\9local id = \"\"\13\n\9\9\9\9\9if global.conf.debug.showBlockId then\13\n\9\9\9\9\9\9id = \" (#\" .. i .. \")\"\13\n\9\9\9\9\9end\13\n\9\9\9\9\9table.insert(inv, i .. c.name .. id .. \" (\" .. c.amout .. \")\")\13\n\9\9\9\9end\13\n\9\9\9\9\13\n\9\9\9\9local sizeY  = 0\13\n\9\9\9\9if global.conf.showConsole then \13\n\9\9\9\9\9sizeY = global.resY - global.conf.consoleSizeY -3\13\n\9\9\9\9else\13\n\9\9\9\9\9sizeY = global.resY -2\13\n\9\9\9\9end\13\n\9\9\9\9this.lInv = this.ocui.List.new(this.ocui, 0, 2, 30, sizeY, inv, {config = {true, -1}, listedFunction = function(_, content)\13\n\9\9\9\9\9this:select(string.sub(content, 1))\13\n\9\9\9\9\9this.showInv = false\13\n\9\9\9\9\9global.clear()\13\n\9\9\9\9end})\13\n\9\9\9else\13\n\9\9\9\9global.clear()\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9this.keyUp = function(this, c, k, p)\13\n\9\9if k == global.controls.inv then\13\n\9\9\9this.invKeyIsPressed = false\13\n\9\9end\13\n\9end\13\n\9\13\n\9this.touch = function(this, x, y, b, p, drag)\13\n\9\9local fromX = this.gameObject.posX - (this.range * (global.texturePack.size *2))\13\n\9\9local fromY = this.gameObject.posY - (this.range * (global.texturePack.size))\13\n\9\9local toX = this.gameObject.posX + ((this.range +1) * (global.texturePack.size *2))\13\n\9\9local toY = this.gameObject.posY + ((this.range +2) * (global.texturePack.size))\13\n\9\9\13\n\9\9if this.showInv == false and x > fromX and x < toX and y > fromY and y < toY then\13\n\9\9\9local bx, by = global.getBlockPos(x, y)\13\n\9\9\9\13\n\9\9\9if global.keyboard.isAltDown() and b == global.controls.place then\13\n\9\9\9\9b = global.controls.broke\13\n\9\9\9elseif global.keyboard.isAltDown() and b == global.controls.broke then\13\n\9\9\9\9b = global.controls.place\13\n\9\9\9end\13\n\9\9\9\13\n\9\9\9if b == global.controls.place and \13\n\9\9\9\9this.inv[this.selected] ~= nil and\13\n\9\9\9\9this.inv[this.selected].amout > 0\13\n\9\9\9then\13\n\9\9\9\9if this.isCreative == false and this.inv[this.selected].amout <= 1 then\13\n\9\9\9\9\9this.inv[this.selected] = nil\13\n\9\9\9\9elseif this.isCreative == false then\13\n\9\9\9\9\9this.inv[this.selected].amout = this.inv[this.selected].amout -1\13\n\9\9\9\9end\13\n\9\9\9\9global.wre.addBlock(bx, by, this.selected)\13\n\9\9\9elseif b == global.controls.broke then --ToDo: add break damage check.\13\n\9\9\9\9local removed, block = global.wre.removeBlock(bx, by)\13\n\9\9\9\9if block ~= nil then\13\n\9\9\9\9\9this:addToInv(block, 1)\13\n\9\9\9\9end\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9\13\n\9this.drag = function(this, x, y, b, p)\13\n\9\9this:touch(x, y, b, p, true)\13\n\9end\13\n\9\13\n\9this.drop = function(this, x, y, b, p)\13\n\9\9this.ocui:update(x, y)\13\n\9end\13\n\9\13\n\9this.addToInv = function(this, block, amout)\13\n\9\9if type(block) == \"string\" then\13\n\9\9\9block = global.blocks.id[block]\13\n\9\9end\13\n\9\9\13\n\9\9if type(block) ~= \"number\" then\13\n\9\9\9global.warn(\"Tryed to add invalid block to player inv: \" .. tostring(block))\13\n\9\9\9return false\13\n\9\9end\13\n\9\9\13\n\9\9if this.inv[block] == nil then\13\n\9\9\9this.inv[block] = {amout = amout, name = global.blocks.name[block]}\13\n\9\9else\13\n\9\9\9this.inv[block].amout = this.inv[block].amout +amout\13\n\9\9end\13\n\9\9return true\13\n\9end\13\n\9\13\n\9this.select = function(this, c)\13\n\9\9if type(c) == \"string\" then\13\n\9\9\9c = tonumber(string.sub(c, 0, 1))\13\n\9\9end\13\n\9\9this.selected = c\13\n\9end\13\n\9\13\n\9this.stop = function(this)\13\n\9\9this.ocui:stop()\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Player",["//data/entities/"] = 0,["//data/parents/Entity.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\nlocal global = ...\13\n\13\nlocal Entity = {}\13\nEntity.__index = Entity\13\n\13\nfunction Entity.init()\13\n\13\nend\13\n\13\nfunction Entity.new(args)\13\n\9local this = setmetatable({}, Entity)\13\n\9\13\n\9this.posX = args.posX or 0 --pos in world (in blocks).\13\n\9this.posY = args.posY or 0 --pos in world (in blocks).\13\n\9this.index = args.index or -1 --index in world table.\13\n\9\13\n\9this.sizeX = ((args.sizeX or 1) * (global.texturePack.size *2))\13\n\9this.sizeY = (args.sizeY or 1) * global.texturePack.size\13\n\9\13\n\9if args.texture == nil then\13\n\9\9args.texture = global.ocgl.generateTexture({})\13\n\9elseif type(args.texture) == \"string\" then\13\n\9\9args.texture = global.textures[args.texture]\13\n\9end\13\n\9this.texture = args.texture \13\n\9this.looksToLeft = false\13\n\9\13\n\9local tmpTexture = global.ocgl.generateTexture({})\13\n\9if this.texture.right ~= nil then\13\n\9\9tmpTexture = this.texture.right\13\n\9else\13\n\9\9tmpTexture = this.texture\13\n\9end\13\n\9\13\n\9this.gameObject = global.ocgf.GameObject.new(global.ocgf, {\13\n\9\9dc = global.conf.debug.drawCollider,\13\n\9\9dt = global.conf.debug.drawTrigger,\13\n\9\9logFunc = global.log;\13\n\9\9\13\n\9})\13\n\9this.gameObject:addBoxCollider({\13\n\9\9sx = this.sizeX,\13\n\9\9sy = this.sizeY,\13\n\9})\13\n\9this.gameObject:addRigidBody({\13\n\9\9g = 10,\13\n\9\9stiffness = .5,\13\n\9})\13\n\9this.gameObject:addSprite({\13\n\9\9texture = tmpTexture\13\n\9})\13\n\9\13\n\9\13\n\9this.turn = function(this, toLeft)\13\n\9\9local tmpTexture = nil\13\n\9\9if toLeft then\13\n\9\9\9this.looksToLeft = true\13\n\9\9\9tmpTexture = this.texture.left\13\n\9\9else\13\n\9\9\9this.looksToLeft = false\13\n\9\9\9tmpTexture = this.texture.right\13\n\9\9end\13\n\9\9if tmpTexture ~= nil then\13\n\9\9\9for _, s in pairs(this.gameObject:getSprites()) do\13\n\9\9\9\9s:clear(global.backgroundColor)\13\n\9\9\9\9s:changeTexture(tmpTexture)\13\n\9\9\9end\13\n\9\9end\13\n\9end\13\n\9this.move = function(this, x, y)\13\n\9\9this.gameObject:move(x, y)\13\n\9end\13\n\9this.moveTo = function(this, x, y)\13\n\9\9this.gameObject:moveTo(x, y)\13\n\9end\13\n\9this.addForce = function(this, x, y, maxSpeed)\13\n\9\9this.gameObject:addForce(x * (global.texturePack.size *2), y * global.texturePack.size, maxSpeed)\13\n\9end\13\n\9this.setSpeed = function(this, x, y)\13\n\9\9this.gameObject:setSpeed(x, y)\13\n\9end\13\n\9\13\n\9this.pStart = function(this) --parent func \13\n\9\9global.run(this.start, this)\13\n\9end\13\n\9this.pUpdate = function(this) --parent func\13\n\9\9global.run(this.update, this)\13\n\9end\13\n\9this.pActivate = function(this) --parent func\13\n\9\9global.run(this.activate, this)\13\n\9end\13\n\9this.pDraw = function(this) --parent func\13\n\9\9for _, s in pairs(this.gameObject:getSprites()) do\13\n\9\9\9s.background = global.backgroundColor\13\n\9\9end\13\n\9\9global.run(this.draw, this)\13\n\9end\13\n\9this.pClear = function(this) --parent func\13\n\9\9global.run(this.clear, this)\13\n\9end\13\n\9this.pStop = function(this)\13\n\9\9this.gameObject:stop()\13\n\9\9global.run(this.stop, this)\13\n\9end\13\n\9this.pSpawn = function(this) --parent func\13\n\9\9global.run(this.spawn, this)\13\n\9end\13\n\9this.pDespawn = function(this) --parent func\13\n\9\9global.run(this.despawn, this)\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Entity",["//data/parents/Block.lua"] = "--[[\13\n\9ocCraft Copyright (C) 2019 MisterNoNameLP.\13\n\9\13\n    This file is part of ocCraft.\13\n\13\n    ocCraft is free software: you can redistribute it and/or modify\13\n    it under the terms of the GNU General Public License as published by\13\n    the Free Software Foundation, either version 3 of the License, or\13\n    (at your option) any later version.\13\n\13\n    ocCraft is distributed in the hope that it will be useful,\13\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\13\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\13\n    GNU General Public License for more details.\13\n\13\n    You should have received a copy of the GNU General Public License\13\n    along with ocCraft.  If not, see <https://www.gnu.org/licenses/>.\13\n]]\13\n\13\n--Block main class\13\nlocal global = ...\13\n\13\nlocal Block = {version = \"v0.0d\"}\13\nBlock.__index = Block\13\n\13\nfunction Block.init(this) --parent func\13\n\9\13\nend\13\n\13\nfunction Block.new(args)\13\n\9local this = setmetatable({}, Block)\13\n\9this.id = blockId\13\n\9\13\n\9this.hardness = args.hardness or 0\13\n\9this.damage = args.damage or 0\13\n\9\13\n\9if type(args.texture) == \"string\" then\13\n\9\9args.texture = global.textures[args.texture]\13\n\9end\13\n\9\13\n\9this.gameObject = global.ocgf.GameObject.new(global.ocgf, {\13\n\9\9dc = global.conf.debug.drawCollider,\13\n\9\9x = args.posX,\13\n\9\9y = args.posY\13\n\9})\13\n\9this.gameObject:addBoxCollider({\13\n\9\9sx = global.texturePack.size *2, \13\n\9\9sy = global.texturePack.size, \13\n\9})\13\n\9this.gameObject:addSprite({\13\n\9\9texture = args.texture or global.ocgl:generateTexture(),\13\n\9})\13\n\9\13\n\9this.getPos = function()\13\n\9\9return global.getBlockPos(this.gameObject.posX, this.gameObject.posY)\13\n\9end\13\n\9\13\n\9this.pRemoved = function(this) --parent func\13\n\9\9global.run(this.removed, this)\13\n\9end\13\n\9this.pPlaced = function(this) --parent func\13\n\9\9global.run(this.placed, this)\13\n\9end\13\n\9this.pStart = function(this) --parent func \13\n\9\9global.run(this.start, this)\13\n\9end\13\n\9this.pUpdate = function(this)\13\n\9\9global.run(this.update, this)\13\n\9end\13\n\9this.pDraw = function(this)\13\n\9\9this.gameObject:draw()\13\n\9\9global.run(this.draw, this)\13\n\9end\13\n\9this.pClear = function(this, acctual)\13\n\9\9this.gameObject:clear(global.backgroundColor, acctual)\13\n\9\9global.run(this.clear, this)\13\n\9end\13\n\9this.pStop = function(this)\13\n\9\9global.run(this.stop, this)\13\n\9end\13\n\9this.pActivate = function(this) --parent func\13\n\9\9global.run(this.activate, this)\13\n\9end\13\n\9\13\n\9return this\13\nend\13\n\13\nreturn Block",["//data/parents/"] = 0,["//data/"] = 0,}
  23. --===== local functions =====--
  24. function seperatePath(path) --Ripped from UT_v0.6.1
  25. --seperates a data path ["./DIR/FILE.ENDING"] into the dir path ["./DIR/"], the file name ["FILE"], and the file ending [".ENDING" or nil]
  26.     if string.sub(path, #path) == "/" then
  27.         return path
  28.     end
  29.    
  30.     local dir, fileName, fileEnd = "", "", nil
  31.     local tmpLatest = ""
  32.     for s in string.gmatch(tostring(path), "[^/]+") do
  33.         tmpLatest = s
  34.     end
  35.     dir = string.sub(path, 0, #path -#tmpLatest)
  36.     for s in string.gmatch(tostring(tmpLatest), "[^.]+") do
  37.         fileName = fileName .. s
  38.         tmpLatest = s
  39.     end
  40.     if fileName == tmpLatest then
  41.         fileName = tmpLatest
  42.     else
  43.         fileEnd = "." .. tmpLatest
  44.         fileName = string.sub(fileName, 0, #fileName - #fileEnd +1)
  45.     end
  46.    
  47.     return dir, fileName, fileEnd
  48. end
  49.  
  50. --===== prog start =====--
  51. local fs = require("filesystem")
  52. local shell = require("shell")
  53. local serialization = require("serialization")
  54.  
  55. local args, opts = shell.parse(...)
  56. local emptyBufferSpace = 10
  57.  
  58. if opts.h or #args == 0 then
  59.    
  60.     print("Usage: SETUP [OPTIONS]... [TARGET_DIR]...")
  61.     print("  -h         Shows this text.")
  62.     print("  -o             Overwrite the EXPORT_DIR.")
  63.    
  64.     return true
  65. end
  66.  
  67. print(licenseNotice)
  68.  
  69. if not opts.o then
  70.     if string.sub(args[1], 0, 1) == "/" and fs.exists(args[1]) then
  71.         return false, "Folder exists already."
  72.     elseif fs.exists(shell.getWorkingDirectory() .. args[1]) then
  73.         return false, "Folder exists already."
  74.     end
  75. end
  76.  
  77. for i, s in pairs(data) do
  78.     local path, file, ending = seperatePath(i)
  79.     file = (file or "") .. (ending or "")
  80.     if string.sub(args[1], 0, 1) == "/" then
  81.         path = "/" .. args[1] .. "/" .. (path or "")
  82.     else
  83.         path = shell.getWorkingDirectory() .. "/" .. args[1] .. "/" .. (path or "")
  84.     end
  85.    
  86.     print("Create file: " .. path .. file)
  87.    
  88.     fs.makeDirectory(path)
  89.     if s ~= 0 then
  90.         local f = io.open(path .. file, "w")
  91.         for c = 1, #s, (f.bufferSize - emptyBufferSpace) +1 do
  92.             f:write(string.sub(s, c, c + f.bufferSize - emptyBufferSpace))
  93.             f:flush()
  94.         end
  95.         f:close()
  96.     end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement