rpg_get, rpg_set, rpg_verify, rpg_base_classes.module, etc.

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
aaron's picture

The latest commit brings things even closer. Rulesets may be imported from modules now. A new module has been created in the package (RPG Base Classes), separating the base classes from the core module. When attributes are created from these classes, tables are created both to create the new type/attribute combination, and to store data in rpg objects.

  • Number: This will store an integer.
  • Text: This will store a raw text value. Make sure to run through check_plain, etc. before displaying.
  • Boolean: This will store true/false.
  • Array: This will store an array made up of any values.
  • Figured: This will not store any value, and is meant to be processed exclusively with the 'get' function.
  • Node: This will store the nid of a Drupal node object.
  • User: This will store the uid of a Drupal user object.
  • Object: This will store the rid of an RPG object.
  • Object Array: This will store an array made up only of RPG objects.

The following functions are now available for calling & manipulating the values of attributes of rpg objects:

  • rpg_get($object, $property, $arg1, $arg2, ...) -- This returns the value of the object's attribute. It first calls the 'get' function, if that exists for the attribute.
  • rpg_get_raw($object, $property, $arg1, ...) -- This returns the raw value from the database, without calling the 'get' function. This would generally be used only in certain conditions, such as when the 'get' function wants to retrieve a value from the database. (In most cases, when defined, the 'get' function will calculate a value from other values.)
  • rpg_set($object, $property, $value) -- This will set the value of the object's attribute, assuming the 'verify' function (if provided) returns true. If the 'set' function is provided, then it will first process that, setting the value to the return value. It will also flag the value to be saved to the database after page processing.
  • rpg_set_raw($object, $property, $value) -- This will bypass the 'verify' and 'set' functions, directly setting the value. It will also flag the value to be saved to the database.
  • rpg_verify($object, $property, $value) -- This will return the value of the 'verify' function of the type's attribute, or TRUE if not provided. It may be called in certain unique circumstances, when you want to see if a value may be set, but not actually set the value.

Example calls: rpg_get($container, 'may_open', $actor); rpg_set($container, 'open', true); rpg_get($actor, 'health'); rpg_set($sword, 'location', $sheath);

Next on my list is to rework the object creation form to use the new methods for attributes/actions/events.

Aaron Winborn
Drupal RPG, Home of the RPG module.
Spindowners, an upcoming sci-fi RPG being developed with that module.

Games

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week