local clockstate = nil function data() return { guiUpdate = function() if not clockstate then -- element for the divider local line = api.gui.comp.Component.new("VerticalLine") -- element for the icon local icon = api.gui.comp.ImageView.new("ui/clock_small.tga") -- element for the time clockstate = api.gui.comp.TextView.new("gameInfo.time.label") -- add elements to ui local gameInfoLayout = api.gui.util.getById("gameInfo"):getLayout() gameInfoLayout:addItem(line) gameInfoLayout:addItem(icon) gameInfoLayout:addItem(clockstate) end --================================================================================================ -- search for new industries local allConstructions = api.res.constructionRep.getAll() print ("allConstructions =",#allConstructions ," /UG_melectro_demo_clock") for i = 0, #allConstructions-1 do if allConstructions[i] == "industry/tools_factory.con" then print ("Construction name =",allConstructions[i] ," /UG_melectro_demo_clock") end end --=============================================================================================== --updates time local time = os.time() if clockstate and time then clockstate:setText(os.date('%H:%M', time)) end end } end