Skip to content

Instantly share code, notes, and snippets.

@nathan130200
Last active December 3, 2020 01:42
Show Gist options
  • Save nathan130200/3d5869678b84ce8e53b921d9735a4283 to your computer and use it in GitHub Desktop.
Save nathan130200/3d5869678b84ce8e53b921d9735a4283 to your computer and use it in GitHub Desktop.
Overwatch - Basic elapsed time clock for workshop.

Global Variables

clockData (index: 0) an array that will filled with clock data:

  • clockData[0]: hours
  • clockData[1]: minutes
  • clockData[2]: seconds

Tools

Every time will loop and update clock, incrementing values. If you need to detect clock updates you can make an copy of clockData then compare each value.

variables {
global:
0: clockData
}
rule ("[CLOCK] Global Setup") {
event {
Ongoing - Global;
}
actions {
Set Global Variable(clockData, Array(0, 0, 0));
If(Workshop Setting Toggle(Custom String("Clock", Null, Null, Null), Custom String("Disable inspector recording", Null, Null, Null), False, 1));
Disable Inspector Recording;
End;
Create HUD Text(All Players(All Teams), Custom String("{0}:{1}:{2}", If-Then-Else(Compare(First Of(Global.clockData), <=, 9), Custom String("0{0}", First Of(Global.clockData), Null, Null), First Of(Global.clockData)), If-Then-Else(Compare(Value In Array(Global.clockData, 1), <=, 9), Custom String("0{0}", Value In Array(Global.clockData, 1), Null, Null), Value In Array(Global.clockData, 1)), If-Then-Else(Compare(Value In Array(Global.clockData, 2), <=, 9), Custom String("0{0}", Value In Array(Global.clockData, 2), Null, Null), Value In Array(Global.clockData, 2))), Null, Null, Top, 1, Color(White), Null, Null, Visible To and String, Default Visibility);
}
}
rule ("[CLOCK] Update") {
event {
Ongoing - Global;
}
actions {
If(Compare(Value In Array(Global.clockData, 2), ==, 59));
Set Global Variable At Index(clockData, 2, 0);
Modify Global Variable At Index(clockData, 1, Add, 1);
Else;
Modify Global Variable At Index(clockData, 2, Add, 1);
End;
If(Compare(Value In Array(Global.clockData, 1), ==, 60));
Set Global Variable At Index(clockData, 1, 0);
Modify Global Variable At Index(clockData, 0, Add, 1);
End;
Wait(1, Ignore Condition);
Loop;
}
}
rule ("[CLOCK] Player Setup") {
event {
Ongoing - Each Player;
All;
All;
}
actions {
If(Workshop Setting Toggle(Custom String("Clock", Null, Null, Null), Custom String("Disable gamemode hud", Null, Null, Null), True, 0));
Disable Game Mode HUD(Event Player);
}
}
globalvar clockData
#!define formatNumber(n) "0{0}".format(n) if n <= 9 else n
#!define rawTime formatNumber(clockData[0]), formatNumber(clockData[1]), formatNumber(clockData[2])
rule "[CLOCK] Global Setup":
@Event global
clockData = [0, 0, 0]
if createWorkshopSetting(bool, "Clock", "Disable inspector recording", false, 1):
disableInspector()
hudHeader(getAllPlayers(), "{0}:{1}:{2}".format(rawTime),
HudPosition.TOP, 1, Color.WHITE, HudReeval.VISIBILITY_AND_STRING, SpecVisibility.DEFAULT)
rule "[CLOCK] Update":
@Event global
if clockData[2] == 59:
clockData[2] = 0
clockData[1] += 1
else:
clockData[2] += 1
if clockData[1] == 60:
clockData[1] = 0
clockData[0] += 1
wait(1)
goto RULE_START
rule "[CLOCK] Player Setup":
@Event eachPlayer
if createWorkshopSetting(bool, "Clock", "Disable gamemode hud", true, 0):
eventPlayer.disableGamemodeHud()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment