1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 [Solved] Unable to run script with list item as condition (+ script/arg/array)

Discussion in 'Programming' started by Energy Engine, Aug 13, 2019.

  1. Energy Engine

    Energy Engine Member

    Joined:
    Jun 23, 2016
    Posts:
    74
    Hi,

    I'm trying to get a script with arguments as arrays to run based on the action condition variable accessed in another list. There doesn't seem to be any errors, but I can't actually get the scripts to trigger even though the action condition shows me that it has accessed the action condition variable in that list.

    Setup as follows:

    Create:

    Code:
    big_list=ds_list_create(); //action condition list
    
    list_a=ds_list_create(); //list containing script/array
    list_b=ds_list_create();
    
    arr_entry[0] = scr_debug_msg;
    arr_entry[1] = ["A1","A2","A3"];
    
    arr_entry2[0] = scr_debug_msg;
    arr_entry2[1] = ["B1","B2","B3"];
    
    ds_list_add(list_a,
    arr_entry,
    );
    
    ds_list_add(list_b,
    arr_entry2,
    );
    
    ds_list_add(big_list,
    "move", //a items
    "mel" //b items
    )
    Step:

    Code:
    if keyboard_check_pressed(220)
    {
    ai_do=ds_list_find_value(big_list,0) //position adjusted thru shuffle
    }
    
    if ai_do=="move"
        {   
        var script_arr = list_a[| 0];
        script_execute(script_arr[0],script_arr[1]);
        }
      
    else if ai_do=="mel"
        {
        var script_arr = list_b[| 0];
        script_execute(script_arr[0],script_arr[1]);
        }
    I can see that ai_do becomes "move" or "mel", but the scripts above don't seem to run. Should this not work? Note that I also tried replacing the strings above with numbers just to be on the safe side, but still no triggering.

    Thanks in advance!
     
  2. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,167
    Do you know how to use the debug mode and set break points?

    This would be the ideal time to learn if you haven't used it before. The code looks fine to me at first glance. So you would want to use debug mode, and step through the code to see exactly what is happening, and where it is going wrong.
     
  3. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    949
    With the script scr_debug_msg being passed an array, how are you handling that in the script?

    Something like this should output them correctly. Does that not work?
    Code:
    //scr_debug_msg()
    var a = argument[0];
    show_debug_message(a[0]);
    show_debug_message(a[1]);
    show_debug_message(a[2]);
    
     
  4. Energy Engine

    Energy Engine Member

    Joined:
    Jun 23, 2016
    Posts:
    74
    Thank you both.

    Also, please forgive my stupidity. I just noticed I forgot about a runner variable that needed to be on, which was commented out, but forgot to uncomment. So I assumed something was wrong with the way the list was being read. Issue is resolved.
     
    IndianaBones likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice