Energy Engine
Member
Hi,
I've run into a small problem which I thought wouldn't be an issue, but can't seem to get around. I'm simply trying to access and run a script inside an array, which itself is inside a list. The variable name of the array isn't being recognized even though its been declared as an instance variable. Also, please note that I don't actually want to call the list itself. The list is simply being mentioned as a caveat.
The relevant code is as follows (list related elements included):
Create:
I'm running the script "scr_ai_move_adv_mel". Inside the script:
This part:
Is where I'm having trouble. I'm trying to grab and run the script "scr_ai_stand_mel_grab" which is inside the array "ar_ml_grab[0]" along with its argument variable inside ar_ml_grab[2]. I went through the manual and found that accessors may be needed to access the script+arg inside the array. With the above code, I'm given an error which says that the variable ar_ml_grab is not an array, which is strange because it clearly is, as per the create event. But obviously I'm doing something wrong here with the syntax. The manual's example for array accessors doesn't seem too helpful in my case either.
Thanks in advance for any guidance.
I've run into a small problem which I thought wouldn't be an issue, but can't seem to get around. I'm simply trying to access and run a script inside an array, which itself is inside a list. The variable name of the array isn't being recognized even though its been declared as an instance variable. Also, please note that I don't actually want to call the list itself. The list is simply being mentioned as a caveat.
The relevant code is as follows (list related elements included):
Create:
Code:
//Create lists
ai_list_stand_mel_source=ds_list_create();
ai_list_move_source=ds_list_create();
//Array+scripts
ar_ml_grab[0] = scr_ai_stand_mel_grab;
ar_ml_grab[1] = script_get_name(ar_ml_grab[0]);
ar_ml_grab[2] = ["some argument value"]
ds_list_add(ai_list_stand_mel_source,
ar_ml_grab,
)
ar_mv_adv_mel[0] = scr_ai_move_adv_mel;
ar_mv_adv_mel[1] = script_get_name(ar_mv_adv_mel[0]);
ar_mv_adv_mel[2] = [noone]; //added in case this arg is needed
ds_list_add(ai_list_move_source,
ar_mv_adv_mel,
)
Code:
var scr_end = 1000;
var range_x = 48;
var mel_choice = noone;
if ai_mom<scr_end
{
if feed_x<=range_x
{
mel_choice=choose("mel")//,"gr")
if mel_choice=="mel"
{
var sel = ar_ml_grab[@ 0]
script_execute(sel[0],sel[2]);
}
}
}
Code:
var sel = ar_ml_grab[@ 0]
script_execute(sel[0],sel[2]);
Thanks in advance for any guidance.
Last edited: