Error Message Since Patch 2.3

Halas

Member
Hi Guys,

I updated my program today to see a few error messages. I managed to get through most of them, but this one is currently proving to be a nasty one I can't get.

___________________________________________
############################################################################################
ERROR in
action number 1
of Other Event: User Defined 2
for object obj_inv_panel:

script_execute argument 1 incorrect type (undefined) expecting a Number (YYGI32)
at gml_Script_ev_notify (line 49) - script_execute(_script, _inv, _event, _updated_slots);
############################################################################################
gml_Script_ev_notify (line 49)
gml_Script_item_switch (line 38) - ev_notify(_inv1, EVENTS.inv_updated);
gml_Object_obj_inv_panel_Other_12 (line 18) - item_switch(inv, _pressed_slot.index, _mouse_slot.inv, _mouse_slot.index);
gml_Object_obj_inv_panel_equipment_Other_12 (line 57)
gml_Object_obj_inv_mouse_Step_0 (line 9)

Now this is relating to the script: ev_notify
from line: script_execute(_script, _inv, _event, _updated_slots);
It says _event is supposed to be a number. In this case, _event is calling EVENTS.inv_updated which is an Enum.

The Enum being:

GML:
enum EVENTS {
        inv_updated,
        inv_destroyed,
        inv_resized
    }
Any suggestions?
 

chamaeleon

Member
Code:
script_execute argument 1 incorrect type (undefined) expecting a Number (YYGI32)
at gml_Script_ev_notify (line 49) -                      script_execute(_script, _inv, _event, _updated_slots);
It says _event is supposed to be a number. In this case, _event is calling EVENTS.inv_updated which is an Enum.
The error message tells you argument 1, _script, is undefined.
 

Halas

Member
According to the manual,

Argument 1 is the 3rd entry in the script_execute

Is this not correct?


script_execute(scr, arg0, arg1, arg2..., etc...);

ArgumentDescription
scrThe name of the function/script that you want to call
arg0, arg1, arg2..., etc...The different arguments that you want to pass through to the function/script
 
Last edited:

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
Argument 1 is not the same as arg1.

Argument 1 is the first argument you pass to a function. The function is script_execute.
 

Halas

Member
This script is taken from:

var _observers = ds_list_create(); ds_list_copy(_observers, _inv[? "observers"]);
var _observers_count = ds_list_size(_observers);

//cycle through observers and notify the event
for(var _o = 0; _o < _observers_count; _o++) {

var _observer = _observers[| _o];

var _instance = _observer[0];
var _script = _observer[1];

//skip if instance doesn't exist
if(!instance_exists(_instance)) { continue; }

with(_instance) {
script_execute(_script, _inv, _event, _updated_slots);
}

Any ideas on how I can troubleshoot how and why its not registering a script.
 

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
The error states that argument 1 is undefined.
Argument 1 is _script.
Therefore _script is undefined.

_script is _observer[1].
Therefore _observer[1] is either undefined, or doesn't exist, and therefore will return undefined when you try to access it.

Where are you declaring whatever is supposed to be in it?
 

Halas

Member
First I should mention: This block of code is part of a system purchased in the marketplace - I have emailed their support but has been non-responsive since August.
I did receive permission from Nocturne to get help on this matter.

Now, Where are you declaring whatever is supposed to be in it?

I haven't looked into this section of code yet, I will be doing so and updating when I can.

Looking quickly through the scripts, I found this. I cannot post the entire block of code, only what related as per instructed.

.
.
.


var _inv = argument0;
var _instance = argument1;
var _script = argument2;

//get list of subscribers for this event
var _observers = _inv[? "observers"];

//create observer array
var _observer = array_create(2);

//add instance
_observer[0] = _instance;

//add script
_observer[1] = _script;

.
.
.



}
 

Halas

Member
Yes but it looks like it was already converted to that syntax. This is the script.
I understand that the variables are no longer needed, but it should work under these conditions.

function ev_subscribe(argument0, argument1, argument2)
{
var _inv = argument0;
var _instance = argument1;
var _script = argument2;

//get list of subscribers for this event
var _observers = _inv[? "observers"];

//create observer array
var _observer = array_create(2);

//add instance
_observer[0] = _instance;

//add script
_observer[1] = _script;

//register
ds_list_add(_observers, _observer);
}
 

chamaeleon

Member
Yes but it looks like it was already converted to that syntax. This is the script.

function ev_subscribe(argument0, argument1, argument2)
{
...
var _script = argument2;
...
_observer[1] = _script;
...
}
But what does the call to ev_subscribe look like? Does it pass a correct value for argument2/_script?
 

Halas

Member
This is the purpose of the script.

///@func ev_subscribe(inventory, instance, script)
///@desc Subscribe the specified instance to the inventory events. Whenever an event for the inventory is fired, the specified script is run.
///@arg {number} inventory - the inventory to subscribe to
///@arg {instance} instance - id of the instance that is subscribing
///@arg {script} script - the script to run when an event gets fired

//ev_subscribe(inventory, instance, script)
if _item = "spell"
{
ev_subscribe(global.inv_equipment, id, Spells_roll(global.inv_equipment, EVENTS.inv_updated))
}

Spells_roll being the script it should be passing.

The purpose of this instance is to update the player stats once an item is equipped, which is why we see the error once an item attempts to equip.
 

chamaeleon

Member
This is the purpose of the script.

///@func ev_subscribe(inventory, instance, script)
///@desc Subscribe the specified instance to the inventory events. Whenever an event for the inventory is fired, the specified script is run.
///@arg {number} inventory - the inventory to subscribe to
///@arg {instance} instance - id of the instance that is subscribing
///@arg {script} script - the script to run when an event gets fired

//ev_subscribe(inventory, instance, script)
if _item = "spell"
{
ev_subscribe(global.inv_equipment, id, Spells_roll(global.inv_equipment, EVENTS.inv_updated))
}

Spells_roll being the script it should be passing.

The purpose of this instance is to update the player stats once an item is equipped, which is why we see the error once an item attempts to equip.
You cannot call the function/script you want to pass as a script to invoke. It has already been called by the time ev_subscribe() is called, and Spells_roll()'s return value is what is passed, not some imagined form of "lets call this expression at a later time". Use only the name of function, no arguments, no parentheses.
 
Last edited:

FrostyCat

Member
When you do this:
GML:
ev_subscribe(global.inv_equipment, id, Spells_roll(global.inv_equipment, EVENTS.inv_updated));
You are running Spells_roll(global.inv_equipment, EVENTS.inv_updated) right away and using the return value of that as a script ID. That is not what you were asked to provide for the function.

The most straight-forward but short-sighted solution is to put Spells_roll(global.inv_equipment, EVENTS.inv_updated) into its own script (say Spells_equipment_updated), then pass that as the third argument.
GML:
ev_subscribe(global.inv_equipment, id, Spells_equipment_updated);
The long-term solution is to patch that library to make the "script" arguments also take methods, such that you can do this without starting a new script:
GML:
ev_subscribe(global.inv_equipment, id, function() {
    Spells_roll(global.inv_equipment, EVENTS.inv_updated);
});
 

Halas

Member
I am not entirely sure what you meant by your long term solution, I did the short term one.

While the initial error is gone, two other spawned in its place.

############################################################################################
ERROR in
action number 1
of Other Event: User Defined 2
for object obj_inv_panel:

Data structure with index does not exist.
at gml_Object_obj_inv_panel_Other_12 (line 29) - var _item = _pressed_slot.item[? "category"]
############################################################################################
gml_Object_obj_inv_panel_Other_12 (line 29)
gml_Object_obj_inv_panel_equipment_Other_12 (line 57)
gml_Object_obj_inv_mouse_Step_0 (line 9)


This script being:

GML:
if item_get_amount(_pressed_slot.inv,_pressed_slot.index) >=1
    {
        var _item = _pressed_slot.item[? "category"]   
        show_debug_message(string(_item))
        show_debug_message(string(_pressed_slot.item[? "category"]))
                //Items
        if _item != "spell" && _item != "rune"   
            {
                ex_ev_subscribe(global.inv_equipment, id, Stats_roll)
            }       
        if _item = "spell"
            {
                ex_ev_subscribe(global.inv_equipment, id, Spells_roll)
            }
        if _item = "rune"   
            {
                ex_ev_subscribe(global.inv_runespage, id, Runes_roll)
            }
    }

___________________________________________
############################################################################################
ERROR in
action number 1
of Other Event: User Defined 2
for object obj_inv_panel:

DoConv :1: illegal undefined/null use
at gml_Script_Stats_roll (line 36) - global.stats_items[_istat] += _ivalue;
############################################################################################
gml_Script_Stats_roll (line 36)
gml_Script_ev_notify (line 49)
gml_Script_item_switch (line 38) - _ev_notify(_inv1, EVENTS.inv_updated);
gml_Object_obj_inv_panel_Other_12 (line 18) - item_switch(inv, _pressed_slot.index, _mouse_slot.inv, _mouse_slot.index);
gml_Object_obj_inv_panel_equipment_Other_12 (line 57)
gml_Object_obj_inv_mouse_Step_0 (line 9)

GML:
///@desc    Stat Roll - Adding stats to player once equipped.
///        {ds_list} updated_slots - ds_list of affected slots if inv_updated event (-1 in the other events)
function Stats_roll() {

    var _inv = global.inv_equipment;
    var _event = EVENTS.inv_updated;
    //var _updated_slots = argument2;

    switch(_event) {

      case EVENTS.inv_updated:
        //fired when the contents of the EQUIPMENT inventory have been changed
    
        //Reset Item Stats to 0
    {
        for (var a=0; a<5; a++)
                {
                    global.Stats[a] -= global.stats_items[a];
                    global.stats_items[a] = 0;
                    Obj_Player.weapon = 0;
                    Obj_Player.Idmg = 0;
                }
        //Check item and its Stats
        for (var _i = 0; _i < inv_max_size(_inv); _i++)
            {
                if (item_get_amount(_inv, _i)) >= 1
                    {
                        //Get Info
                        var _key = tag_get(_inv,_i,"Key");
                        var _istat = tag_get(_inv, _i, "Istat");
                        var _ivalue = tag_get(_inv, _i, "Ivalue");
                        var _idmg = tag_get(_inv, _i, "Damage");
                        //var _irare = tag_get(_inv, _i, "Rarity");
                        //var _iweight = tag_get(_inv, _i, "Weight");
                    
                        global.stats_items[_istat] += _ivalue;   
                        Obj_Player.Idmg = _idmg
                        Obj_Player.weapon = _key
                        show_debug_message(string(_key))
                
                    }
                            
            }
        //Add Item Stats to Player Stats
        for (var a=0; a<5; a++)
            {   
                global.Stats[a] += global.stats_items[a]
            }
    
        ev_unsubscribe(_inv, id);
    }
      break;

      case EVENTS.inv_destroyed:
        //fired when the inventory gets destroyed (as a result as inv_destroy)
      break;

      case EVENTS.inv_resized:
        //fired when the inventory gets resized (as a result as inv_resize)
      break;

    }



}
 
Top