## LSL Wiki : energy

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org

## Energy

An object's energy, as reported by llGetEnergy, is quite distinct from the RL physics definition of energy. SL energy is actually a throttle on how effectively scripts can change the motion of physical objects. The energy of an object ranges from 0.0 to 1.0. If an object's energy is 1.0, LSL functions that attempt to change the object's motion will have their full effect. If the energy of the object is 0, the same functions will have no effect. Intermediate energy values give intermediate effects.

An object gains energy through a stipend, which it earns merely by existing in the rezzed state. An object expends energy when scripts call functions to change its motion. SL's energy was implemented to limit the amount scripts can use certain dynamics functions.

Each time an object is rezzed, or its mass is changed (like by changing its size or shape), its energy is reset to 0.

#### Earning Energy

While rezzed, an object is credited with energy at a rate that is determined by its mass. The more massive the object is, the slower it earns energy. Specifically, the energy stipend is 200/mass units of energy per second. When an object's energy reaches 1.0, the stipend is suspended until the energy falls below 1.0.

#### Expending Energy

The following functions immediately reduce the amount of energy of the object running the script:

llApplyImpulse
llApplyRotationalImpulse
llPushObject

For the first two, the amount of energy expended is the magnitude of the impulse vector divided by 20,000. For llPushObject, it is the sum of the expenditures due to the two impulse vectors. Note: for llPushObject, the object being pushed does not lose energy.

These functions also reduces the amount of energy of the object being affected:

llMoveToTarget
llRotLookAt
llLookAt
llSetForce
llSetTorque
llSetForceAndTorque
llSetHoverHeight
llGroundRepel
llSetBuoyancy

The amount of energy used by calls to these functions is affected by the mass of the object in question. The different functions also seem to have varying levels of efficiency. Some tasks take more energy for a given mass than others. Persistent functions like llSetBuoyancy and llMoveToTarget constantly use energy and will not function if the mass of the object is above a limit determined by the rate of recharge vs. the efficiency of the function. Smaller objects (those with lesser mass) gain energy quicker.

The energy an object has can be determined by calling llGetEnergy.

Q: Is it by object or by prim?
A: The root prim has the combined energy of all the child prims and its own, as it does with mass. Scripts in child prims will reflect the energy of that prim, same with mass.