Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(4 edits)

I think GML live cache was just not flushed properly. Now it's reloading the enums fine. But If I encounter it again I will copy all the related code.

As for something else though it is related to arrays not being read properly.

[SCRIPT CALL] player_state_handle(0);
[live][2020-08-12 17:33:15] Runtime error: [error] Argument index 0 is out of range (0..0 excl)
 called from player_state_handle[L6,c12]
[live][2020-08-12 17:33:15] Runtime error: [error] Value must be a number.
 called from par_player:Step_0[L109,c8]

``` Player Create Event
myArr [0] = [0,0,0];
myArr = player_state_create(player_state_value.idle);
```
``` Player State Create (Script)
/// enemy_state_create(initial value: state value, ?custom handle:script, ?custom change:script): state
/// @arg state {enum}
/// @arg custom_handling_script {script}
/// @arg custom_changing_script {script}
if(live_call()){ return live_result; }
enum player_state {

current, 
previous, 
can_attack, 
cooldown, 
spawned_summons, 
can_crit, 
custom_handle, 
custom_change, 
skillset, 
state_args, 
sizeof };
enum player_state_value { 

spawn, 
idle, 
transformation,
move_overworld,
inventory,
readycombat,
drawsword,
combat,
combat_move,

blocking,
victory,
attack_heavy,
attack_normal,
injured,
dying,

hurt,


out_of_combat, 


death, 
respawn,
summoning_allies, 
attacking, 
attacking_crit, 
staggered, 
despawn, 
returning, 
walking, 
casting, 
sizeof };

gml_pragma("global", "global.player_sprite_map = ds_map_create();");

var _init_state = argument[0];

var _arr/*:player_state*/ = array_create(player_state.sizeof, undefined);

_arr[player_state.current] = _init_state;
_arr[player_state.can_attack] = false;
_arr[player_state.can_crit] = false;
_arr[player_state.cooldown] = 0;
_arr[player_state.spawned_summons] = false;
_arr[player_state.custom_handle] = (argument_count > 1) ? argument[1] : undefined; 
_arr[player_state.custom_change] = (argument_count > 2) ? argument[2] : undefined;
_arr[player_state.skillset] = [];
_arr[@player_state.state_args] = [];

player_state_change(_arr, player_state.current);

#region Create state string map (for debugging)
_psv = ds_map_create();
_psv[?player_state_value.attack_heavy ] = "attack_heavy";
_psv[?player_state_value.attack_normal ] = "attack_normal";
_psv[?player_state_value.attacking ] = "attacking";
_psv[?player_state_value.attacking_crit ] = "attacking_crit";
_psv[?player_state_value.blocking ] = "blocking";
_psv[?player_state_value.casting ] = "casting";
_psv[?player_state_value.combat ] = "combat";
_psv[?player_state_value.combat_move ] = "combat_move";
_psv[?player_state_value.death ] = "death";
_psv[?player_state_value.despawn ] = "despawn";
_psv[?player_state_value.drawsword ] = "drawsword";
_psv[?player_state_value.dying ] = "dying";
_psv[?player_state_value.hurt ] = "hurt";
_psv[?player_state_value.idle ] = "idle";
_psv[?player_state_value.injured ] = "injured";
_psv[?player_state_value.inventory ] = "inventory";
_psv[?player_state_value.move_overworld ] = "move_overworld";
_psv[?player_state_value.out_of_combat ] = "out_of_combat";
_psv[?player_state_value.readycombat ] = "readycombat";
_psv[?player_state_value.returning ] = "returning";
_psv[?player_state_value.sizeof ] = "sizeof";
_psv[?player_state_value.spawn ] = "spawn";
_psv[?player_state_value.staggered ] = "staggered";
_psv[?player_state_value.summoning_allies ] = "summoning_allies";
_psv[?player_state_value.transformation ] = "transformation";
_psv[?player_state_value.victory ] = "victory";
_psv[?player_state_value.walking ] = "walking";

#endregion
return _arr;
```
``` Player Step Event 0
player_state_handle(myArr);
```
``` Player State handle
/// player_state_handle(state):bool
/// @desc handles the state during the Step revent, returns true if there was a state change, and false otherwise
/// @arg state
if(live_call()){ return live_result; }
show_debug_message("[SCRIPT CALL] player_state_handle("+string(myArr)+");");
var _arr = argument0;

var _state_value = _arr[ player_state.current];

show_debug_message("[Player] (state current) = " + string(_psv[? _state_value]) ) ;
```

Your script takes arguments but you are not passing them into live_call, that's what your error is.