Resume, counterintuitively, does not actually save anything itself. It simply relaunches all the applications that were running when you shut your computer down. It's the job of those Lion-compatible applications to restore their windows.
Safe sleep, on the other hand, saves a snapshot of your RAM to your HDD when you put your computer to sleep. In case of power failure, the machine boots from this file on startup.
Safe sleep is the only time (that I know of) that OS X saves its RAM.
You can use the
pmset command line utility (specifically the
sudo pmset -a hibernatemode x command where
x is the sleep mode) to change the sleep mode, although there is no significant benefit in doing this.
The three main different kinds of sleep are as follows (from the
hibernatemode = 0 (binary 0000) by default on supported desktops. The
system will not back memory up to persistent storage. The
system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.
hibernatemode = 3 (binary 0011) by default on supported portables. The system will store a copy of memory to persistent
(the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from
hibernatemode = 25 (binary 0001 1001) is only settable via pmset. The system will store a copy of memory to persistent storage
(the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps,
slower wakes, and better battery life, you should use this setting.
As I stated before, configuring the sleep mode is not recommended (again from the
We do not recommend modifying hibernation settings. Any changes you
make are not supported. If you choose to do so anyway, we recommend
using one of these three settings. For your sake and mine, please
don't use anything other 0, 3, or 25.
I don't know about the script vs. user issue, although I highly doubt there is a difference.