A little issue with local variable

Discussion in 'Programming' started by Jihl, Jan 11, 2019.

  1. Jihl

    Jihl Member

    Joined:
    Nov 26, 2018
    Posts:
    21
    Hey there all

    Thanks for all the help until now, you are the best community :D

    May I get a little bit of help on this? It is giving me the error that "array_aux" is not defined when the function scr_show_loot_ensured gets called

    the code:
    Code:
    // Read Data
    var object_type = buffer_read(buffer, buffer_u8)
    var my_id       = buffer_read(buffer, buffer_u16)
    var total_slots = buffer_read(buffer, buffer_u8)
    
    // Create auxiliar array
    var array_aux
       
    for (var i = 0; i < total_slots; i+=2)
    {
        // Add item to the array
        array_aux[i] = buffer_read(buffer, buffer_u16)
        msg("Got item id: " + string(array_aux[i]))
    
        // Add item quantity to the array
        array_aux[i+1] = buffer_read(buffer, buffer_u16)
    }
         
    // Find object
    var object = scr_object_find(object_type, my_id)
         
    // Use object
    if !is_undefined(object)
    {
        with object
        {
            // Show the corpse loot
            scr_show_loot_ensured(total_slots, array_aux)
        }
    }
    else msg("Object is undefined")
    Thank you very much!
     
  2. Death

    Death Member

    Joined:
    Aug 8, 2018
    Posts:
    75
  3. Jihl

    Jihl Member

    Joined:
    Nov 26, 2018
    Posts:
    21
    I am sorry! The problem was that total_slots was 0 so array_aux had no values at all.
     
  4. Jihl

    Jihl Member

    Joined:
    Nov 26, 2018
    Posts:
    21

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