ID:171494
 
Can anyone help me on whats wrong with this obj saving code?

proc
SavePlanets()
var/savefile/S=new("planets")
var/index=1
for(var/obj/O)
S["/obj[index]"]<<O
S["/objnum"]<<index

LoadPlanets()
var/savefile/S=new("planets")
var/object_max
var/obj/O
S["/objnum"]>>object_max
for(var/index=1,index<=object_max,index+=1)
S["/obj[index]"]>>O
Index is never incremented.
In response to Garthor
Sorry, im being dense here...what?
In response to Metroid
He means here:
for(var/obj/O)
S["/obj[index]"]<<O

index is never increased(incremented) so all of your obj are saved in the same index
for(var/obj/O)
S["/obj[index]"]<<O
index++

or
for(var/obj/O)
S["/obj[index]"]<<O
index+=1

Would both work in this case.
In response to Hobbesx
Hmmm...still doesnt work...any more problems with it?

Wait, would I need to do index++ for both save and load?

Edit: Nvm, I tried with both, still doesnt work X_X
In response to Metroid
Metroid wrote:
Hmmm...still doesnt work...any more problems with it?

Wait, would I need to do index++ for both save and load?

Edit: Nvm, I tried with both, still doesnt work X_X

Damnit! I really need help! Please help!
In response to Metroid
I redid this code, I dont know what was wrong, but it works now, I no longer need help.