ID:139759
 
I had this working earlier, but for some reason it won't work now! I apparently deleted a line and dont even remember what it was...

Code:
mob/proc/LoadList()
src << output("Loading List","LoginScreen.saveinfo") //Just an output to let me know Im loading a list
var/file_text=file2text("ListFile.txt")
var/seperate_items[] = text2list(file_text,";") // Each semi-colon indicates the end of a line of text
for(var/text_string in seperate_items)
var/list/split_text_string = text2list(text_string,"]") //Each end/right bracket thing indicates a seperator
var/A=split_text_string[2] as text
var/B=split_text_string[1] as text //convert it to text? idk why I just had to to make it work before
src << output("[A] found in [B]","LoginScreen.saveinfo") // more output to let me know an item was found
if(B=="Main")
var/O=text2path(A)
var/atom/a=new O() //creating the object
src << output(a,"LoginScreen.saveinfo")


Problem description:
After working from before, loading items from a text file and placing them in a list (like an inventory?), I somehow screwed up and now it's not loading the list.

I believe this is the broken part, as this does nothing now
if(B=="Main")
var/O=text2path(A)
var/atom/a=new O() //creating the object

You aren't doing anything with the created object.
In response to Garthor
Sorry, it's supposed to add the created object to the player's list of items.
            var/O=text2path(A)
var/atom/a=new O()
if(findtext(B,"Main"))
src.Items+=a

But when I do it gives me this

runtime error: list index out of bounds
proc name: LoadSelectedDeck (/mob/proc/LoadList)
source file: Login.dm,50
usr: Puppy (/mob/Player)
src: Puppy (/mob/Player)
call stack:
Puppy (/mob/Player): LoadList()
Puppy (/mob/Player): Login()
In response to Puppy93
Posting the error in the first place would've been helpful.

The issue is that you are making assumptions about the text string which are not true. You assume you are getting two elements in the list when you split it along the "]" character, but really there's only one (or zero).
In response to Garthor
Garthor wrote:
Posting the error in the first place would've been helpful.

The issue is that you are making assumptions about the text string which are not true. You assume you are getting two elements in the list when you split it along the "]" character, but really there's only one (or zero).

I didn't get that error till I edited it today. I'll try fixing it up.

Edit: It seems to semi-work, it places some of the objects in the list, but not all of them.