ID:147491
 
Bah, I'd sworn I'd hit "Reply". >.< Anyhow, new post below...
Are you sure these are actually the same object? Savefiles aren't supposed to save two copies unless they're different objects. So the left leg equipment should be object("../inventory/.0") if they're the same.

For debugging purposes, try outputting the \ref of each object as it saves.
var/obj/O
for(O in inventory) src << "[O] = \ref[O]"
for(O in equipped) src << "[O] = \ref[O]; [equipped[O]] = \ref[equipped[O]]"

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Are you sure these are actually the same object? Savefiles aren't supposed to save two copies unless they're different objects. So the left leg equipment should be object("../inventory/.0") if they're the same.

For debugging purposes, try outputting the \ref of each object as it saves.
var/obj/O
> for(O in inventory) src << "[O] = \ref[O]"
> for(O in equipped) src << "[O] = \ref[O]; [equipped[O]] = \ref[equipped[O]]"

Lummox JR

Right, I just tried that, and recieved:

Gi Bottom = [0x2000036], the the first loop only showed up.
Ok, I came up with something else that could possibly work for me, but I'm not exactly too well on how to parse text, so much help would be appreciated.

        Save()
if(istype(src,/mob/player/))
var/savefile/F=new
var/txtfile=file("player/[copytext(src.ckey,1,2)]/[src.ckey].lotd.txt")
if(fexists(F))
fdel(F)
src.Write(F)
F["last_x"]<<src.x
F["last_y"]<<src.y
F["last_z"]<<src.z
F["overlays"]<<list()
F["underlays"]<<list()
F["icon"]<<null
F["icon_state"]<<""
F["type"]<<src.type
F["version"]<<src.version
F["attacks"]<<src.attacks
F["currentattack"]<<src.currentattack
F["dir"]<<src.dir
var/i=0
var/list/L[0]
for(var/X in src.equipped)
for(var/obj/items/C in src.inventory)
i++
if(src.equipped[X]==C)
var/d=html_decode("&#34;")
L["[X]"]="object([d]../inventory/.[i-1][d])"
F["equipped"]<<L
fdel(txtfile)
F.ExportText("/",txtfile)
return 1
else
return 0
Load()
if(fexists("player/[copytext(src.ckey,1,2)]/[src.ckey].lotd.txt"))
var/savefile/F=new
var/txtfile=file("player/[copytext(src.ckey,1,2)]/[src.ckey].lotd.txt")
F.ImportText("/",txtfile)
var/Version
F["version"]>>Version
if(!Version)
Version=0
if((num2text(Version) in Tech_Wipes))
src<<"<b>Techniques for version: [num2text(Version)], were wiped.</b>"
F["attacks"]<<list()
F["version"]<<world.version
F["currentattack"]<<1
if((num2text(Version) in Player_Wipes))
src<<"<b>Player files for version: [num2text(Version)], have been wiped, please remake.</b>"
fdel("player/[copytext(src.ckey,1,2)]/[src.ckey].lotd.txt")
return
var/TYPE
var/last_x
var/last_y
var/last_z
F["type"]>>TYPE
var/mob/player/P=new TYPE
P.Read(F)
F["last_x"]>>last_x
F["last_y"]>>last_y
F["last_z"]>>last_z
F["version"]>>P.version
F["attacks"]>>P.attacks
F["currentattack"]>>P.currentattack
F["dir"]>>P.dir
P.loc=locate(last_x,last_y,last_z)
for(var/X in P.equipped)
//This is where I'm stuck, I have NO idea on how to take out the extra back slashes and quotes from which my saving proc had inserted.
return P
In response to Goku72
Goku72 wrote:
Right, I just tried that, and recieved:

Gi Bottom = [0x2000036], the the first loop only showed up.

Doh!

I've done you a bit of an accidental disservice here by making O an obj; if you declare it as just var/O instead, it will properly loop through the strings in the equipped list as it should.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Goku72 wrote:
Right, I just tried that, and recieved:

Gi Bottom = [0x2000036], the the first loop only showed up.

Doh!

I've done you a bit of an accidental disservice here by making O an obj; if you declare it as just var/O instead, it will properly loop through the strings in the equipped list as it should.

Lummox JR

Ya, I figured that out, and it infact did output two different references.
In response to Goku72
Goku72 wrote:
Ya, I figured that out, and it infact did output two different references.

Then the two objs saving isn't a mistake; they're not identical.

If you want these to be the same object, you'll have to be sure to do that when the lists are set up or changed.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Goku72 wrote:
Ya, I figured that out, and it infact did output two different references.

Then the two objs saving isn't a mistake; they're not identical.

If you want these to be the same object, you'll have to be sure to do that when the lists are set up or changed.

Lummox JR

Well, that's just the thing, At no point do I make a new object. I simply set the equipped list similarly to this:

obj
items
clothing
proc
Use(mob/User)
if(!User.equipped["left leg"])
User.equipped["left leg"]=src


All of a players items are stored in their inventory list, and then defined as equipped when a reference is set in the equipped list.

In response to Goku72
Goku72 wrote:
Well, that's just the thing, At no point do I make a new object. I simply set the equipped list similarly to this:
obj
items
clothing
proc
Use(mob/User)
if(!User.equipped["left leg"])
User.equipped=src

Hopefully it's not identical to that. That code won't work, inasmuch as your equipped list is associative and you just replaced it outright with src.

Anyway, if your equipped list isn't causing the problem, the inventory list is. One or the other is creating a repeat reference.

You should also watch out here because it may be that your equipping isn't limiting the object to something in your own inventory, thereby equipping an entirely different object.

Lummox JR
In response to Lummox JR
Ya, sorry about that. I just made that proc up there real quick earlier, it sets User.equipped["left leg"]=src; which I fixed in the other post. Also, the problem didn't really occur until I changed my saving system from just directly saving the mob to using Write() and Read(), then changing variables directly.

<Edit>
Also forgot to mention that the equipment system doesn't get all whacky until I relog in, otherwise it works just as it should.
</Edit>