User File #1420914191806473

Upload All User Files

#1420914191806473 - Chuck Rock 2 lua script

Chuck Rock 2 - Son of Chuck [W] [!].lua
1232 downloads
Uploaded 9/24/2012 11:20 PM by Truncated (see all 22)
Scroll position, player position, speed, acceleration, player HP, crappy lag detector, River Race speed.
--lua script for gens rerecording+lua: http://code.google.com/p/gens-rerecording/
--purpose: HUD in Chuck Rock 2 - Son of Chuck.
--written by Truncated 2011-05-01.
-- 

local old_yvel = 0
local old_xvel = 0
local rr_pix_old = 0
local rr_sub_old = 0
local rr_diff_old = 0

gui.register( function ()
	
	screen_x = memory.readword(0xFF0B30)
	screen_y = memory.readword(0xFF0B32)
		
	xpos = memory.readword(0xFF0C94) 
	xpos_sub = memory.readbyte(0xFF0C96) 
	xvel_pix = memory.readbytesigned(0xFF0C85)
	xvel_sub = memory.readbyte(0xFF0C86)
	xvel = 256*xvel_pix+xvel_sub 
	xvel_pix = math.abs(xvel_pix)
	
	xvel = memory.readwordsigned(0xFF0C85) 
	xvel_pix = math.abs(xvel / 256)
	xvel_sub = xvel % 256
	
	
	diff_xvel = xvel - old_xvel
	diff_xvel_pix = math.abs(diff_xvel / 256)
	diff_xvel_sub = diff_xvel % 256
	
	old_xvel = xvel
	

	ypos = memory.readword(0xFF0C98) 
	ypos_sub = memory.readbyte(0xFF0C9A) 
	yvel_pix = memory.readbytesigned(0xFF0C89)
	yvel_sub = memory.readbyte(0xFF0C8A)
	yvel = 256*yvel_pix+yvel_sub 
	yvel_pix = math.abs(yvel_pix)
	
	diff_yvel = yvel - old_yvel
	diff_yvel_pix = math.abs(diff_yvel / 256)
	diff_yvel_sub = diff_yvel % 256
	
	old_yvel = yvel
	
	--ridable waves in Wacky Waterfalls
	--wave_x = memory.readword(0xFF53A4)
	--wave_disp = screen_x+wave_x
	--gui.text(150,120, string.format("%d", wave_disp))
	
	--speed in River Race
	rr_pix = memory.readbyte(0xFF0B8B)
	rr_sub = memory.readbyte(0xFF0B8C)
	gui.text(150,120, string.format("%d:%d", rr_pix, rr_sub))
	rr_diff = rr_pix *256 + rr_sub - rr_pix_old*256 - rr_sub_old
	rr_diff_diff = rr_diff - rr_diff_old
	gui.text(150,140, string.format("%d   %d", rr_diff, rr_diff_diff))
	
	rr_diff_old = rr_diff
	rr_pix_old = rr_pix
	rr_sub_old = rr_sub
	
	
	
	gui.text(150, 176, "     x        y", "magenta", "black") 
	
	--screen-position 
	message3 = string.format("scr: %d", screen_x) 
	gui.text(150, 184, message3, "white", "black") 
	message3 = string.format("%d", screen_y) 
	gui.text(206, 184, message3, "white", "black") 
	
	if (old_screen_x == screen_x) and (old_screen_y == screen_y) then
		gui.text(130, 100, "SCREEN LOCK!  SCREEN LOCK!", "red", "black") 
	end
	
	old_screen_x = screen_x
	old_screen_y = screen_y
	
	if (old_xpos == xpos) and (old_xpos_sub == xpos_sub) and
	   (old_ypos == ypos) and (old_ypos_sub == ypos_sub) 
	then
		gui.text(138, 108, "CHAR LOCK!  CHAR LOCK!", "white", "red") 
	end
	
	old_xpos = xpos
	old_xpos_sub = xpos_sub
	old_ypos = ypos
	old_ypos_sub = ypos_sub
	   
	
	--X-position 
	message3 = string.format("pos: %d:%d", xpos, xpos_sub) 
	gui.text(150, 192, message3, "green", "black") 
	
	--X-velocity 
	if xvel < 0 then
		if xvel_sub == 0 then 
			xvel_sub = 256
		end
		message = string.format("vel: -%d:%d", xvel_pix, 256-xvel_sub)
	else
		message = string.format("vel: %d:%d", xvel_pix, xvel_sub)
	end
	gui.text(150, 200, message, "yellow", "black") 

	--X-velocity diff (acceleration)
	if diff_xvel < 0 then
		if diff_xvel_sub == 0 then 
			diff_xvel_sub = 256
		end
		message4 = string.format("acc: -%d:%d", diff_xvel_pix, 256-diff_xvel_sub)
	else
		message4 = string.format("acc: %d:%d", diff_xvel_pix, diff_xvel_sub)
	end
	gui.text(150, 208, message4, "red", "black") 
	
	
	--Y-position 
	message4 = string.format("%d:%d", ypos, ypos_sub) 
	gui.text(206, 192, message4, "green", "black") 

	--Y-velocity 
	if yvel < 0 then
		if yvel_sub == 0 then 
			yvel_sub = 256
		end
		message4 = string.format("-%d:%d", yvel_pix, 256-yvel_sub)
	else
		message4 = string.format("%d:%d", yvel_pix, yvel_sub)
	end
	gui.text(206, 200, message4, "yellow", "black") 
	
	--Y-velocity diff
	if diff_yvel < 0 then
		if diff_yvel_sub == 0 then 
			diff_yvel_sub = 256
		end
		message4 = string.format("-%d:%d", diff_yvel_pix, 256-diff_yvel_sub)
	else
		message4 = string.format("%d:%d", diff_yvel_pix, diff_yvel_sub)
	end
	gui.text(206, 208, message4, "red", "black") 
	
	--HP
	message = string.format("HP: %d", memory.readbyte(0xFF0A85))
	gui.text(260, 200, message, "white", "black")
		
end)