User File #19485580542599690

Upload All User Files

#19485580542599690 - Kage lua HUD

Kage.lua
1122 downloads
Uploaded 12/17/2014 12:29 PM by TASeditor (see all 188)
toggle_disp = {};
display = true;

Draw=function()

-- Player 1 RAM Addresses:

	XPos1 = memory.readbyte(0x0610);
	XPos2nd1 = memory.readbyte(0x0620);
	
	XSpd1 = memory.readbyte(0x06C2);
	XDir1 = memory.readbyte(0x06B1);
	
	
	YPos1 = memory.readbyte(0x0630);
	YPos2nd1 = memory.readbyte(0x0640);
	
	YDir1 = memory.readbyte(0x06C0);
	if YDir1 == 255
	then YSpd1 = memory.readbytesigned(0x06B0);
	end;
	if YDir1 == 0
	then YSpd1 = memory.readbyte(0x06B0);
	end;

-- Player 2 RAM Addresses:

	XPos2 = memory.readbyte(0x0614);
	XPos2nd2 = memory.readbyte(0x0624);
	
	XSpd2 = memory.readbyte(0x06C6);
	XDir2 = memory.readbyte(0x06B5);
	
	
	YPos2 = memory.readbyte(0x0634);
	YPos2nd2 = memory.readbyte(0x0644);
	
	YDir2 = memory.readbyte(0x06C4);
	if YDir2 == 255
	then YSpd2 = memory.readbytesigned(0x06B4);
	end;
	if YDir2 == 0
	then YSpd2 = memory.readbyte(0x06B4);
	end;
	
-----------------------------------------

-- Player 1 Calc:

	XPosition1 = XPos2nd1*256 + XPos1;
	YPosition1 = YPos2nd1*256 + YPos1;
	
	if XDir1 == 64 or 192
	then XSpeed1 = XSpd1;
	end;
	if XDir1 == 128
	then XSpeed1 = -XSpd1;
	end;
	
	if YDir1 == 255
	then YSpeed1 = YSpd1;
	end;
	if YDir1 == 0 
	then if YSpd1 < 128
		 then YSpeed1 = YSpd1
		 else YSpeed1 = 128;
		 end;
	end;

-- Player 2 Calc:

	XPosition2 = XPos2nd2*256 + XPos2;
	YPosition2 = YPos2nd2*256 + YPos2;
	
	if XDir2 == 64 or 192
	then XSpeed2 = XSpd2;
	elseif XDir2 == 128
		then XSpeed2 = -XSpeed2;
	end;
	
	if YDir2 == 255
	then YSpeed2 = YSpd2;
	end;
	if YDir2 == 0 
	then if YSpd2 < 128
		 then YSpeed2 = YSpd2
		 else YSpeed2 = 128;
		 end;
	end;
	
	
-----------------------------------------

-- Enemy Calc and Draw:
	
	toggle_disp = input.get();
	
	-- Press T to deactivate the enemy display
	if toggle_disp.T == true
	then display = false; 
	end;
	-- Press G to activate the enemy display
	if toggle_disp.G == true
	then display = true; 
	end;
	
	
	if display == true
	then
	gui.box(2, 98, 110, 180, "#FFFFFFA0", "white");
	gui.text(24, 100, "X Pos" ,"black", "#F0F0F070");
	gui.text(58, 100, "Y Pos" ,"black", "#F0F0F070");
	gui.text(92, 100, "HP", "black", "#F0F0F070");


	for i = 0, 7, 1 do

		EXPos = memory.readbyte(0x0718+i);
		EXPos2nd = memory.readbyte(0x0728+i);
		
		EYPos = memory.readbyte(0x0738+i);
		EYPos2nd = memory.readbyte(0x0748+i);
		
		EXPosition = EXPos2nd*256 + EXPos;
		EYPosition = EYPos2nd*256 + EYPos;
		
		EHP = memory.readbyte(0x07F8+i);
		
	
		gui.text(4, 110+9*i, "E"..i+1 ..":","black", "#F0F0F070");
		
		gui.text(24, 110+9*i, EXPosition, "black", "#FF000010");
		gui.text(58, 110+9*i, EYPosition, "black", "#00FF0010");
		gui.text(92, 110+9*i, EHP, "black", "#00000010");
	
	end;
end;

-----------------------------------------

-- Player 1 Draw:

	gui.box(42, 10, 248, 54, "#FFFFFFA0", "white");
	gui.text(128,12,"Player 1", "black", "#F0F0F0A0");
	gui.text(44, 22,"X Position: "..XPosition1, "black", "#FF000010");
	gui.text(44, 30,"Y Position: "..YPosition1, "black", "#00FF0010");
	
	
	gui.text(44, 38,"X Speed: "..XSpeed1, "black", "#FF000010");
	gui.box(114, 37, (114+math.abs(XSpeed1*1.5)), 45, "#FF0000A0", "#00000000");
	gui.text(44, 46,"Y Speed: "..YSpeed1, "black", "#00FF0010");
	gui.box(114, 45, (114+math.abs(YSpeed1)), 53, "#00FF00A0", "#00000000");
		
-- Player 2 Draw:

	--[[gui.box(42, 58, 248, 102, "#FFFFFFA0", "white");
	gui.text(128,60,"Player 2", "black", "#F0F0F0A0");
	gui.text(44, 70,"X Position: "..XPosition2, "black", "#FF000010");
	gui.text(44, 78,"Y Position: "..YPosition2, "black", "#00FF0010");
	
	
	gui.text(44, 86,"X Speed: "..XSpeed2, "black", "#FF000010");
	gui.box(114, 85, (114+math.abs(XSpeed2*1.5)), 93, "#FF0000A0", "#00000000");
	gui.text(44, 94,"Y Speed: "..YSpeed2, "black", "#00FF0010");
	gui.box(114, 93, (114+math.abs(YSpeed2)), 101, "#00FF00A0", "#00000000");]]--
	
---------------------------------------
	
	if taseditor.engaged() == true
	then

		if taseditor.markedframe(movie.framecount())==true
		then M_frame = movie.framecount();
		end;


		Marker = taseditor.getmarker(movie.framecount());
		M_Str = taseditor.getnote(Marker);
		
		if M_frame ~= nil
		then Diff = movie.framecount() - M_frame; -- Diff points at the line in the txt-file used for the current frame

			 if M_Str == "1-1 started"
			 then RAMlog = io.open("1-1Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "1-2 started"
			 then RAMlog = io.open("1-2Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "1-3 started"
			 then RAMlog = io.open("1-3Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "1-4 started"
			 then RAMlog = io.open("1-4Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "2-1 started"
			 then RAMlog = io.open("2-1Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "2-2 started"
			 then RAMlog = io.open("2-2Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "2-3 started"
			 then RAMlog = io.open("2-3Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "3-1 started"
			 then RAMlog = io.open("3-1Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "4-1 started"
			 then RAMlog = io.open("4-1Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "4-2 started"
			 then RAMlog = io.open("4-2Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "4-3 started"
			 then RAMlog = io.open("4-3Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "5-1 started"
			 then RAMlog = io.open("5-1Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 elseif M_Str == "5-2 started"
			 then RAMlog = io.open("5-2Log.txt", "r");
				  for i = 0, Diff, 1 do
				  Text = RAMlog:read("*line");
				  end;
				  RAMlog:close();
			 else Text = "";
			 end;

		 	 
		 gui.box(42, 58, 248, 78, "#FFFFFFA0", "white");
		 gui.text(128, 60, "Old TAS", "black", "#F0F0F0A0");
		 if Text ~= nil
		 then gui.text(44,70, Text, "black", "#00000000");
		 else gui.text(44,70, "Error", "black", "#00000000");
		 end;
		 end;

	end;
	
	
end;

gui.register(Draw);