Posted 15 August 2014 - 11:58 PM
Today, I installed OpenPeripherals and some more mods, including Thermal Expansion. I was making a code that showed the energy in the current energy cell. One part of the program is almost the same as the code shown on Direwolf20 ForgeCraft2 S2E25, except only for the peripheral names. There will be another part of the code which will "beautifly" it and so some other things. But when I runned the program, It was calling an error in the line that contained the setZIndex method. I made what I could do to solve this problem. If I took away this method, it would run ok, but I prefer to stick with this method.
The cell is in the back side of the computer and the bridge is in the right side. The code is here:
The cell is in the back side of the computer and the bridge is in the right side. The code is here:
local energy = peripheral.wrap("back")
local bg = peripheral.wrap("right")
bg.clear()
local energyB = bg.addBox(20, 40, 30, 200, 0x000000, 0.9)
energyB.setZIndex(0)
local overlay = bg.addBox(20, y, 30, energyToBar, 0xFF0000, 1)
overlay.setZIndex(1)
local text = bg.addText(25, 250, energyToText, 0xFFFFFF)
while true do
local sEnergy = energy.getEnergyStored("back")
local mEnergy = energy.getMaxEnergyStored("back")
local percentage = sEnergy / mEnergy
local ratio = percentage * 100
text.setText(tostring(math.floor(percentage * 100)).."%")
overlay.setHeight(ratio * 2)
overlay.setY((200 + 40) - energyToBar)
end