Guest User

Nightmare on Elm Street Lua - goofydylan8

a guest
Jul 10th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 KB | None | 0 0
  1. --Nightmare on Elm Street 4-Player
  2. --July 10, 2012
  3. --goofydylan8
  4.  
  5. function draw()
  6.  
  7.     ---- Get Player 1 relavent details
  8.     -- X-Position. Pixel value and a subpixel representation rounded down to 3 decimal places.
  9.     -- Y-Position. Pixel Value
  10.     -- X-Velocity. Pixel value and a subpixel representation rounded down to 3 decimal places.
  11.     -- Ability to jump? 0 if able to jump, otherwise not. If function used to change to Y and N representations
  12.     X1Pos = memory.readbyte(0x40B)
  13.     X1Sub = memory.readbyte(0x3F4)
  14.     X1 = X1Pos+math.floor(X1Sub/.256)/1000
  15.    
  16.     V1X = memory.readbyte(0x450)
  17.     V1Sub = memory.readbyte(0x439)
  18.     V1 = V1X+math.floor(V1Sub/.256)/1000
  19.    
  20.     Y1 = memory.readbyte(0x47E)
  21.    
  22.     J1 = memory.readbyte(0x57B)
  23.    
  24.     if J1 == 0 then
  25.         Ju1 = "Y"
  26.     else
  27.         Ju1 = "N"
  28.     end
  29.  
  30.     ---- Get Player 2 relavent details
  31.     -- Same as Player 1
  32.     X2Pos = memory.readbyte(0x40C)
  33.     X2Sub = memory.readbyte(0x3F5)
  34.     X2 = X2Pos+math.floor(X2Sub/.256)/1000
  35.    
  36.     V2X = memory.readbyte(0x451)
  37.     V2Sub = memory.readbyte(0x43A)
  38.     V2 = V2X+math.floor(V2Sub/.256)/1000
  39.    
  40.     Y2 = memory.readbyte(0x47F)
  41.    
  42.     J2 = memory.readbyte(0x57C)
  43.    
  44.     if J2 == 0 then
  45.         Ju2 = "Y"
  46.     else
  47.         Ju2 = "N"
  48.     end
  49.  
  50.     ---- Get Player 3 relavent details
  51.     -- Same as Player 1
  52.     X3Pos = memory.readbyte(0x40D)
  53.     X3Sub = memory.readbyte(0x3F6)
  54.     X3 = X3Pos+math.floor(X3Sub/.256)/1000
  55.    
  56.     V3X = memory.readbyte(0x452)
  57.     V3Sub = memory.readbyte(0x43B)
  58.     V3 = V3X+math.floor(V3Sub/.256)/1000
  59.    
  60.     Y3 = memory.readbyte(0x480)
  61.    
  62.     J3 = memory.readbyte(0x57D)
  63.    
  64.     if J3 == 0 then
  65.         Ju3 = "Y"
  66.     else
  67.         Ju3 = "N"
  68.     end
  69.  
  70.     ---- Get Player 4 relavent details
  71.     -- Same as Player 1
  72.     X4Pos = memory.readbyte(0x40E)
  73.     X4Sub = memory.readbyte(0x3F7)
  74.     X4 = X4Pos+math.floor(X4Sub/.256)/1000
  75.    
  76.     V4X = memory.readbyte(0x453)
  77.     V4Sub = memory.readbyte(0x43C)
  78.     V4 = V4X+math.floor(V4Sub/.256)/1000
  79.    
  80.     Y4 = memory.readbyte(0x481)
  81.    
  82.     J4 = memory.readbyte(0x57E)
  83.    
  84.     if J4 == 0 then
  85.         Ju4 = "Y"
  86.     else
  87.         Ju4 = "N"
  88.     end
  89.  
  90.     --Get enemy HP values, Stolen from adelikat's 2009 "Nightmare on Elm Street 4-Player TAS, lua script."
  91.     HP1 = memory.readbyte(0x0113);
  92.     HP2 = memory.readbyte(0x0114);
  93.     if ( (HP1 > 0 and HP1 < 255) or (HP2 > 0 and HP2 < 255) ) then
  94.     gui.text(200,24,"HP:"..HP1..","..HP2);
  95.     end
  96.    
  97.  
  98.     -- Get screen position
  99.     Sx = memory.readbyte(0x0E8);
  100.    
  101.     -- Get the movable platform Y position.
  102.     P = memory.readbyte(0x486);
  103.    
  104.     -- Displays all of the relavent data
  105.    
  106.     gui.text(1, 8, "X1:"..X1.."\nX2:"..X2.."\nX3:"..X3.."\nX4:"..X4)
  107.     gui.text(57,8, "Y1:"..Y1.."\nY2:"..Y2.."\nY3:"..Y3.."\nY4:"..Y4)
  108.     gui.text(93,8, "V1:"..V1.."\nV2:"..V2.."\nV3:"..V3.."\nV4:"..V4)
  109.     gui.text(139,8, "J1:"..Ju1.."\nJ2:"..Ju2.."\nJ3:"..Ju3.."\nJ4:"..Ju4)
  110.     gui.text(200,8, "Sx:"..Sx.."\nPy:"..P)
  111.    
  112.  
  113.  
  114. end
  115.  
  116. emu.registerafter(draw);
Advertisement
Add Comment
Please, Sign In to add comment