Open Peripheral HUD

Discussion in 'ComputerCraft Programming' started by fxstriker, Aug 6, 2013.

  1. fxstriker

    fxstriker Good Bye skcraft.

    Joined:
    Jan 14, 2012
    Messages:
    259
    Likes Received:
    35
    Using computer craft Open Peripheral add on i made this cool HUD
    it shows the time in real time (in game time)
    and the power level of the mfsu powering my me system.
    posted the code for anyone interested

    [​IMG]
    Code:
    p = peripheral.wrap("right")
    p.clear()
    function Main()
     while true do
      t = os.time()
      d = (textutils.formatTime(t,false))
      p.clear()
      box = p.addBox(4,30,100.00345,5,0xCD0000,0.5)
      text = p.addText(5,5,d,0xFFFFFF)
      text = p.addText(5,15,"Eu Storage.",0xFFFFFF)
      network = peripheral.wrap("bottom")
      E = network.callRemote("batbox_0","getStored")
      E = E / 10000000*100
      box = p.addBox(4,30,E,5,0x76EE00,1)
      meSystem()
      sleep(1)
     end
    end
     
    function meSystem()
     if meWait == 5 then
     meWait = 0
     totalSpace = network.callRemote("me_crafting_terminal_2","getTotalBytes")
     f = network.callRemote("me_crafting_terminal_2","getFreeBytes")
     f = f / totalSpace*100
     print(freeSpace)
     text = p.addText(5,45,"Me System,",0xFFFFFF)
     box = p.addBox(4,60,100.00345,5,0xCD0000,0.5)
     box = p.addBox(4,60,f,5,0x76EE00,1)
     else
      meWait = meWait + 1
      text = p.addText(5,45,"Me System.",0xFFFFFF)
      box = p.addBox(4,60,100.00345,5,0xCD0000,0.5)
      box = p.addBox(4,60,f,5,0x76EE00,1)
     end
    end
     
    function HUDreload()
     p.clear()
     os.reboot()
    end
     
    while true do
     f = 0
     meWait = 0
     Main()
    end
    Hope you guys like it =p
    ps. yes i realize storage is spelled wrong i fixed it in the code tho
    side note this only works with one mfsu, edits to the code would need to be made for more
     
    freddy362 likes this.
  2. fxstriker

    fxstriker Good Bye skcraft.

    Joined:
    Jan 14, 2012
    Messages:
    259
    Likes Received:
    35
    Updated the original post with updated code that ads an me monitor; The green shows free space left red is used.
    Note: you can see the bars flicker a slight orange, i believe this is a rendering bug and have spent some time on fixing it to no avail.
    [​IMG]
     
    TechMasterAllen likes this.
  3. TitanfallInbound

    TitanfallInbound Dude who knows a lot about mods.

    Joined:
    Jul 24, 2013
    Messages:
    107
    Likes Received:
    3
    Looks great. And useful.
     
    Punkandgoth likes this.
  4. Azimath

    Azimath Master Zepplin Thief

    Joined:
    Jan 22, 2012
    Messages:
    30
    Likes Received:
    6
    Ive wanted to try it. This is a nice example of a good use for the peripheral. Looks like you need more ME storage :eek:.
     
  5. fxstriker

    fxstriker Good Bye skcraft.

    Joined:
    Jan 14, 2012
    Messages:
    259
    Likes Received:
    35

    No the me system works a bit differently green is available space red is used its kind of reversed but i felt that it displayed the information better once you knew how to read it
     
  6. TitanfallInbound

    TitanfallInbound Dude who knows a lot about mods.

    Joined:
    Jul 24, 2013
    Messages:
    107
    Likes Received:
    3
    Oh will it work with an Mfe?
     
  7. fxstriker

    fxstriker Good Bye skcraft.

    Joined:
    Jan 14, 2012
    Messages:
    259
    Likes Received:
    35
    Yes, you would have to edit this (underlined)
    E = E / 10000000*100
    to what ever amount of storage you had
     
  8. Neonbeta

    Neonbeta Person who did stuff and things

    Joined:
    Mar 2, 2012
    Messages:
    2,603
    Likes Received:
    757
    Didn't you leave?
     
  9. hsun324

    hsun324 Programmer, Gamer

    Joined:
    May 14, 2012
    Messages:
    362
    Likes Received:
    90
    I'm sure he still haunts the forums from time to time.
     
  10. Platinum831

    Platinum831 AKA THE ZEKE MAN

    Joined:
    Jan 21, 2012
    Messages:
    51
    Likes Received:
    6
    do u need any thing else to get this to work besides the computer terminal glasses and the terminal glass bridge because it wont work or do i have to change stuff in the code to get it to work