When you add a state, you provide the name of a method or function that will contain the state's implementation code. This method or function must receive 1 parameter that will contain the "mode" passed to it by the PRState framework. Within the body of this method or function, you must check the value of the "mode" parameter and react accordingly. The 3 valid values for "mode" are:
When your implementation function is called with mode equal to PRSTATE_MODE_INIT, you must run any needed setup code and nothing else. Your function is called once with this mode each time the state is set.
When your function is called with mode equal to PRSTATE_MODE_END, you can run any necessary clean up code to prepare for the current state to be switched away. Your function is called once with this mode each time another state is about to be set.
Your function will also be called once every frame with mode equal to PRSTATE_MODE_UPDATE throughout the lifetime of the active state. This is where you would execute the bulk of your state implementation code.
For your convenience, you will find a code snippet inside of a note asset called PRState_Snippet_StateImplementationMethod found in the Implementation group within the PRState group. The snippet contains a template for a method variable all set up to act as a state implementation method. All you need to do is copy and paste the snippet into your object for each state you need to implement, rename the method variable to the one you defined and fill them in with code.
For your convenience, you will find a code snippet inside of a note asset called PRState_Snippet_StateImplementationMethod found in the Implementation group within the PRState group. The snippet contains a template for a method variable all set up to act as a state implementation method. All you need to do is copy and paste the snippet into your object for each state you need to implement, rename the method variable to the one you defined and fill them in with code. Here is the snippet in question:
	MyStateMethod = function(mode) {
    if mode == PRSTATE_MODE_INIT {
        // This code will run when the object has just switched to this state.
        // Write your state initialization code below. Don't remove the exit command.
        exit
    }
    if mode == PRSTATE_MODE_END {
        // This code will run when the object state is just about to switch to another state.
        // Write your state clean-up code below. Don't remove the exit command.
        exit
    }
    // The method's main body will run every frame during the state's PRSTATE_MODE_UPDATE mode.
    // Write your code to implement your object state below.
}
After pasting the above snippet into your object's Create event, fill in the initialization if block (when the mode parameter equals PRSTATE_MODE_INIT), the clean-up/destruction if block (when the mode parameter equals PRSTATE_MODE_END) and the frame update section of the method (the main body of the method, or when mode equals PRSTATE_MODE_UPDATE) to implement your state's logic.