ID:2180236
 
Movement states:
#define NULL_STATE 0
#define STATE_FLYING (1 << 0)
#define STATE_TRAINING (1 << 1)
#define STATE_WATER (1 << 2)
#define STATE_KO (1 << 3)
#define STATE_FROZEN (1 << 4)
#define STATE_CHARGE (1 << 5)
#define TILE_WIDTH 32
#define TICK_LAG 0.25

#define MOVE_STATES (STATE_FLYING)
#define FREEZE_STATES (STATE_TRAINING | STATE_WATER)
#define STOP_STATES (STATE_KO | STATE_FROZEN | STATE_CHARGE)


Skill example:
            Train()
set waitfor = FALSE
set category = "Skills"
usr << output("You have attempted to train.","chat")
if(stopState())
return FALSE
if(state != STATE_TRAINING)
state = STATE_TRAINING
state2 = NULL_STATE
icon_state = "Training"
else
nullState()
training = FALSE
while(state == STATE_TRAINING)
if(energy <= 5)
training = FALSE
usr << output("You have run out of energy.","chat")
nullState()
else
usr << output("You are training and have [energy] energy.","chat")
training = TRUE
energy -= 5
var/stat = pick(stats)
if(stat == "energy")
if(prob(50))
maxEnergy += (maxEnergy / 100) * energyGain
world << output("You now have [maxEnergy] max energy.","chat")
else
var/statM = stat + "M"
if(vars[stat] < (vars[statM] * statCap))
vars[stat] += 1 * statGain
sleep(50)

Loading
        Load()
var/savefile/F = new("Saves/Players/[ckey].is")
if(fexists("Saves/World/World.is"))
Read(F)
var/xo
var/yo
var/zo
F["X"] >> xo
F["Y"] >> yo
F["Z"] >> zo
loc = locate(xo,yo,zo)
stateLoads()
else
Character()



Problem description:
When using Train, it works fine - however, saving, logging off, then loading will not make the user continue from where he left off (training). Rather, it just keeps their state as frozen and does nothing.

How would I make it so that whatever they were last doing is continued?

You'd either want to not save their state and let them continue themselves, or check their state after loading and call the appropriate action.
In response to Nadrew
Would that require moving the Train() stuff into a separate proc then, to call if their state is checked and it is STATE_TRAINING?
You could add some kind of override system that will skip the state checks when first being loaded (when manually calling Train())