Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local files = {
- [ "glasses/others/object.lua" ] = "Object = {}\\n\\nfunction Object:new (...) \\n local class = self\\n local object = { }\\n setmetatable( object , {\\n __index = class; \\n })\\n object.__index = class \\n object:constructor(...)\\n return object\\nend",
- [ "glasses/displayObjects/border.lua" ] = "Border = inherit( DisplayObject )\\n\\nfunction Border:constructor(x,y,width,height,borderWidth,color,opacity)\\n self.super.constructor(self,x,y,width,height,opacity)\\n self.borderWidth = borderWidth or 3\\n self.color = color or 0x000000\\nend\\n\\nfunction Border:draw(glasses)\\n \\n glasses.addBox(self.x,self.y,self.borderWidth,self.height,self.color,self.opacity)\\n glasses.addBox(self.x+self.width - self.borderWidth,self.y,self.borderWidth,self.height,self.color,self.opacity)\\n glasses.addBox(self.x,self.y,self.width,self.borderWidth,self.color,self.opacity)\\n glasses.addBox(self.x,self.y+self.height,self.width,self.borderWidth,self.color,self.opacity)\\n \\nend",
- [ "glasses/displayObjects/displayObject.lua" ] = "DisplayObject = inherit( Object )\\n\\nfunction DisplayObject:constructor(x,y,width,height,opacity) \\n self.x = x\\n self.y = y\\n self.width = width\\n self.height = height\\n self.opacity = opacity or 1\\n self.textFields = {}\\nend\\n\\nfunction DisplayObject:addBorder(border)\\n self.border = border\\nend\\n\\nfunction DisplayObject:draw(glasses)\\n self:drawBorder(glasses)\\n self:drawTextFields(glasses)\\n self:drawTitle(glasses)\\nend\\n\\nfunction DisplayObject:drawTextFields(glasses)\\n for _,field in pairs(self.textFields) do\\n field:draw(glasses)\\n end\\nend\\n\\nfunction DisplayObject:addTextField(field)\\n self.textFields[ #self.textFields + 1 ] = field\\nend\\n\\nfunction DisplayObject:drawTitle(glasses)\\n if self.title == nil then return end\\n self:addText(glasses,self.x+10,self.y+10,self.title,0xffffff)\\nend\\n\\nfunction DisplayObject:addText(glasses,x,y,text,color)\\n glasses.addText(x-1,y,text,0x000000)\\n glasses.addText(x+1,y,text,0x000000)\\n glasses.addText(x,y-1,text,0x000000)\\n glasses.addText(x,y+1,text,0x000000)\\n glasses.addText(x,y,text,color)\\nend\\n\\nfunction DisplayObject:drawBorder(glasses)\\n if self.border ~= nil then\\n self.border:draw(glasses)\\n end\\nend \\n\\nfunction DisplayObject:setTitle(title)\\n self.title = title\\nend\\n\\nfunction DisplayObject:addDataProvider(provider)\\n self.provider = provider\\nend\\n\\nfunction DisplayObject:num2hex(num)\\n local hexstr = '0123456789abcdef'\\n local s = ''\\n while num > 0 do\\n local mod = math.fmod(num, 16)\\n s = string.sub(hexstr, mod+1, mod+1) .. s\\n num = math.floor(num / 16)\\n end\\n if s == '' then s = '00' end\\n if string.len(s) == 1 then\\n s = s .. \"0\"\\n end\\n return s\\nend\\n",
- [ "glasses/others/value.lua" ] = "Value = inherit( Object )\\n\\nfunction Value:constructor(value,min,max) \\n self.value = value\\n self.min = min\\n self.max = max\\nend\\n\\nfunction Value:getValue()\\n return self.value\\nend\\n\\nfunction Value:get()\\n return self.value\\nend\\n\\nfunction Value:getRate()\\n if self.max == nil then return end\\n return self.value / self.max\\nend\\n\\n",
- [ "glasses/dataProviders/enderTankProvider.lua" ] = "EnderTankProvider = inherit( DataProvider )\\n\\nfunction EnderTankProvider:constructor(per,direction) \\n self.data = {}\\n self.direction = direction or \"UP\"\\n self.peripheral = peripheral.wrap(per)\\n self.type = \"TankProvider\"\\nend\\n\\nfunction EnderTankProvider:addPowerPort(per)\\n self.powerPort = peripheral.wrap(per)\\nend\\n\\n\\nfunction EnderTankProvider:update()\\n print(self.peripheral.getTankInfo(\"WEST\"))\\n local tankInfo = self.peripheral.getTankInfo(self.direction)[1]\\n self.data = {}\\n if tankInfo.contents ~= nil then\\n self.data.liquid = tankInfo.contents.rawName\\n self.data.stored = tankInfo.contents.amount\\n self.data.id = tankInfo.contents.name\\n self.data.capacity = tankInfo.capacity\\n self.data.value = self.data.stored / self.data.capacity\\n end\\n if self.powerPort == nil then return end\\n --[[\\n \\n -- apparently the power port on an ender tech tank doesnt work with the getEnergyStored() and getMaxEnergyStored() functions\\n self.data.power = self.powerPort.getEnergyStored()\\n self.data.maxPower = self.powerPort.getMaxEnergyStored()\\n self.data.powerRate = self.data.power / self.data.maxPower\\n ]]\\nend\\n",
- [ "glasses/displayObjects/tankDisplay.lua" ] = "TankDisplay = inherit( DisplayObject )\\n\\nfunction TankDisplay:draw(glasses)\\n if self.provider == nil then return end\\n local data = self.provider:get()\\n glasses.addBox(self.x,self.y,self.width,self.height,0xAAAAAA,self.opacity)\\n if data.id ~= nil then\\n glasses.addLiquid(self.x,self.y + self.height - ( data.value * self.height ),self.width,( data.value * self.height ),data.id)\\n end\\n \\n self.super.draw(self,glasses)\\nend",
- [ "glasses/displayObjects/machineDisplay.lua" ] = "MachineDisplay = inherit( DisplayObject )\\n\\nfunction MachineDisplay:draw(glasses)\\n if self.provider == nil then return end\\n local data = self.provider:get()\\n glasses.addBox(self.x,self.y,self.width,self.height,0xAAAAAA,self.opacity)\\n if data.items ~= nil then\\n local rows = math.floor(( self.height - 20 ) / 19)\\n if rows == 0 then rows = 1 end\\n local itemsPerRow = math.ceil(#data.items / rows)\\n local itemSpacing = (self.width - 45) / itemsPerRow\\n if #data.items < rows * ( (self.width - 60 ) / 19 ) then\\n itemsPerRow = math.floor( (self.width - 60 ) / 19 )\\n itemSpacing = 19\\n end\\n for i=1,rows do\\n for j = 1, itemsPerRow do\\n local itemID = (i-1) * itemsPerRow + j\\n --print(i..\" : \"..itemID)\\n local item = data.items[itemID]\\n if item ~= nil then\\n local x = self.x + 30 + itemSpacing * ( j - 1 )\\n local y = self.y + 0 + itemSpacing * i\\n glasses.addIcon(x,y,item[1].id,item[1].dmg)\\n self:addText(glasses,x,y+10,tostring(math.floor(item[1].qty)),0xffffff)\\n end\\n end\\n end \\n end\\n \\n local even = false\\n for i = 1,self.height,2 do\\n local rate = i / self.height \\n local color \\n if rate < (1 - data.value ) then\\n color = 0x000000\\n if even then\\n color = 0x222222\\n end\\n else\\n color = 0xaa0000\\n if even then\\n color = 0x660000\\n end\\n end\\n even = not even\\n glasses.addBox(self.x,self.y + i, 25,2, color, self.opacity)\\n end\\n \\n self.super.draw(self,glasses)\\nend\\n\\nfunction MachineDisplay:drawTitsle(glasses)\\n if self.title == nil then return end\\n self:addText(glasses,self.x+30,self.y+10,self.title,0xffffff)\\nend",
- [ "glasses/lib.lua" ] = "-- function to create a class with all properties from another class\\nfunction inherit(super)\\n local class = { }\\n class.__index = super\\n class.super = super\\n setmetatable( class , {\\n __index = super; \\n })\\n return class\\nend\\n\\nfunction doFiles()\\n dofile(\"glasses/others/object.lua\")\\n dofile(\"glasses/others/value.lua\")\\n dofile(\"glasses/others/energyStorage.lua\")\\n\\n dofile(\"glasses/dataProviders/dataProvider.lua\")\\n dofile(\"glasses/dataProviders/energyProvider.lua\")\\n dofile(\"glasses/dataProviders/inventoryProvider.lua\")\\n dofile(\"glasses/dataProviders/machineProvider.lua\")\\n dofile(\"glasses/dataProviders/ic2MachineProvider.lua\")\\n dofile(\"glasses/dataProviders/tankProvider.lua\")\\n dofile(\"glasses/dataProviders/enderTankProvider.lua\")\\n\\n\\n \\n dofile(\"glasses/displayObjects/displayCollection.lua\")\\n dofile(\"glasses/displayObjects/displayObject.lua\")\\n dofile(\"glasses/displayObjects/border.lua\")\\n dofile(\"glasses/displayObjects/textField.lua\")\\n dofile(\"glasses/displayObjects/progressBar.lua\")\\n dofile(\"glasses/displayObjects/barGraph.lua\")\\n dofile(\"glasses/displayObjects/inventoryDisplay.lua\")\\n dofile(\"glasses/displayObjects/machineDisplay.lua\")\\n dofile(\"glasses/displayObjects/tankDisplay.lua\")\\n dofile(\"glasses/displayObjects/enderTankDisplay.lua\")\\nend\\n\\n\\nfunction run()\\n doFiles()\\n \\n local collection = DisplayCollection:new(peripheral.find(\"openperipheral_bridge\"))\\n \\n local energyProvider = EnergyProvider:new()\\n for i=0,7 do\\n energyProvider:addCell(EnergyStorage:new(\"powered_tile_\"..i))\\n end\\n \\n local progressBar = ProgressBar:new(700,0,250,100,0.4)\\n progressBar:addBorder(Border:new(700,0,250,100,2))\\n progressBar:addDataProvider(energyProvider)\\n progressBar:setTitle(\"Power level\")\\n progressBar:setDrawType(\"RF\")\\n \\n local field = TextField:new(710,25,\"{powerlevel} RF\")\\n field:addVarReplacement(\"{powerlevel}\",energyProvider,\"get\",\"value\")\\n progressBar:addTextField(field)\\n \\n local barGraph = BarGraph:new(700,110,250,100,0.4)\\n barGraph:addBorder(Border:new(700,110,250,100,2))\\n barGraph:addDataProvider(energyProvider)\\n barGraph:setTitle(\"Power levels per cell\")\\n \\n local invProvider = InventoryProvider:new(\"chest_0\")\\n inventoryDisplay = InventoryDisplay:new(490,0,200,75,0.4)\\n inventoryDisplay:addBorder(Border:new(490,0,200,75,1))\\n inventoryDisplay:addDataProvider(invProvider)\\n inventoryDisplay:setTitle(\"Chest\")\\n \\n local furnaceProvider = MachineProvider:new(\"powered_tile_8\")\\n furnaceDisplay = MachineDisplay:new(580,85,110,50,0.4)\\n furnaceDisplay:addBorder(Border:new(580,85,110,50,1))\\n furnaceDisplay:addDataProvider(furnaceProvider)\\n furnaceDisplay:setTitle(\"Redstone furnace\")\\n \\n local pulverizerProvider = MachineProvider:new(\"powered_tile_9\")\\n pulverizerDisplay = MachineDisplay:new(580,145,110,50,0.4)\\n pulverizerDisplay:addBorder(Border:new(580,145,110,50,1))\\n pulverizerDisplay:addDataProvider(pulverizerProvider)\\n pulverizerDisplay:setTitle(\"Pulverizer\")\\n \\n local smeltFactoryProvider = MachineProvider:new(\"mekanism_machine_0\")\\n smeltFactoryDisplay = MachineDisplay:new(280,0,200,75,0.4)\\n smeltFactoryDisplay:addBorder(Border:new(280,0,200,75,1))\\n smeltFactoryDisplay:addDataProvider(smeltFactoryProvider)\\n smeltFactoryDisplay:setTitle(\"Elite Smelting Factory\")\\n \\n local maceratorProvider = IC2MachineProvider:new(\"macerator_0\")\\n maceratorDisplay = MachineDisplay:new(460,85,110,50,0.4)\\n maceratorDisplay:addBorder(Border:new(460,85,110,50,1))\\n maceratorDisplay:addDataProvider(maceratorProvider)\\n maceratorDisplay:setTitle(\"Macerator\")\\n \\n local tankProvider = TankProvider:new(\"drum_0\")\\n tankDisplay = TankDisplay:new(170,0,100,75,0.4)\\n tankDisplay:addBorder(Border:new(170,0,100,75,1))\\n tankDisplay:addDataProvider(tankProvider)\\n tankDisplay:setTitle(\"Drum\")\\n \\n local drumField = TextField:new(180,20,\"{liquid}\")\\n drumField:addVarReplacement(\"{liquid}\",tankProvider,\"get\",\"liquid\")\\n tankDisplay:addTextField(drumField)\\n \\n local drumLiquidField = TextField:new(180,30,\"{liquid} MB\")\\n drumLiquidField:addVarReplacement(\"{liquid}\",tankProvider,\"get\",\"stored\")\\n tankDisplay:addTextField(drumLiquidField)\\n \\n collection:addDisplayObject(progressBar)\\n collection:addDisplayObject(barGraph)\\n collection:addDisplayObject(inventoryDisplay)\\n collection:addDisplayObject(furnaceDisplay)\\n collection:addDisplayObject(pulverizerDisplay)\\n collection:addDisplayObject(smeltFactoryDisplay)\\n collection:addDisplayObject(maceratorDisplay)\\n collection:addDisplayObject(tankDisplay)\\n \\n while true do\\n collection:draw()\\n sleep(0.1)\\n end\\nend\\nrun()",
- [ "glasses/others/energyStorage.lua" ] = "EnergyStorage = inherit( Object )\\n\\nfunction EnergyStorage:constructor(...) \\n self.peripheral = peripheral.wrap(...)\\nend\\n\\nfunction EnergyStorage:getEnergy(...)\\n return self.peripheral.getEnergyStored(...)\\nend\\n\\nfunction EnergyStorage:getMaxEnergy(...)\\n return self.peripheral.getMaxEnergyStored(...)\\nend\\n\\nfunction EnergyStorage:getEnergyValue()\\n return Value:new(self:getEnergy(),0,self:getMaxEnergy())\\nend",
- [ "glasses/dataProviders/energyProvider.lua" ] = "EnergyProvider = inherit( DataProvider )\\n\\nfunction EnergyProvider:constructor() \\n self.data = {}\\n self.cells = {}\\n self.type = \"EnergyProvider\"\\nend\\n\\nfunction EnergyProvider:addCell(cell)\\n self.cells[#self.cells + 1] = cell\\nend\\n\\nfunction EnergyProvider:getCells()\\n return self.cells\\nend\\n\\nfunction EnergyProvider:getPowerStored()\\n local stored = 0\\n for _,cell in ipairs(self.cells) do\\n stored = stored + cell:getEnergy()\\n end\\n return Value:new(stored,0,self:getMaxPowerStored():getValue())\\nend\\n\\nfunction EnergyProvider:getMaxPowerStored()\\n local max = 0\\n for _,cell in ipairs(self.cells) do\\n max = max + cell:getMaxEnergy()\\n end\\n return Value:new(max)\\nend\\n\\nfunction getLowestPowerRate()\\n local min = 1e309\\n local minMax\\n for _,cell in ipairs(self.cells) do\\n local stored = cell:getEnergy()\\n if stored < min then\\n min = stored\\n minMax = cell:getMaxEnergy()\\n end\\n end\\n return Value:new(min,0,minMax)\\nend\\n\\nfunction EnergyProvider:getFilledRate()\\n return self:getPowerStored() / self:getMaxPowerStored()\\nend\\n\\nfunction EnergyProvider:update()\\n self.data = {}\\n for i,cell in pairs(self.cells) do\\n self.data[i] = cell:getEnergyValue() \\n end\\n self.data.value = self:getPowerStored()\\nend\\n",
- [ "glasses/displayObjects/progressBar.lua" ] = "ProgressBar = inherit( DisplayObject )\\nProgressBar.validTypes = {\\n [\"Default\"] = true,\\n [\"Gradient\"] = true,\\n [\"RF\"] = true,\\n}\\n\\nfunction ProgressBar:constructor(...) \\n self.super.constructor(self,...)\\n self.drawType = \"Default\"\\nend\\n\\nfunction ProgressBar:draw(glasses)\\n if self.provider == nil then return end\\n local rate = self.provider:get().value:getRate()\\n local g = rate * 255\\n local r = 255 - g\\n local color = tonumber(\"0x\" .. self:num2hex(r) .. self:num2hex(g) .. \"00\")\\n glasses.addBox(self.x,self.y,self.width,self.height,0xAAAAAA,self.opacity)\\n glasses.addBox(self.x+10,self.y+10,self.width - 20,self.height - 20,0xBBBBBB,self.opacity)\\n self[\"draw\"..self.drawType](self,glasses,rate,color)\\n self.super.draw(self,glasses)\\nend\\n\\nfunction ProgressBar:drawDefault(glasses,rate,color)\\n glasses.addBox(self.x+10,self.y+10,(self.width - 20) * rate,self.height - 20,color,self.opacity)\\nend\\n\\nfunction ProgressBar:drawGradient(glasses,rate)\\n for i = 1, (self.width - 20) * rate do\\n local colorRate = i / ( self.width - 20 )\\n local g = math.floor(colorRate * 255)\\n local r = math.floor(255 - g)\\n local color = \"0x\" .. self:num2hex(r) .. self:num2hex(g) .. \"00\"\\n glasses.addBox(self.x+10+i,self.y+10,1,self.height - 20,tonumber(color),self.opacity)\\n end\\nend\\n\\nfunction ProgressBar:drawRF(glasses,rate)\\n local even = true\\n for i = 1, (self.width - 20), 4 do\\n local color = 0xaa0000\\n if rate < i / (self.width - 20) then\\n color = 0x000000\\n if even then\\n color = 0x222222\\n end\\n else\\n color = 0xaa0000\\n if even then\\n color = 0x660000\\n end\\n end\\n glasses.addBox(self.x+10+i,self.y+10,4,self.height - 20,color,self.opacity)\\n even = not even\\n end\\nend\\n\\nfunction ProgressBar:setDrawType(drawType)\\n if self.validTypes[drawType] == nil then return end\\n self.drawType = drawType\\nend",
- [ "glasses/dataProviders/tankProvider.lua" ] = "TankProvider = inherit( DataProvider )\\n\\nfunction TankProvider:constructor(per,direction) \\n self.data = {}\\n self.direction = direction or \"UP\"\\n self.peripheral = peripheral.wrap(per)\\n self.type = \"TankProvider\"\\nend\\n\\nfunction TankProvider:update()\\n local tankInfo = self.peripheral.getTankInfo(self.direction)[1]\\n self.data = {}\\n if tankInfo.contents ~= nil then\\n self.data.liquid = tankInfo.contents.rawName\\n self.data.stored = tankInfo.contents.amount\\n self.data.id = tankInfo.contents.name\\n self.data.capacity = tankInfo.capacity\\n self.data.value = self.data.stored / self.data.capacity\\n end\\nend\\n",
- [ "glasses/displayObjects/barGraph.lua" ] = "BarGraph = inherit( DisplayObject )\\n\\n\\nfunction BarGraph:draw(glasses)\\n if self.provider == nil then return end\\n local data = self.provider:get()\\n glasses.addBox(self.x,self.y,self.width,self.height,0xAAAAAA,self.opacity)\\n glasses.addBox(self.x+10,self.y+10,self.width - 20,self.height - 20,0xBBBBBB,self.opacity)\\n \\n local barWidth = (self.width - 30) / (#data + 1)\\n local barSpacing = barWidth + 5\\n for i,dat in ipairs(data) do\\n glasses.addBox(self.x + 10 + ( i - 1 ) * barSpacing,(self.y + self.height - 10) - ( self.height - 20 ) * dat:getRate() , barWidth,( self.height - 20 ) * dat:getRate(), 0x880000, self.opacity )\\n end\\n self.super.draw(self,glasses)\\nend",
- [ "glasses/dataProviders/dataProvider.lua" ] = "DataProvider = inherit( Object )\\n\\nfunction DataProvider:constructor() \\n self.data = {}\\n self.type = \"DataProvider\"\\nend\\n\\nfunction DataProvider:get(key)\\n self:update()\\n if key == nil then\\n return self.data\\n end\\n if self.data[key] == nil then\\n return self[key]\\n end\\n return self.data[key]\\nend\\n\\nfunction DataProvider:set(key,value)\\n self.data[key] = value\\nend\\n\\nfunction DataProvider:update()\\n \\nend",
- [ "glasses/displayObjects/enderTankDisplay.lua" ] = "EnderTankDisplay = inherit( TankDisplay )\\n\\nfunction EnderTankDisplay:draw(glasses)\\n if self.provider == nil then return end\\n local data = self.provider:get()\\n glasses.addBox(self.x,self.y,self.width,self.height,0xAAAAAA,self.opacity)\\n if data.id ~= nil then\\n if data.powerRate == nil then\\n glasses.addLiquid(self.x,self.y + self.height - ( data.value * self.height ),self.width,( data.value * self.height ),data.id)\\n else\\n local even = false\\n for i = 1,self.height,2 do\\n local rate = i / self.height \\n local color \\n if rate < (1 - data.powerRate ) then\\n color = 0x000000\\n if even then\\n color = 0x222222\\n end\\n else\\n color = 0xaa0000\\n if even then\\n color = 0x660000\\n end\\n end\\n even = not even\\n glasses.addBox(self.x,self.y + i, 25,2, color, self.opacity)\\n end\\n glasses.addLiquid(self.x+25,self.y + self.height - ( data.value * self.height ),self.width,( data.value * self.height ),data.id)\\n end\\n end\\n self.super.draw(self,glasses)\\nend",
- [ "glasses/displayObjects/displayCollection.lua" ] = "DisplayCollection = inherit( Object )\\n\\nfunction DisplayCollection:constructor (glasses)\\n if type(glasses) == \"string\" then\\n self.glasses = peripheral.wrap(glasses)\\n else\\n self.glasses = glasses\\n end\\n self.displayObjects = {}\\nend\\n\\nfunction DisplayCollection:addDisplayObject(object)\\n self.displayObjects[ #self.displayObjects + 1 ] = object\\nend\\n\\nfunction DisplayCollection:draw()\\n self.glasses.clear()\\n for i,displayObject in pairs(self.displayObjects) do\\n displayObject:draw(self.glasses)\\n end\\n self.glasses.sync()\\nend\\n\\n",
- [ "glasses/dataProviders/furnaceProvider.lua" ] = "EnergyProvider = inherit( DataProvider )\\n\\nfunction EnergyProvider:constructor() \\n self.data = {}\\n self.cells = {}\\n self.type = \"EnergyProvider\"\\nend\\n\\nfunction EnergyProvider:addCell(cell)\\n self.cells[#self.cells + 1] = cell\\nend\\n\\nfunction EnergyProvider:getCells()\\n return self.cells\\nend\\n\\nfunction EnergyProvider:getPowerStored()\\n local stored = 0\\n for _,cell in ipairs(self.cells) do\\n stored = stored + cell:getEnergy()\\n end\\n return Value:new(stored,0,self:getMaxPowerStored():getValue())\\nend\\n\\nfunction EnergyProvider:getMaxPowerStored()\\n local max = 0\\n for _,cell in ipairs(self.cells) do\\n max = max + cell:getMaxEnergy()\\n end\\n return Value:new(max)\\nend\\n\\nfunction getLowestPowerRate()\\n local min = 1e309\\n local minMax\\n for _,cell in ipairs(self.cells) do\\n local stored = cell:getEnergy()\\n if stored < min then\\n min = stored\\n minMax = cell:getMaxEnergy()\\n end\\n end\\n return Value:new(min,0,minMax)\\nend\\n\\nfunction EnergyProvider:getFilledRate()\\n return self:getPowerStored() / self:getMaxPowerStored()\\nend\\n\\nfunction EnergyProvider:update()\\n self.data = {}\\n for i,cell in pairs(self.cells) do\\n self.data[i] = cell:getEnergyValue() \\n end\\n self.data.value = self:getPowerStored()\\nend\\n",
- [ "glasses/dataProviders/ic2MachineProvider.lua" ] = "IC2MachineProvider = inherit( MachineProvider )\\n\\nfunction IC2MachineProvider:constructor(per) \\n self.data = { items = {}}\\n self.peripheral = peripheral.wrap(per)\\n self.type = \"MachineProvider\"\\nend\\n\\nfunction IC2MachineProvider:update()\\n self.data.items = {}\\n self.data = { items = {}}\\n local stacks = self.peripheral.getAllStacks()\\n for slot,item in pairs(stacks) do\\n local itemData = item.basic()\\n if itemData.qty > 0 then\\n self.data.items[#self.data.items + 1] = { itemData }\\n self.data[#self.data + 1] = itemData.qty\\n end\\n end\\n self.data.value = self.peripheral.getProgress() / 100\\nend\\n",
- [ "glasses/dataProviders/inventoryProvider.lua" ] = "InventoryProvider = inherit( DataProvider )\\n\\nfunction InventoryProvider:constructor(per) \\n self.data = { items = {}}\\n self.peripheral = peripheral.wrap(per)\\n self.type = \"InventoryProvider\"\\nend\\n\\nfunction InventoryProvider:update()\\n self.data.items = {}\\n self.data = { items = {}}\\n local stacks = self.peripheral.getAllStacks()\\n for slot,item in pairs(stacks) do\\n local itemData = item.basic()\\n self.data.items[#self.data.items + 1] = { itemData }\\n self.data[#self.data + 1] = itemData.qty\\n end\\nend\\n",
- [ "glasses/dataProviders/machineProvider.lua" ] = "MachineProvider = inherit( DataProvider )\\n\\nfunction MachineProvider:constructor(per) \\n self.data = { items = {}}\\n self.peripheral = peripheral.wrap(per)\\n self.type = \"MachineProvider\"\\nend\\n\\nfunction MachineProvider:update()\\n self.data.items = {}\\n self.data = { items = {}}\\n local stacks = self.peripheral.getAllStacks()\\n for slot,item in pairs(stacks) do\\n local itemData = item.basic()\\n self.data.items[#self.data.items + 1] = { itemData }\\n self.data[#self.data + 1] = itemData.qty\\n end\\n self.data.value = self.peripheral.getEnergyStored() / self.peripheral.getMaxEnergyStored()\\nend\\n",
- [ "glasses/displayObjects/inventoryDisplay.lua" ] = "InventoryDisplay = inherit( DisplayObject )\\n\\nfunction InventoryDisplay:draw(glasses)\\n if self.provider == nil then return end\\n local data = self.provider:get()\\n glasses.addBox(self.x,self.y,self.width,self.height,0xAAAAAA,self.opacity)\\n glasses.addBox(self.x+10,self.y+10,self.width - 20,self.height - 20,0xBBBBBB,self.opacity)\\n \\n if data.items ~= nil then\\n local rows = math.floor(( self.height - 20 ) / 19)\\n local itemsPerRow = math.ceil(#data.items / rows)\\n local itemSpacing = (self.width - 25) / itemsPerRow\\n if #data.items < rows * ( (self.width - 20 ) / 19 ) then\\n itemsPerRow = math.floor( (self.width - 20 ) / 19 )\\n itemSpacing = 19\\n end\\n for i=1,rows do\\n for j = 1, itemsPerRow do\\n local itemID = (i-1) * itemsPerRow + j\\n --print(i..\" : \"..itemID)\\n local item = data.items[itemID]\\n if item ~= nil then\\n local x = self.x + 10 + itemSpacing * ( j - 1 )\\n local y = self.y + 0 + itemSpacing * i\\n glasses.addIcon(x,y,item[1].id,item[1].dmg)\\n self:addText(glasses,x,y+10,tostring(math.floor(item[1].qty)),0xffffff)\\n end\\n end\\n end \\n end\\n \\n self.super.draw(self,glasses)\\nend",
- [ "glasses/displayObjects/textField.lua" ] = "TextField = inherit( DisplayObject )\\n\\nfunction TextField:constructor(x,y,text,color,opacity)\\n self.text = text\\n self.super.constructor(self,x,y,0,0,opacity)\\n self.borderWidth = borderWidth or 3\\n self.color = color or 0xffffff\\n self.varReplacements = {}\\nend\\n\\nfunction TextField:draw(glasses)\\n local text = self.text\\n for check,replacement in pairs(self.varReplacements) do\\n local replacementValue\\n if replacement.call == nil and replacement.var ~= nil then\\n replacementValue = replacement.object[replacement.var]\\n elseif replacement.call == nil and replacement.var == nil then\\n replacementValue = replacement.object\\n elseif replacement.call ~= nil and replacement.var == nil then\\n replacementValue = replacement.object[call](replacement.object)\\n elseif replacement.call ~= nil and replacement.var ~= nil then\\n replacementValue = replacement.object[replacement.call](replacement.object)[replacement.var]\\n end\\n if type(replacementValue) == \"table\" then\\n if replacementValue.value ~= nil then\\n replacementValue = replacementValue.value\\n end\\n end\\n text = string.gsub(text,check,tostring(replacementValue))\\n end\\n self:addText(glasses,self.x,self.y,text,self.color,self.opacity)\\nend\\n\\nfunction TextField:addVarReplacement(stringCheck,object,call,var)\\n local stringReplacement = {object = object, call = call, var = var, }\\n self.varReplacements[stringCheck] = stringReplacement\\nend\\n",
- }
- for path,text in pairs(files) do
- local file = fs.open(path,"w")
- print("Unpacking "..path)
- file.write(string.gsub(text,"\\n","\n"))
- file.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement