Jump to content




OpenPeripherals problem: can't setZIndex



  • You cannot reply to this topic
4 replies to this topic

#1 Writer

  • Members
  • 34 posts

Posted 15 August 2014 - 10: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:

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


#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 August 2014 - 12:34 AM

Please post your error message that you're getting as this is very useful in us assisting you.

I'm going to go ahead and assume its an attempt to call nil error and this could be due to the OpenPeripheral version you're using, I believe that the latest versions are setZ instead of setZIndex.

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 16 August 2014 - 12:41 AM

You forgot to approve the question post. :P

#4 Writer

  • Members
  • 34 posts

Posted 16 August 2014 - 12:33 PM

I'm getting the error "attempt to call nil". I'm gonna try the setZ.

#5 Writer

  • Members
  • 34 posts

Posted 16 August 2014 - 02:01 PM

Made it. Solve it. Thank you. :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users