Skip to content

Randomly Selecting Devices

MinLL edited this page Aug 15, 2014 · 1 revision

The following functions will prove useful to your mod, if you provide devices that you wish for other mods to incorporate, or if you wish to draw randomly from a pool of all available devices.

Function RegisterGenericDevice(Armor inventoryDevice, String tags)

Registers a generic device to be used with tag and random item searches. If you have any items to include, the registration is best done in your mods version update scripts. If your item has been registered before, registering it again will overwrite any old tags, so they can be changed if needed.

Params:

  • Armor inventoryDevice - the inventory item to register
  • String tags - comma separated list of tags to include with the item
Armor Function GetGenericDeviceByKeyword(Keyword kw)

Returns a random device with the given keyword. The returned device can be from any mod that has registered its devices and the device is safe to manipulate with the generic functions.

Example: GetGenericDeviceByKeyword(zad_DeviousBelt) - Returns any generic chastity belt

Armor Function GetDeviceByTags(Keyword kw, String tags, bool requireAll = true, String tagsToSuppress = "", bool fallBack = true)

Returns a random device with the given keyword and given tags. Returns Armor if item was found, or none if no items was found.

Params:

  • keyword kw - keyword for the item type you want to fetch
  • String tags - comma separated list of all the tags you want to search by
  • bool requireAll - If true, all the tags in the previous param are require to be on the returned item. With false, only one tag of the given list is enough. Defaults to true.
  • String tagsToSuppress - Comma separated list of tags you DO NOT want to appear on the returned item. Only one tag of these is enough to exclude the item.
  • bool fallBack - If true, will return a completely random item with GetGenericDeviceByKeyword if the tag search fails to produce results. If false, will return none if tag search fails. Defaults to true.

Example usage:

GetDeviceByTags(zad_DeviousGag, "ebonite,white", true, "panel") - Fetches a gag with the tags "ebonite" and "white", requiring both tags to be on the item. Excludes gags with the tag "panel". FallBack defaults to true so if the user doesn't have any matching items (DDx isn't installed), will return a completely random item from the installed ones. If DDx is installed, will return either White ebonite ring or White ebonite ball gag.

bool Function HasTag(Armor item, String tag)

Checks if the given item has the given tag on it, returns true if the tag was found

Usage: HasTag(Armor device, String tag) Return true if the given tag was found on the item. False otherwise.

Params:

  • Armor device - Inventory item to check for the tag
  • String tag - Single tag as a string to check for
bool Function HasTags(Armor item, String[] tags, bool requireAll = true)

Checks if the given item has the given tags on it, returns true or false.

Params:

  • Armor item - The inventory item to check for the tags
  • String[] tags - String array of tags to check for, where each index is one tag.
  • bool requireAll - If true, all the given tags need to be found on the item to return true. If false, only one found tag is enough to return true. Defaults to true.