B
Bonemarrow
Guest
So, few hours ago I asked a question about arrays, and folks told me it would be easier to do it with ds_list. So here I am, stuck with ds_list.
In short, I have an array with all the owned items (Their ID's). Its called inventoryItemListTemp.
The plan is to store all items from the array to the ds_list, remove the desired item from the list, and then write all the item ID's from the list to one file, seperated with comas.
Example of my code:
Now the problem is, when the values from the ds_list are written to a file, the wrong item is removed.
For example, I load numbers 2,3,4,5,7 to the list. I remove the number in 3rd place. I write it to the file. However, the wrong number is removed.
In advance- thank you.
In short, I have an array with all the owned items (Their ID's). Its called inventoryItemListTemp.
The plan is to store all items from the array to the ds_list, remove the desired item from the list, and then write all the item ID's from the list to one file, seperated with comas.
Example of my code:
Code:
item = argument0;
to_remove = 0;
list = ds_list_create();
//assign to the list
for(i=0; i<inventoryItemAmount; i++) {
ds_list_add(list,inventoryItemListTemp[i]);
if inventoryItemListTemp[i] = item then to_remove = i;
}
//remove the item from ds list
ds_list_replace(list,to_remove,"undefined");
//remove one item from var
inventoryItemAmount --;
inventoryDataS = file_text_open_write("InventoryData");
for(wr=0; wr<=inventoryItemAmount; wr++) {
if ds_list_find_value(list,wr) != "undefined" then file_text_write_string(inventoryDataS,string(ds_list_find_value(list,wr))+",")
}
file_text_close(inventoryDataS)
For example, I load numbers 2,3,4,5,7 to the list. I remove the number in 3rd place. I write it to the file. However, the wrong number is removed.
In advance- thank you.