D
state = PlayerStateFree;
.....
//later in step
state();
// instead of script_execute(), just call it directly
//Activate key logic
if(keyActivate)
{
//1. Check for an entity to activate
//2. If there's nothing, or something without a script, do nothing
//3. Otherwise, activate diologue
//4. If the entity is an NPC, make it face towards the player
var _activateX = lengthdir_x(10, direction);
var _activateY = lengthdir_y(10, direction);
activate = instance_position(x+_activateX, y+_activateY, pEntity);
if (activate == noone || activate.entityActivateScript == -1)
{
state = PlayerStateFree;
}
else
{
ScriptExecuteArray(activate.entityActivateScript, activate.entityActivateArgs);
}
//NPC dir
if (activate.entityNPC)
{
with (activate)
{
direction =point_direction(x,y,other.x,other.y);
}
}
English, please?Yeah, as has been said, you cannot write a script in GMS 2.3 the same way you would write a script in any prior version. The script must contain a function. if your script does not contain a function, game maker will look through the script at the start of the game and treat every single variable in that script as a global variable. It doesn't matter if the player object itself defines those same variables, game maker will treat the player's variables as instance variables and the variables references in the script as global variables. Since you define the instance variables and not the global variables, you get the error messages. If the script instead contains a function, then the function can use the instance variables. If you open the debugger and look at the variable listings while your game is running, you will see that the variables you mentioned in the scripts appear as either unassigned or global variables, in addition to the instance variables with the same names.
function
syntax.function PlayerStateFree() {
...
}