Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

SilentCid

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by SilentCid

  1. On 7/14/2019 at 2:08 PM, Molinko said:

    I'm not super familiar with this library so you may have to adjust the code as it is untested.

    
    local GUI = require("GUI")
    local component = require 'component'
    local thread = require 'thread'
    local event = require 'event'
    
    local reactor = component.reactor_chamber
    local currentTemps = reactor.getHeat()
    --------------------------------------------------------------------------------
    
    -- Create new application
    local application = GUI.application()
    
    -- Add panel that fits application
    application:addChild(GUI.panel(1, 1, application.width, application.height, 0x262626))
    -- Add smaller panels
    application:addChild(GUI.panel(4, 2, 23, 4, 0x880000))
    application:addChild(GUI.text(5, 3, 0xFFFFFF, "Current Reactor Temps"))
    
    -- Grab a reference to the text object you need to update
    local gui_temp = GUI.text(5, 5, 0xFFFFFF, currentTemps)
    application:addChild(gui_temp)
    
    -- Create a timer that will run every 3 seconds, forever.
    local tid = event.timer(3, function()
        gui_temp.text = tostring(reactor.getHeat()) -- overwrite the text data
        gui_temp:update() -- notify the app that the state of gui_temp has changed
      end, math.huge)
    
    --------------------------------------------------------------------------------
    
    application:draw(true)
    application:start()
    event.cancel(tid) -- cleanup the timer after application:start returns

     

    Thank you for your help. Didn't seem to want to update that variable. It will get the first reading when you first run the program up but doesn't want to update properly after that. I may have to refer to the library creator on this.

  2. Greetings,

    I'm new to Lua but familiar with some of the basics. I'm using this library for the GUI, but not sure on the proper procedure on updating the items on the screen. I have an adapter attached to an IC2 fluid reactor and want to call reactor.getHeat() to get the latest temps and update this child:

    application:addChild(GUI.text(5, 5, 0xFFFFFF, currentTemps))

    If someone can kindly point me in the right direction I think I can go from there. The rest of my code is pretty basic which I haven't played around much on it.

    local GUI = require("GUI")
    local component = require 'component'
    local reactor = component.reactor_chamber
    local currentTemps = reactor.getHeat()
    --------------------------------------------------------------------------------
    
    -- Create new application
    local application = GUI.application()
    
    -- Add panel that fits application
    application:addChild(GUI.panel(1, 1, application.width, application.height, 0x262626))
    -- Add smaller panels
    application:addChild(GUI.panel(4, 2, 23, 4, 0x880000))
    application:addChild(GUI.text(5, 3, 0xFFFFFF, "Current Reactor Temps"))
    application:addChild(GUI.text(5, 5, 0xFFFFFF, currentTemps))
    
    --------------------------------------------------------------------------------
    
    application:draw(true)
    application:start()
    

     

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.