Vp int get: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
Sleepy E (talk | contribs)
Basic layout
 
Sleepy E (talk | contribs)
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{sdk method page|int|Retrieve an integer attribute.
{{sdk method page|int_get|Return the value of an integer attribute.
|paramex=attr, value
|paramex=attr, value
|parameters=
|parameters=
   {{sdk parameter row|vp_int_attribute_t|attr  |Attribute to return}}
   {{sdk parameter row|vp_int_attribute_t |attr  |Attribute to return value of (defined in VP.h)}}
   {{sdk parameter row|int*             |value |Returns the value}}
   {{sdk parameter row|int*               |value |Returns the value}}
|returncodes=
|returncodes=
   {{sdk return code row|NO_SUCH_ATTRIBUTE  |Invalid attribute}}
   {{sdk return code row|NO_SUCH_ATTRIBUTE  |Invalid attribute}}
|behavior=If an invalid value is passed for attr, then value is not modified.
|behavior=If unsuccessful, then value is not modified.
|caveats=
|caveats=
|examples=
|examples=
<syntaxhighlight lang="c">
int my_owner(VPInstance sdk)
{
  int rc, owner;
  rc = vp_int_get(sdk, VP_MY_USER_ID, &owner);
  if (rc)
    return -1;
  return owner;
}
</syntaxhighlight>
|seealso=
|seealso=
* {{sdk method|int}}
* {{sdk method|int}}
* {{sdk method|int_set}}
* {{sdk method|int_set}}
}}
}}

Latest revision as of 20:12, 12 December 2016

Method call snippet vp_int_get(instance, attr, value);

Return the value of an integer attribute.

Parameters

These are the parameters that this method requires:

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

Returns

This method returns a return code integer, which indicates whether the call was successful or errored for any reason:

Return code Cause
VP_RC_SUCCESS Successful call (for methods that have a registered callback, it only means the request has been sent)
VP_RC_NO_SUCH_ATTRIBUTE Invalid attribute

Behavior

If unsuccessful, then value is not modified.

Examples

int my_owner(VPInstance sdk)
{
  int rc, owner;

  rc = vp_int_get(sdk, VP_MY_USER_ID, &owner);
  if (rc)
    return -1;

  return owner;
}

See also