Skip to content

Instantly share code, notes, and snippets.

@Der-Eddy
Created March 27, 2017 18:12
Show Gist options
  • Save Der-Eddy/998134705b4b4cf57388f92facefb93f to your computer and use it in GitHub Desktop.
Save Der-Eddy/998134705b4b4cf57388f92facefb93f to your computer and use it in GitHub Desktop.
OBS Death Counter
import keyboard #https://github.com/boppreh/keyboard
import time
import sys
import os
counter = 0
prefixCounter = 'Death Count:'
file = os.path.join(sys.path[0], 'count.txt')
def addCounter():
global counter
counter += 1
writeCounter()
def decCounter():
global counter
counter -= 1
writeCounter()
def writeCounter():
print(f'{prefixCounter} {counter}')
with open(file, 'w') as f:
f.write(f'{prefixCounter} {counter}')
def kill():
sys.exit(1)
keyboard.add_hotkey(67, addCounter) #F8
keyboard.add_hotkey(68, decCounter) #F9
keyboard.add_hotkey(1, kill) #ESC
writeCounter()
while True:
time.sleep(1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment