User File #20225968871960280

Upload All User Files

#20225968871960280 (unlisted) -

AutoInput.lua
32 downloads
Uploaded 1/19/2015 8:44 PM by TASeditor (see all 188)
Xinput = {};
Yinput = {};

Window = forms.newform(200, 100, "Auto Input");
forms.label(Window, "[0; 65535]", 10, 5);
Text = forms.textbox(Window, "4000", 100, 12, "", 10, 30);

savestate.saveslot(0);

X = 0; Y = 127;

rf = true; lf = true;

function RotateRight()

	--console.log("Rotate right");
	
	if rf == true
	then X = X + 1;
		 if X >= 127
		 then rf = false;
			  df = true;
			  lf = false;
			  uf = false;
			  X = 127;
		 end;
	elseif df == true
		then Y = Y - 1;
			if Y <= -128
			then df = false;
				 lf = true;
				 uf = false;
				 rf = false;
				 Y = -128;
			end;
		elseif lf == true
			then X = X - 1;
				if X <= -128
				then lf = false;
					 uf = true;
					 rf = false;
					 df = false;
					 X = -128;
				end;
			elseif uf == true
				then Y = Y + 1;
					if Y >= 127
					then uf = false;
						 rf = true;
						 df = false;
						 lf = false;
						 Y = 127;
					end;
				end;
		
	savestate.loadslot(0);

end;

function RotateLeft()

	--console.log("Rotate left");

	if lf == true
	then X = X - 1;
		 if X <= -128
		 then lf = false;
			  df = true;
			  rf = false;
			  uf = false;
			  X = -128;
		 end;
	elseif df == true
		then Y = Y - 1;
			if Y <= -128
			then df = false;
				 rf = true;
				 uf = false;
				 lf = false;
				 Y = -128;
			end;
		elseif rf == true
			then X = X + 1;
				if X >= 127
				then rf = false;
					 uf = true;
					 lf = false;
					 df = false;
					 X = 127;
				end;
			elseif uf == true
				then Y = Y + 1;
					if Y >= 127
					then uf = false;
						 lf = true;
						 df = false;
						 rf = false;
						 Y = 127;
					end;
				end;
				
	savestate.loadslot(0);

end;

while true do

	Angle = memory.read_u16_be(0x33B194);
	AngleGet = forms.gettext(Text);
	
	Xinput["P1 X Axis"] = X;
	Yinput["P1 Y Axis"] = Y;
	joypad.setanalog(Xinput);
	joypad.setanalog(Yinput);
	
	--console.log(X..", "..Y);
	
	if Angle - AngleGet > 50
	then RotateRight();
	elseif Angle - AngleGet < -50
		then RotateLeft();	
		else savestate.saveslot(0);
	end;
	
	XCoordAngle = math.cos(Angle*math.pi/32768)*75;
	YCoordAngle = math.sin(Angle*math.pi/32768)*75;	
	gui.drawLine(230, 90, 230+XCoordAngle, 90-YCoordAngle, 0xFF000000);
	
	
	--console.log( joypad.getimmediate() )
	
	gui.text(480, 2, AngleGet);
	gui.text(480, 17, Angle);
	
	--console.log("----");
	emu.frameadvance();
end