vp_double

From Virtual Paradise Wiki
Revision as of 20:29, 14 December 2016 by Sleepy E (talk | contribs) (Basic layout)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Method call snippet vp_double(instance, attr);

Return the value of a floating point attribute (with double-precision)

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
vp_float_attribute_t
attr
Attribute to return value of (defined in VP.h)

Returns

The value of the attribute.

Behavior

If an invalid identifier is passed for attr, then 0 will be returned.

Caveats

There is no way to know if the call was unsuccessful, use vp_double_get() when this is required.

Examples

void handle_avatar_add(VPInstance sdk)
{
  double x, z;

  x = vp_double(sdk, VP_AVATAR_X);
  z = vp_double(sdk, VP_AVATAR_Z);

  // If an avatar appears at roughly 0X 0Z (at any height), then send a welcome message.
  if (x > -0.5 && x < 0.5 && y > -0.5 && y < 0.5)
  {
    char msg[256];

    sprintf(msg, "Welcome %s to the world!", vp_string(sdk, VP_AVATAR_NAME));
    vp_say(sdk, msg);
  }
}

int main(int argc, const char* argv[])
{

  //...

  vp_event_set(sdk, VP_EVENT_AVATAR_ADD, handle_avatar_add);

  //...
}

See also