• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

A little issue with local variable

Jihl

Member
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!
 
Top