I am trying to create a simple inventory system for a game I am creating. The inventory needs 2 pieces of information for each item in the inventory, "item name" and "item description".
The information I read from the Angelscript website says to create
an array of string with 2 elements each.
Apparently this is done by using
string[] inventory(2);
What does this mean 2 elements?
How do I access those 2 elements inside the array?
The code below seems to work, but doesn't do what I expect it would do.
void Inventory(string item, string description) {
string[] inventory(2); // an array of string with 2 elements each.
inventory.insertLast(item); // item name
inventory.insertLast(description); //item description
print("ID:"+ inventory[1]);
print("ID:"+ inventory[2]);
print("ID:"+ inventory[3]);
}
Inventory("gold_key",item);
output
ID:
ID:gold_key
ID:Use this gold key to unlock a gold door.
I am not sure want you want to do but accessing array can be done using arr_name[index]. While index begin in 0. For example: