Dessyreqt

DKC2 info script

Jul 13th, 2012
981
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1. runningTimerSpeed = 3
  2.  
  3. --Game-specific RAM addresses
  4. RAM = {
  5.     dwords = {
  6.         inGameFrames = 0x7e00d5,
  7.     },
  8.     bytes = {
  9.         mode = 0x7e0de5,
  10.     }
  11. }
  12.  
  13. --Locations to output text
  14. output = {
  15.     x = 0,
  16.     y = 210,
  17.     yOffset = 0,
  18. }
  19.  
  20. showOptions = {
  21.     time = true,
  22.     levelTime = true,
  23. }
  24.  
  25. whiteBox = false
  26. levelStart = 0
  27. previousMode = 0
  28.  
  29. function CalculateTime(frames)
  30.     local hour = math.floor(frames / 216000)
  31.     local minute = math.floor(frames / 3600 - hour * 60)
  32.     local sec = math.floor(frames / 60 - hour * 3600 - minute * 60)
  33.     local mil = frames - hour * 216000 - minute * 3600 - sec * 60
  34.     mil = math.floor(mil * 100 / 60)
  35.  
  36.     return hour, minute, sec, mil
  37. end
  38.  
  39. function OutputTime(outOffset)
  40.     --set in-game time
  41.     local inGameFrames = memory.readdword(RAM.dwords.inGameFrames)
  42.     local hour, minute, sec, mil = CalculateTime(inGameFrames)
  43.  
  44.     gui.text(output.x, output.y - output.yOffset, "(T) Time: " .. hour .. ":" .. string.format("%02d",minute) .. ":" .. string.format("%02d",sec) .. "." .. string.format("%02d",mil))
  45.     output.yOffset = output.yOffset + 10
  46. end
  47.  
  48. function OutputLevelTime(outOffset)
  49.     --set in-game time
  50.     local inGameFrames = memory.readdword(RAM.dwords.inGameFrames)
  51.     local mode = memory.readbyte(RAM.bytes.mode)
  52.     if mode == 0 and previousMode == 1 then
  53.         levelStart = inGameFrames
  54.     end
  55.     previousMode = mode
  56.     local hour, minute, sec, mil = CalculateTime(inGameFrames - levelStart)
  57.  
  58.     gui.text(output.x, output.y - output.yOffset, "(L) Level Time: " .. hour .. ":" .. string.format("%02d",minute) .. ":" .. string.format("%02d",sec) .. "." .. string.format("%02d",mil))
  59.     output.yOffset = output.yOffset + 10
  60. end
  61.  
  62. --Outputs relevant game information
  63. function OutputGameInfo()
  64.     output.yOffset = 0
  65.    
  66.     if showOptions.time then
  67.         OutputTime()
  68.     end
  69.     if showOptions.levelTime then
  70.         OutputLevelTime()
  71.     end
  72. end
  73.  
  74. --Handles all the hotkey stuff
  75. function HandleKeys()
  76.     keys = input.get()
  77.  
  78.     if press('T') then
  79.         showOptions.time = not showOptions.time
  80.     end
  81.     if press('L') then
  82.         showOptions.levelTime = not showOptions.levelTime
  83.     end
  84.    
  85.     last_keys = keys                                              
  86. end
  87.  
  88. function press(button)
  89.     if keys[button] and not last_keys[button] then
  90.         return true
  91.     end
  92.     return false
  93. end
  94.    
  95. while true do
  96.     OutputGameInfo()
  97.     HandleKeys()
  98.     snes9x.frameadvance()
  99. end
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment