-
Notifications
You must be signed in to change notification settings - Fork 89
Scripting Basics
RECOMMEND: Set your display scaling to 100% when you're working across multiple computers
Create a Class Library project in Visual Studio and add references to PS4MacroAPI.dll
. You also need to add references to System.Drawing
if you plan to use the included image processing libraries, and references to System.Windows.Forms
if your script will include a UI. The main class will be the entry point which needs to be a subclass of ScriptBase
in order to be loaded by PS4 Macro.
Use the following template to get started.
using PS4MacroAPI;
public class Script : ScriptBase
{
/* Constructor */
public Script()
{
Config.Name = "Example Script";
Config.LoopDelay = 800;
}
// Called when the user pressed play
public override void Start()
{
base.Start();
}
// Called every interval set by LoopDelay
public override void Update()
{
base.Update();
}
}
The structure of the abstract class ScriptBase is inspired by Unity. The class comes with many built-in methods that wraps useful functions that a bot/script might need such as pressing buttons (with timing), taking a screenshot, and basic image processing. It is also the entry point for PS4 Macro.
See code examples or the scripting API docs.
The constructor will be invoked only once after the script DLL is loaded from PS4 Macro. Use this for initializing default values especially values in the Config property.
NOTE: If the script includes UI then the main form must be created here and nowhere else.
Start()
will be called every time the user pressed play. The method should contain initialization that needs to occur every time the script is started. The best practice is to initialize variables that has to be reset every playback "session".
Update()
is called every interval that is set by Config.LoopDelay
(in milliseconds). This is the main loop of the script and probably where most of the script's implementations will be called from.