Advertisement
EvilAsh25

dw2_codcounter

Apr 10th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5.  
  6. ;----------------------------------------------------------------------------
  7.  
  8. ;Enter your TXT file path and prefix
  9. filePath = W:\Speedgames\Dragon Warrior 2\deaths.txt
  10. prefix := "COD Counter "
  11.  
  12. StringLen, prefixLen, prefix
  13. FileReadLine, fileRead, %filePath%, 1
  14. StringTrimLeft, deathVar, fileRead, %prefixLen%
  15.  
  16. ;Creates txt file if it doesn't exist.
  17. IfNotExist, %filePath%
  18.     FileAppend, %prefix% 0, %filePath%
  19.  
  20. ;When you press [Hotkey] it will increment and update the counter in the file
  21.     NumpadMult::
  22.         ;Reads counter from the file into the deathVar variable
  23.         FileReadLine, fileRead, %filePath%, 1
  24.         StringTrimLeft, deathVar, fileRead, %prefixLen%
  25.        
  26.         ;Increments and writes to file
  27.         Var := ++deathVar
  28.         FileDelete, %filePath%
  29.         FileAppend, %prefix% %deathVar%, %filePath%
  30.     return
  31.  
  32. ;When you press [Hotkey] it will decrement and update the counter in the file
  33.     NumpadDiv::
  34.         ;Reads counter from the file into the deathVar variable
  35.         FileReadLine, fileRead, %filePath%, 1
  36.         StringTrimLeft, deathVar, fileRead, %prefixLen%
  37.        
  38.         ;Don't decrement if it is 0
  39.         if deathVar = 0
  40.             return
  41.  
  42.         ;Decrements and writes to file
  43.         Var := --deathVar
  44.         FileDelete, %filePath%
  45.         FileAppend, %prefix% %deathVar%, %filePath%
  46.     return
  47.    
  48. ;Reset back to 0 when you press [Hotkey]
  49.     NumpadAdd::
  50.         ;writes to file
  51.         deathVar := 0
  52.         FileDelete, %filePath%
  53.         FileAppend, %prefix% %deathVar%, %filePath%
  54.     return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement