Does anyone know the best way to split a text file into an array by first searching for the id in the long list of items and then getting the next few lines from there and filling it into the array for example I have a text document
itemsDB.txt
001
Boots
Leather Boots
1
ITEMID
NAME
DESC
ITEMLEVEL
I plan on just filling it up with items like this
001
Boots
Leather Boots
1
002
Gloves
Leather Gloves
2
Is there a way for me to read through the item db doc find the line with the ID (001) then set vars with the next few lines data
I have this so far
var split : String[];
var id : int;
var itemName : String = "";
var itemdesc : String = "";
var itemlevel : int = 0;
function Start () {
getData(0);
}
var ITEMDBTEXTDOC : TextAsset;
function getData(id:int){
var itemDB = ITEMDBTEXTDOC;
split = itemDB.text.Split("\n"[0]);
id = parseInt(split[0]);
itemName = split[1];
itemdesc = split[2];
itemlevel = parseInt(split[3]);
}
This just fills an array with whatever is in there. I dont know how to do it from a specific line to a specific line?
Im trying to make an inventory based on itemIDs so that I can just have an inventory array of say 20 items all listed with IDs and then when I open my inventory I could just set all the thumbnails based on the ids from the db etc grab all the pics and set them. Then get all the data once the player mouses over the item (tooltip)