Input, Mappings & Controls

3.1.Examples #

General Example

def jump() // Make player jump with CROSS button
{ 
  SendButton(CROSS, true);	// Presses CROSS
  Sleep(100);			// Wait for RemotePlay to process press
  SendButton(CROSS, false);	// Releases CROSS
} 

def moveForward() //make player move forward for 1 second then stop
{ 
  SendAxis(LEFTSTICKY, -128);	// Left stick forward
  Sleep(1000);			// wait
  SendAxis(LEFTSTICKY, 0);	// Reset left stick Y axis
} 

def turnLeft() //make player turn fully left for 400 ms
{ 
  SendAxis(RIGHTSTICKX, 128); 	// Right stick left
  Sleep(400);			// wait
  SendAxis(RIGHTSTICKX, 0);	// Reset left stick X axis
} 

def aimAndShoot() //make player aim down sights and shoot for 1 second
{ 
  SetTrigger(L2, 255);	// Hold left trigger fully down to aim
  SetTrigger(R2, 255);	// Hold right trigger fully down to shoot
  Send();			// Send trigger updates 
  Sleep(1000);		// Shoot for a bit
  SetTrigger(L2, 0);	// Reset triggers and send
  SetTrigger(R2, 0);
  Send();
} 

def thowGrenade() //Use touchpad to throw grenade (Battlefield 1)
{ 
  Press(TOUCHPAD);		//We need to actually press the touchpad button to throw a grenade
  SendTouch(TOUCH1, 960,  471);	// Press in the centre of pad
  Sleep(100);			// Wait for RemotePlay to process press
  Release(TOUCHPAD);	
  ResetTouchpad();
} 

global example = 0;

def onInit()
{
  example = 1;
}

def onTriggered()
{
  if(example == 1){
   print(to_string(example) + " has been set to 1!");
  }
  while (HotkeyActive())
  {	
    jump(); 	// Jump

    Sleep(1000);	// Wait

    moveForward(); 	// Move forward

    turnLeft();	// Turn left

    aimAndShoot(); 	// Shoot

    thowGrenade() 	// Use touchpad to throw grenade

    Sleep(1000);	// Pause a bit before looping
  }

  ResetState(); //Reset all input when hotkey released
}

def onExit()
{
  example = 0;
}

Sleep on Hotkey Example

def onTriggered()
{
  while(SleepOnHotkey(100)) //Send Circle press every 100ms until hotkey released
  {
    SendButton(CIRCLE, true);
    SendButton(CIRCLE, false);
  }
}

ApplyAxisForce (Anti Recoil) Example

def onTriggered()
{
  ApplyAxisForce(RIGHTSTICKY, 6); //Apply downward force of right stick to compensate recoil

  while (HotkeyActive())
  {  	
    Send();
  }

  RemoveAxisForce(RIGHTSTICKY); //Remove force and update
  Send();
}

Print Example

print(to_string(i) + " is greater than or equal to 5");

Config Swap Example

def onTriggered()
{
  var config = GetConfig();

  switch (config) //Selects a different config depending on the current config
  {
    	case(1) {
    	SetConfig(2);
        	break;
    	}
    	case(3) {
    	SetConfig(4);
        	break;
    	}
    	default {
    		return;
    	}
  }

  while(SleepOnHotkey(10)) {} //Wait until hotkey released to swap back

  SetConfig(config);
}
Help Guide Powered by Documentor
Suggest Edit