Author Topic: E2 - Show Me The Time  (Read 9853 times)

kevinminion

  • Global Moderator
  • Full Member
  • *****
  • Posts: 147
  • Karma: +15/-0
    • View Profile
  • IGN: Kevin Minion
E2 - Show Me The Time
« on: May 24, 2015, 09:58:03 pm »
ADMIN NOTE: This post has been pinned as an example of how to properly share your programs.

Place a EGP v3 HUD  then place this E2 chip.
Wire > Visuals > Screens > EGP v3 - select HUD in the drop down before placing it in the world

Use the Advence Wire Tool to wire the HUD[wirelink] input of the E2 to the [wirelink] of the EGP v3 HUD
Press E (use) on the EGP v3 HUD button to activate it.
As it is, it converts to Eastern Time (USA).
 
Code: [Select]
@name Blox_The_Time
@inputs HUD:wirelink
@outputs
@persist K ScreenHeight ScreenWidth
@trigger
interval(1000) # update every second (1000ms)
if (first() | dupefinished()) {
    ScreenWidth = egpScrW(owner())
    ScreenHeight= egpScrH(owner())
 
    K = 230  # This can be any number 1-300.  If you have other HUD elements, you may need to adjust this
}
TimeHour = time("hour")
TimeMin =  time("min")
TimeSec =  time("sec")
# Convert GMT to EST (12 hour clock)
if (TimeHour < 5) {
    TimeHour = TimeHour + 8
} else {
    TimeHour = TimeHour - 4
}
# Make it look pretty
if (TimeHour < 10) {
    StrHour = "0" + TimeHour
} else {
    StrHour = ""  + TimeHour
}
if (TimeMin < 10) {
    StrMin = "0" + TimeMin
} else {
    StrMin = ""  + TimeMin
}
if (TimeSec < 10) {
    StrSec = "0" + TimeSec   
} else {
    StrSec =  "" + TimeSec
}
# Place the time in the lower left-hand corner
HUD:egpText(K,"Time:  " + StrHour + ":" + StrMin + ":" + StrSec,vec2(10,ScreenHeight - 30))
HUD:egpSize(K,30)

Let me know if you have any questions / suggestions / optimizations!
« Last Edit: November 14, 2016, 08:44:39 pm by bloxgate »