ID:144533
 
Code:Saving and loading Deck
mob/proc
save_deck(var/slotnum)
if(length(usr.deck) < 40)
usr<<"<b><font color = white>Sorry Cant Save a deck with 40 cards or less."
else
var/savefile/F=new("saves/[usr.key]/slot[slotnum].save")
F["deck"]<<usr.deck
F["Cards in deck"]<<usr.deck.len
usr<<"<b><font color = white>Cards and Deck Saved Successfully!"

load_deck(var/slotnum)
if(fexists("saves/[usr.key]/slot[slotnum].save"))
var/savefile/F=new("saves/[usr.key]/slot[slotnum].save")
F["deck"]>>usr.deck
F["Cards in deck"]>>usr.deck.len
LoadedDeck=1
usr<<"<b><font color = white>Cards and Deck Loaded Successfully!"
LoadedDeck=0
else
usr<<"No deck to load!"
turf/SaveDeck
icon = 'SaveDeck.png'
Click()
var/slotnum=input("Pick a slot to save your deck in.") in list("1","2","3","4","5","Cancel")
if(slotnum=="Cancel")
return
slotnum=text2num(slotnum)
if(fexists("saves/[usr.key]/slot[slotnum].save"))
switch(input("Do you want to overwrite the deck in slot [slotnum]?") in list("Yes","No"))
if("No")
return
usr<<"<b><font color = white>Saving your deck please wait..."
usr.save_deck(slotnum)
turf/LoadDeck
icon = 'LoadDeck.png'
Click()
var/slotnum=input("Pick a deck to load.") in list("1","2","3","4","5","Cancel")
if(slotnum=="Cancel")
return
slotnum=text2num(slotnum)
switch(input("Are you sure you want to load deck [slotnum]?")in list("Yes","No"))
if("Yes")
usr<<"<b><font color = white>Loading your deck please wait..."
usr.load_deck(slotnum)


Problem description:When you click load deck and you have a deck saved in that slot it reboots you. Can anyone help.
////////ALSO/////////
mob/proc/DisplayCardInHand()
for(var/obj/card/O in src.client.screen)
src.client.screen-=O
var/i=1
var/maxhand=src.hand.len
for(i,i<=maxhand,i++)
var/ypos=0
var/obj/card/O = src.hand[i]
var/q=i%8
if(q==0) q=9
O.layer=55+q//<--Says theres a problem with that line when displaying cards in hand.
if(i<9) ypos=0
else if(i>=9&&i<17) ypos=1
else if(i>=17&&i<25) ypos=2
else if(i>=25&&i<33) ypos=3
else if(i>=33&&i<40) ypos=4
else ypos=5
var/xpos
var/p = i-1
xpos=p%8
var/xmpos=0
var/xppos=14*xpos
while(xppos>32)
xmpos++
xppos-=32
O.screen_loc="[10+xmpos]:[xppos],[2+ypos]"
src.client.screen+=O


No put usr in proc. Ungh.

Lummox JR