ID:159831
 
Hi everybody, im making a game from the bases, and I need to make something like a tmp var, but for an overlay, I mean that i dont want the overlay to be saved with the character, I could do this just with a "src.overlays-=''" in the load proc, and it works perfectly, but i'd like to now if there's a more effective way of doing this so i'll not end up with hundreds of extra lines of code. (like the vars, you can set the var to the normal state after loading, but it's more effective using a tmp var)

If i said something without sense, sorry, english isn't my main language but Im trying to be as clear as possible
Lists are your friends!

mob/player/var/list/saved_overlays = new //only place this var on player mobs!

mob/player/Save()
overlays = null
//do your saving here
overlays = saved_overlays

mob/player/Load()
//load your mob here
overlays = saved_overlays

mob/player/proc/add_overlays() //just place all the overlays you want
//to add into the args, it will
//add all of them
overlays += args
saved_overlays += args

In response to Jeff8500
thx, i always try to avoid lists cause i dont understand them pretty well xD
ok i understand them but i still kinda afraid of using themfor some reason...
anyway im gonna try to start learning about and use them =) thx again


oh and well, i haven't tried it yet cause im not in my house, but i'm sure it works ^^



EDIT: a question.. i never used a sub-category for my players , i just use mob for normal players(the ones with no special verbs like mods, etc.), is there a difference in using a sub-category?
and how do i define a sub-category as the one for players?


Again, if i say something wrong, english isn't my main sorry ^^
In response to Frolik
Look up world/mob. You set it to the type you want the mob to be when they fist login.

As for the subtype thing goes, you should always use one for things that don't need the same variables as others.

mob
var/strength
var/defense

Player
var/gold

Monster
var/AIflags


See how strength and defense are shared, but gold and AIflags aren't? It conserves resources, especially with vars that are lists, objs, etc. If you have, let's say, 10 lists per mob, and you have 660 mobs (some of which may not even need the var!) in your world, you will be breaking the list limit, which makes your game virtually unplayable.
In response to Jeff8500
ok thx, and it's true i neve thought in all those unnecesary vars using resources ^^

and lucky me, cause now im in time to adapt the code (im just starting this game =) )
And now im starting to think other great thinks about having player in a different subtype xD

ok again, and for last time: Thanks =)