I’m looking for a simple way to create a mass ammount of items and be able to call them at anytime. I want to be able to place these items in a vendor system or your inventory / bank. I’m not sure exactly how this would be done. Need to be able to create and store them in a list or array that can be accessed at anytime.
function item1 () {
//item name
//item stats
//item price
//class that can use
//level required
//add this item to an array or list
}
function vendorNPC1 () {
//check array for item1 and add item1 to sellable items
}
What I do in the RPG I am making:
- Declare and initialize all items in a static global array at starting.(array that can be accessed at anytime). You need to keep track and know which item is in which index.
- Just add any item you want to sell from this pre-defined array to a vendor’s inventory array.
How to make a basic item class
Class Item(){
private var name:String;
private var price:int;
//constructor
Item(_name;_price){
item_name=_name;
item_price=_pirce;
}
Get_Price(){
return item_price;
}
}
To create a item : var my_item:Item=new Item(“posion”,360);
To compare price: if (my_item.Get_Price<=Player.money)