Jihl
Member
Hey there all!
I am trying to make an X*2 long array which has pairs of numbers, the first the item id and second the item quantity, I'm doing this with a switch statement but it looks horribly unefficient and an unproffesional piece of code </3
I need to get the array in once piece so I can pass it as an argument to the final script. But I havent figured out how to do it iteratively.
Any ideas on how to make this iterative?
Thank you very much!
I am trying to make an X*2 long array which has pairs of numbers, the first the item id and second the item quantity, I'm doing this with a switch statement but it looks horribly unefficient and an unproffesional piece of code </3
I need to get the array in once piece so I can pass it as an argument to the final script. But I havent figured out how to do it iteratively.
Any ideas on how to make this iterative?
Code:
var total_slots = buffer_read(buffer, buffer_u8)
// Create auxiliar list and array
var list_aux = ds_list_create()
var array_aux = 0
for (var i = 0; i < total_slots; i++)
{
// Add item to the list
ds_list_add(list_aux, buffer_read(buffer, buffer_u16))
// Add item quantity to the list
ds_list_add(list_aux, buffer_read(buffer, buffer_u16))
}
// Make array to pass as argument
switch total_items
{
case 1:
array_aux = array(list_aux[0], list_aux[1])
break
case 2:
array_aux = array(list_aux[0], list_aux[1], list_aux[2], list_aux[3])
break
case 3: ...
case 4: ....
}
// Show the corpse loot "You don't need to know where does the corpse variable comes from for this post"
with corpse scr_show_loot_ensured(total_slots, array_aux)
Last edited: