ID:170477
 
I used flick in my attack proc:

    proc
Attackproc()
if(src.WType!="Bow")
flick("attack",src)
//attack stuff


The "if" is satisfied (because stuff after that is done) but the flick only works if it is the first time I use my character. I.e. if I have just created him. If I save, and reload, then it doesn't flick! What is happening?
Maybe it's your save code. Post it so we could take a look at it.
In response to CodingSkillz2
Um no.. what would tha thave anything to do with it?
Flick's a really weird proc, are you SURE that that icon state is in the icon the person is using? Half of the time I can't get it to work either.
In response to Flame Sage
Flame Sage wrote:
Um no.. what would tha thave anything to do with it?

Bzzt. Savecode can interfere with what he's doing. See how it's using an if with a var in there? If it doesn't get saved, it would return false, as of the var would equal null.
So, it may be his save system.
In response to Hell Ramen
mob
Write(savefile/F)
..()

F["last_x"] << x
F["last_y"] << y
F["last_z"] << z

Read(savefile/F)
..()

var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x, last_y, last_z)

client/proc/SaveMob()
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
var/char_ckey = cKey(src.mob.name)
F["/[ckey]/[char_ckey]"]<<src.mob

client/proc/LoadMob(char_ckey)
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
F["/[ckey]/[char_ckey]"]>>src.mob


mob
Logout()
for(var/a in OList)
OList += a
overlays -= a


I know that the "if" is being satisfied, every single time, because I put a 'world<<"TEST"' after it, which came up every time!
In response to Ease
Bump
In response to Ease
Have you tried setting icon_state directly instead of flick()ing? flick() is a very finicky and sometimes buggy proc.

You don't appear to be removing the overlays when saving. This might be the problem; if an atom is saved while it has overlays, it will get a new /icon object that is made up of its original icon plus the overlays. This /icon object won't have the icon_state that you're trying to flick().

You are attempting to remove overlays on logout, but that won't work: Firstly, you're looping through OList, which is probably empty. Secondly, looping through overlays instead wouldn't work either; it's not an ordinary list. Thirdly, that code is probably being executed *after* you save the mob, so even if it did work it wouldn't be doing anything.

Instead, here's how I manage overlays:

I give mobs a proc called RefreshOverlays(). This proc looks something like this:

mob/proc/RefreshOverlays()
// Clear existing overlays
overlays=null
// Add overlays
// ...


Instead of adding overlays just anywhere in your code, add ALL of them in RefreshOverlays(). (You'll obviously need to be able to check a condition for each overlay to determine whether you want to add it.) And in the places where you would normally add or remove overlays, call RefreshOverlays() instead.

Now that you've centralised all your overlays in one proc, overlay management becomes easy. When a mob is loaded (say, at the end of mob/Read()), call RefreshOverlays(). Just before a mob is saved (say, at the beginning of mob/Write()), set overlays=null to clear them.

This will potentially also result in smaller savefiles, because you may not need to save as many icons.