Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- debugOn = false
- status1 = ""
- status2 = ""
- tickLength = 1.0 / 20.0
- --[[
- local tArgs = { ... }
- if table.getn(tArgs) < 1 then
- print("Usage: nbtbuild <schematicFile>")
- return
- end
- file = fs.open(tArgs[1],"rb")
- schem = ""
- byte = file.read()
- while byte ~= nil do
- schem = schem..string.char(byte)
- byte = file.read()
- end
- --schem = file.readAll()
- file.close()
- blacklistedBlocks = {}
- blacklistedBlocks[64]=true
- blockNames = {}
- blockCount = {}
- slots = {-1,-1,-1,-1,-1,-1,-1,-1,-1}
- slotCount = {0,0,0,0,0,0,0,0,0}
- vecModX = {0,1,0,-1}
- vecModZ = {-1,0,1,0}
- animStates = { "|","/","-","\\" }
- lastAnim = 0
- animSpeed = 0.4
- charAnim = 0
- --]]
- pather= {}
- pather.location = {0,0,0}
- function pather.setPos(newLoc)
- pather.location = newLoc
- end
- function pather.findNearestBlock(maxDepth)
- local nextLoc = getListCopy(pather.location)
- local pathList = {}
- local modList = { {-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1} }
- table.insert(pathList,getListCopy(pather.location))
- while #pathList > 0 do
- local nLoc = pathList[1]
- local nX,nY,nZ = nLoc[1],nLoc[2],nLoc[3]
- table.remove(pathList,1)
- for k,v in pairs(modList) do
- local nnLoc = utils.getListCopy(nLoc)
- nnLoc[1] = nnLoc[1] + v[1]
- nnLoc[3] = nnLoc[3] + v[2]
- if nbtParser.isValid(nnLoc) == true then
- table.insert(pathList
- end
- end
- end
- forwardDist = 0
- while true do
- forwardDist = forwardDist + 1
- nextLoc[1] = nextLoc[1] + mover.vecModX[mover.dir]
- nextLoc[3] = nextLoc[3] + mover.vecModZ[mover.dir]
- if nbtParser.isValidLoc(nextLoc) then
- if nbtParser.isAir( nextLoc ) == false then
- end
- else
- break
- end
- end
- end
- config = {}
- function config.LoadBlockNames()
- if not fs.exists("BlockIDs") then
- pError("BLOCK ID File not found",false)
- return
- end
- local file = fs.open("BlockIDs", "r")
- line = file.readLine()
- while line ~= nil do
- splitPos = line:find("=",1,true)
- if splitPos ~= nil then
- local index = tonumber( line:sub(1,splitPos-1) )
- blockNames[index]=line:sub(splitPos+1)
- end
- line = file.readLine()
- end
- file.close()
- end
- function config.getBlockName(bID)
- if bID == -1 then return "None" end
- if blockNames[bID] ~= nil then
- return blockNames[bID]
- end
- return "_ID"..bID
- end
- utils = {}
- function utils.getBasePath(fullPath)
- localPath = fullPath
- for i=string.len(fullPath),1,-1 do
- if string.sub(fullPath,i,i) == "/" then
- localPath = string.sub(fullPath,0,i)
- break
- end
- end
- return localPath
- end
- function utils.getListCopy(org)
- local copy = {}
- for i,v in ipairs(org) do
- copy[i]=v
- end
- return copy
- end
- function utils.timeoutFunc(func,timeout, ...)
- local start = os.clock()
- while not func(...) do
- if not timeout or os.clock() > start + timeout then
- return false
- end
- end
- return true
- end
- mover = {}
- mover.vecModX = {0,1,0,-1}
- mover.vecModZ = {-1,0,1,0}
- mover.dir = 1
- mover.location = {0,0,0}
- function mover.turnLeft()
- turtle.turnLeft()
- --gui.animStep()
- mover.dir = mover.dir - 1
- if mover.dir < 1 then
- mover.dir = 4
- end
- processing.persistenceUpdate()
- end
- function mover.turnRight()
- turtle.turnRight()
- --gui.animStep()
- mover.dir = mover.dir + 1
- if mover.dir > 4 then
- mover.dir = 1
- end
- processing.persistenceUpdate()
- end
- function mover.moveUp()
- while not turtle.up() do
- end
- mover.location[2] = mover.location[2]+1
- processing.persistenceUpdate()
- --gui.animStep()
- end
- function mover.moveDown()
- while not turtle.down() do
- end
- mover.location[2]=mover.location[2]-1
- processing.persistenceUpdate()
- --gui.animStep()
- end
- function mover.moveForward()
- while not utils.timeoutFunc(turtle.forward,10) do
- gui.reportTempStatus("Blocked","Please move!")
- end
- gui.clearTempStatus()
- mover.addLocationStep()
- --gui.animStep()
- end
- function mover.moveBackward()
- while not utils.timeoutFunc(turtle.back,10) do
- gui.reportTempStatus("Blocked", "Please move!")
- end
- gui.clearTempStatus()
- mover.subLocationStep()
- --gui.animStep()
- end
- function mover.addLocationStep()
- mover.location[1] = mover.location[1] + mover.vecModX[mover.dir]
- mover.location[3] = mover.location[3] + mover.vecModZ[mover.dir]
- processing.persistenceUpdate()
- end
- function mover.subLocationStep()
- mover.location[1] = mover.location[1] - mover.vecModX[mover.dir]
- mover.location[3] = mover.location[3] - mover.vecModZ[mover.dir]
- processing.persistenceUpdate()
- end
- function mover.moveTo(order,loc,locMod)
- if locMod == nil then locMod = {0,0,0} end
- for i=1,string.len(order),2 do
- axis = order:sub(i,i)
- if axis == "x" then
- mover.moveToX(loc[1]+locMod[1])
- elseif axis == "y" then
- mover.moveToY(loc[2]+locMod[2])
- elseif axis == "z" then
- mover.moveToZ(loc[3]+locMod[3])
- end
- end
- end
- function mover.moveToX(newX)
- if location[1] == newX then return end
- mover.turnToX(newX)
- while location[1] ~= newX do
- mover.moveForward()
- end
- end
- function mover.moveToY(newY)
- if location[2] == newY then return end
- while location[2] ~= newY do
- if newY < location[2] then
- mover.moveDown()
- elseif newY > location[2] then
- mover.moveUp()
- end
- end
- end
- function mover.faceDir(newDir)
- if newDir == dir then return end
- if (mover.dir%4)+1 == newDir then
- mover.turnRight()
- else
- while mover.dir ~= newDir do
- mover.turnLeft()
- end
- end
- end
- function mover.faceOriginNorth()
- mover.faceDir(1)
- end
- function mover.faceOriginEast()
- mover.faceDir(2)
- end
- function mover.faceOriginSouth()
- mover.faceDir(3)
- end
- function mover.faceOriginWest()
- mover.faceDir(4)
- end
- function mover.moveToZ(newZ)
- if location[3] == newZ then return end
- mover.turnToZ(newZ)
- while location[3] ~= newZ do
- mover.moveForward()
- end
- end
- function mover.turnToX(newX)
- if newX < location[1] then
- mover.faceOriginWest()
- elseif newX > location[1] then
- mover.faceOriginEast()
- end
- end
- function mover.turnToZ(newZ)
- if newZ < location[3] then
- mover.faceOriginNorth()
- elseif newZ > location[3] then
- mover.faceOriginSouth()
- end
- end
- function mover.getMapLoc(trueLoc)
- return {math.abs(trueLoc[1]-schemOrigin[1]),trueLoc[2]+1,math.abs(trueLoc[3]-schemOrigin[3])}
- end
- function mover.getLocCopy()
- return utils.getListCopy(mover.location)
- end
- function mover.getLocationString()
- return mover.location[1].."X,"..mover.location[2].."Y,"..mover.location[3].."Z"
- end
- processing = {}
- processing.keyMap = {}
- processing.lastTick = -1
- processing.dllDir = "nbtdll/"
- processing.pstDir = "nbtpst/"
- processing.tickLock = false
- processing.persistent = false
- processing.persistencyBaseFile = "base.pst"
- processing.persistencyTempFile = "temp.pst"
- function processing.init()
- processing.execDir = utils.getBasePath(shell.getRunningProgram())
- processing.loadDLLs()
- end
- function processing.startup()
- gui.setState(guiStates.loadingFile)
- gui.callEvent("blockidloadstart")
- config.LoadBlockNames()
- gui.callEvent("blockidloadend")
- gui.callEvent("nbtloadstart")
- nbtReader.beginRead(processing.fileName)
- --gui.callEvent("nbtloadend")
- end
- function processing.doConfig()
- if processing.cont == true then
- else
- mover.location = {0,0,0}
- mover.faceDir = 1
- gui.setState(guiStates.choosePosition)
- gui.state.initCustom({"Start Position","Slot 1", "Slot 2" })
- --gui.callEvent("desc","Starting Position")
- end
- end
- function processing.loadDLLs()
- local fList = fs.list(processing.execDir..processing.dllDir)
- for k,v in pairs(fList) do
- dofile(processing.execDir..processing.dllDir..v)
- end
- end
- function processing.exit()
- term.clear()
- term.setCursorPos(1,1)
- os.queueEvent("terminate")
- end
- function processing.forceTick()
- if processing.tickLock then os.queueEvent("tick") end
- end
- function processing.positionSetRequestDone(request,pos)
- for k,v in pairs(request) do
- if v == "Start Position" then
- builder.startPosition = pos[k]
- elseif string.sub(v,1,5) == "Slot " then
- num = tonumber( string.sub(v,6) )
- builder.refillPositions[num] = pos[k]
- end
- end
- processing.establishPersistence()
- end
- function processing.establishPersistence()
- processing.saveBaseFile()
- processing.persistent = true
- processing.persistenceUpdate()
- end
- function processing.saveBaseFile()
- file = fs.open(processing.execDir..processing.pstDir..processing.persistencyBaseFile,"w")
- file.writeLine(processing.fileName)
- file.writeLine(utils.getLocationString(builder.startPosition))
- for k,v in pairs(builder.refillPositions) do
- file.writeLine(utils.getLocationString(v))
- end
- file.close()
- end
- function processing.persistenceUpdate()
- if processing.persistent == false then return end
- file = fs.open(processing.execDir..processing.pstDir..processing.persistencyTempFile,"w")
- file.writeLine(utils.getLocationString(mover.location))
- file.writeLine(mover.dir)
- file.close()
- --SAVE
- end
- --[[
- function processing.interruptTick()
- if os.clock() < processing.lastTick + tickLength then return false end
- os.queueEvent("--TT")
- gui.animStep()
- while true do
- local ev,p1,p2,p3 = os.pullEvent()
- if ev == "--TT" then
- break
- elseif ev == "key" then
- processing.internalKeyEvent(p1)
- end
- end
- --gui.Tick()
- return true
- end--]]
- function processing.internalKeyEvent(key,char)
- gui.keyPress(key,char)
- end
- function processing.checkTemp()
- return (fs.exists(processing.execDir..processing.pstDir..processing.persistencyBaseFile) and fs.exists(processing.execdir..processing.pstDir..processing.persistencyTempFile))
- end
- nbtReader = {}
- nbtReader.utils = {}
- nbtReader.blockData = {}
- nbtReader.blacklistedBlocks = {}
- nbtReader.index = 1
- nbtReader.active = false
- function nbtReader.beginRead(fileName)
- local file = fs.open(processing.execDir..fileName,"rb")
- nbtReader.schem = ""
- local inp = file.read()
- while inp ~= nil do
- nbtReader.schem = nbtReader.schem .. string.char(inp)
- inp = file.read()
- end
- file.close()
- nbtType = nbtReader.utils.readType()
- name = nbtReader.utils.readName()
- nbtReader.active = true
- processing.forceTick()
- end
- function nbtReader.done()
- nbtReader.active = false
- gui.callEvent("nbtloadend")
- processing.doConfig()
- end
- function nbtReader.tick()
- if nbtReader.utils.readByte() ~= nil then
- nbtType = nbtReader.utils.readType()
- if nbtType == 0 then return true end
- name = nbtReader.utils.readName()
- if debugOn then
- term.clear()
- term.setCursorPos(1,1)
- end
- printDebug("Byte: " .. nbtReader.utils.readByte())
- printDebug("Type read: " .. nbtType )
- printDebug("Name read: " .. name )
- if nbtType == 2 then
- value = nbtReader.utils.readShort()
- if name == "Height" then
- height = value
- elseif name == "Width" then
- width = value
- elseif name == "Length" then
- length = value
- end
- printDebug("Read type 2 (short")
- printDebug("value: " ..value)
- elseif nbtType == 7 then
- printDebug("Read type 7 (array)")
- arrayLength = nbtReader.utils.readSignedInt()
- printDebug("Length: " .. arrayLength)
- if name == "Blocks" then
- -- print("blocks")
- for y=1,height,1 do
- nbtReader.blockData[y]={}
- for z=1,length,1 do
- nbtReader.blockData[y][z]={}
- for x=1,width,1 do
- -- print(y.."/"..z.."/"..x.." = ".. readByte())
- --read()
- if nbtReader.blacklistedBlocks[nbtReader.utils.readByte()] == nil then
- nbtReader.blockData[y][z][x] = nbtReader.utils.readByte()
- else
- nbtReader.blockData[y][z][x] = 0
- end
- nbtReader.index = nbtReader.index + 1
- end
- end
- end
- else
- printDebug("Unsupported array: " .. name .. "\nSkipping full length")
- nbtReader.index = nbtReader.index + arrayLength
- end
- elseif nbtType == 8 then
- -- print("a")
- value = nbtReader.utils.readName()
- --print(value)
- printDebug("Read String: " ..value)
- if name == "Materials" then
- materials = value
- end
- elseif nbtType == 9 then
- --print("L:"..name)
- printDebug("Read List")
- listType = nbtReader.utils.readByte()
- nbtReader.index = nbtReader.index + 1
- --print("T:"..tostring(listType))
- listLength = nbtReader.utils.readSignedInt()
- printDebug("ListLength: " .. listLength)
- printDebug("ListType: " .. listType)
- nbtReader.index = nbtReader.index + listLength
- printDebug("Skipping full length")
- else
- printDebug("ERRROR\nUnknown type. Skipping byte")
- nbtReader.index = nbtReader.index + 1
- end
- printDebug("",true)
- return true
- else
- nbtReader.active = false
- return false
- end
- end
- function nbtReader.utils.readByte()
- --print("Reading byte") read()
- return nbtReader.schem:byte(nbtReader.index)
- end
- function nbtReader.utils.readType()
- printDebug("Reading type",true)
- local b = nbtReader.utils.readByte()
- nbtReader.index = nbtReader.index + 1
- printDebug("TYPE::"..b,false)
- return b
- end
- function nbtReader.utils.readShort()
- printDebug("Reading short",true)
- local b = bit.blshift(nbtReader.utils.readByte(),8)
- nbtReader.index = nbtReader.index + 1
- b = bit.bor(b, nbtReader.utils.readByte())
- nbtReader.index = nbtReader.index + 1
- return b
- end
- function nbtReader.utils.readBytes(length)
- printDebug("Reading bytes",true)
- local b = {}
- for i=1,length,1 do
- b[i]=nbtReader.utils.readByte()
- nbtReader.index = nbtReader.index + 1
- end
- return b
- end
- function nbtReader.utils.readString(length)
- printDebug("Reading string",true)
- local b = ""
- local r = nbtReader.utils.readBytes(length)
- for i,k in ipairs(r) do
- b = b .. string.char(k)
- end
- return b
- end
- function nbtReader.utils.readSignedInt()
- printDebug("Reading signed int",true)
- local r = nbtReader.utils.readByte()
- r = bit.blshift(r,24)
- nbtReader.index = nbtReader.index + 1
- r = bit.bor(r,bit.blshift(nbtReader.utils.readByte(),16))
- nbtReader.index = nbtReader.index + 1
- r = bit.bor(r,bit.blshift(nbtReader.utils.readByte(),8))
- nbtReader.index = nbtReader.index + 1
- r = bit.bor(r,nbtReader.utils.readByte())
- nbtReader.index = nbtReader.index + 1
- return r
- end
- function nbtReader.utils.readName()
- return nbtReader.utils.readString(nbtReader.utils.readShort())
- end
- nbtParser = {}
- function nbtParser.getDistinctBlocks(blockDataList)
- blockIDs = {}
- for y,v in ipairs(blockDataList) do
- for z,v2 in ipairs(v) do
- for x,bID in ipairs(v2) do
- if bID ~= 0 then
- --print(bID)
- if blockIDs[bID] ~= nil then
- blockIDs[bID] = blockIDs[bID] + 1
- else
- blockIDs[bID] = 1
- end
- end
- end
- end
- end
- return blockIDs
- end
- function nbtParser.getBlock(x,y,z)
- return blockData[(y)][schemH-(z-1)][schemW-(x-1)]
- end
- builder = {}
- builder.startPosition = {0,0,0}
- builder.refillPositions = {-1,-1,-1,-1,-1,-1,-1,-1,-1}
- function pError(errorMsg,continue)
- term.setCursorPos(1,1)
- print(errorMsg)
- if not continue then
- error()
- else
- print("Hit enter to continue")
- read()
- end
- end
- function printDebug(msg,readDebug)
- if not debugOn then return end
- print(msg)
- if readDebug~=nil and readDebug then
- read()
- end
- end
- --[[
- LoadBlockNames()
- location = {0,0,0}
- dir = 1
- index = 1
- blockData = {}
- nbtReader.read()
- printDebug("done",true)--]]
- function assignSlots(sx,sy,sz)
- local bAssigned = {}
- slots = {0,0,0,0,0,0,0,0,0}
- bCount = 0
- for y=0,height-1,1 do
- if bCount == 9 then break end
- for x=startPos[1],startPos[1]-schemW+1,-1 do
- if bCount == 9 then break end
- for z=startPos[3],startPos[3]-schemH+1,-1 do
- if bCount == 9 then break end
- local blockLoc = getMapLoc({x,y,z})
- local blockID = getBlock(blockLoc[1],blockLoc[2],blockLoc[3]) --blockData[blockLoc[2]][blockLoc[3]][blockLoc[1]]
- if blockID ~= nil and blockID ~= 0 and bAssigned[blockID] == nil then
- for i=1,9,1 do
- if slots[i] == 0 then
- slots[i] = blockID
- bAssigned[blockID] = true
- bCount = bCount + 1
- break
- end
- end
- end
- end
- end
- end
- end
- function pulseSides()
- local sides = rs.getSides()
- for i,v in pairs(sides) do
- rs.setOutput(v,true)
- end
- sleep(1)
- for i,v in pairs(sides) do
- rs.setOutput(v,false)
- end
- end
- function doRefill(goback)
- tempStat1 = status1
- reportStatus("Refilling",KEEP)
- backPos = getLocCopy()
- backDir = dir
- moveTo("y",getLocCopy(),{0,1,0})
- --moveTo("x>z>y",startPos,{0,1,0})
- for i=1,9,1 do
- if slots[i] ~= 0 then
- if turtle.getItemCount(i) < 64 then
- moveTo("x>z>y",matRefillPos[slots[i]])
- pulseSides()
- moveTo("y",matRefillPos[slots[i]],{0,1,0})
- end
- end
- end
- --moveTo("x>z>y",startPos)
- if goback then
- moveTo("y",getLocCopy(),{0,backPos[2]+1,0})
- moveTo("z>x>y",backPos)
- faceDir(backDir)
- else
- moveTo("x>z>y",startPos)
- end
- reportStatus(tempStat1,"KEEP")
- end
- function subTab(tabA,tabB)
- return {tabA[1]-tabB[1],tabA[2]-tabB[2],tabA[3]-tabB[3]}
- end
- function reportStatus(nStat1,nStat2)
- if nStat1 == nil then nStat1 = "" end
- if nStat2 == nil then nStat2 = "" end
- if nStat1 ~= "KEEP" then
- status1 = nStat1
- clearLine(5)
- term.setCursorPos(2,5)
- write("Status: ".. status1)
- end
- if nStat2 ~= "KEEP" then
- status2 = nStat2
- clearLine(6)
- term.setCursorPos(2,6)
- write(status2)
- end
- end
- function buildRow(z,y)
- reportStatus("Row " .. z .. " / " .. y, "" )
- for z=1,schemH,1 do
- --local cLoc = subTab(getLocCopy(),startPos)
- cLoc = getLocCopy()
- cLoc[2] = cLoc[2] - 1
- --print(cLoc[1].."/"..cLoc[2].."/"..cLoc[3])
- local mapLoc = getMapLoc(cLoc)
- --print(mapLoc[1].."/"..mapLoc[2].."/"..mapLoc[3])
- local blockID = getBlock(mapLoc[1],mapLoc[2],mapLoc[3])
- reportStatus("KEEP",getBlockName(blockID))
- found=-1
- foundEmpty =-1
- if blockID ~= 0 then
- while found == -1 do
- for i=1,9,1 do
- if slots[i] == blockID then
- if turtle.getItemCount(i) > 0 then
- found = i
- break
- else
- foundEmpty = i
- end
- end
- end
- if found == -1 then
- if foundEmpty ~= -1 then
- tempStat1 = status1
- tempStat2 = status2
- reportStatus("Refilling:",getBlockName(blockID))
- doRefill(true)
- reportStatus(tempStat1,tempStat2)
- end
- end
- end
- if found == -1 then
- turtle.select(foundEmpty)
- else
- turtle.select(found)
- end
- turtle.placeDown()
- else
- end
- gui.animStep()
- placedBlocks = placedBlocks + 1
- printProgressBar(placedBlocks,length*width*height,10,true)
- moveForward()
- end
- end
- --[[
- blockList = getDistinctBlocks(blockData)
- uniqueBlockCount = 0
- for i,v in pairs(blockList) do
- if blockList[i] ~= nil then
- uniqueBlockCount = uniqueBlockCount + 1
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- printBorder()
- printGUIPositionStart()
- startPos = locationSetRequest(9)
- buildToLeft = true
- term.clear()
- term.setCursorPos(1,1)
- printBorder()
- printGUIBuildDirection()
- while true do
- local ev,p1 = os.pullEvent()
- if ev == "key" then
- if p1 == 203 then
- buildToLeft = true
- printGUIBuildDirectionRect()
- --left
- elseif p1 == 205 then
- buildToLeft = false
- printGUIBuildDirectionRect()
- --right
- elseif p1 == 28 then
- schemH = length
- schemW = width
- schemWAxis = "x"
- schemHAxis = "z"
- schemOrigin = getListCopy(startPos)
- schemOrigin[3] = schemOrigin[3] - schemH
- if buildToLeft then
- schemOrigin[1] = schemOrigin[1] - schemW
- end
- break
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- printBorder()
- printCenteredText(3,"..Calculating slots..")
- assignSlots()
- matRefillPos = {}
- local slotRefillCounter = 1
- for i,v in pairs(blockList) do
- printGUIPositionRefill(i,slotRefillCounter)
- matRefillPos[i] = locationSetRequest(9)
- slotRefillCounter = slotRefillCounter + 1
- end
- term.clear()
- term.setCursorPos(1,1)
- printBorder()
- printCenteredText(3,"Press <Enter> to start")
- while true do
- local ev,p1 = os.pullEvent()
- if ev == "key" then
- if p1 == 28 then
- break
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- printBorder()
- term.clear()
- term.setCursorPos(1,1)
- printBorder()
- printCenteredText(3,"Building")
- term.setCursorPos(2,5)
- term.write("Status")
- term.setCursorPos(2,9)
- term.write("Progress")
- placedBlocks = 0
- doRefill(false)
- moveTo("y>x>z",startPos,{0,1,0})
- faceOriginNorth()
- up = true
- printCenteredText(3,"Ready to Build")
- printCenteredText(4,"<Hit Enter Key>")
- read()
- for y=1,height,1 do
- for x=1,schemW,1 do
- buildRow(x,y)
- up = not up
- if buildToLeft then
- faceOriginWest()
- else
- faceOriginEast()
- end
- moveForward()
- if up then
- faceOriginNorth()
- else
- faceOriginSouth()
- end
- moveForward()
- end
- up = true
- moveTo("x>z>y",startPos,{0,y+1,0})
- faceOriginNorth()
- end
- term.clear()
- term.setCursorPos(1,1)
- --]]
- ----
- term.clear()
- processing.init()
- gui.Drawing.printBorder()
- local tArgs = { ... }
- processing.fileName = tArgs[1]
- processing.cont = false
- if processing.fileName == nil then
- if processing.checkTemp() then
- processing.fileName = processing.getTempName()
- procesing.cont = true
- end
- end
- gui.setState(guiStates.startup)
- while true do
- local startTick = os.clock()
- if nbtReader.active then
- if not nbtReader.tick() then
- nbtReader.done()
- end
- end
- gui.tick()
- --if mover.enabled then
- -- mover.tick();
- --end
- if nbtReader.active == true then
- processing.tickLock = false
- if startTick + tickLength > os.clock() then
- os.startTimer(startTick+tickLength - os.clock())
- else
- --if mover enabled
- os.queueEvent("tick")
- end
- else
- processing.tickLock = true
- end
- while true do
- local ev,p1 = os.pullEvent()
- if ev == "timer" then
- os.queueEvent("tick")
- elseif ev == "tick" then
- break
- elseif ev == "key" then
- processing.internalKeyEvent(p1,nil)
- elseif ev == "char" then
- processing.internalKeyEvent(nil,p1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment