-
Notifications
You must be signed in to change notification settings - Fork 11
Developing: Items
Reactor 3's engine handles items a tad bit differently depending on their context. I will cover the two main situations in which they are used, along with the general structure of an item.
Like most things in Reactor 3, items are dictionaries with a variety of default keys. Going back a bit, items are actually stored outside of the game itself in JSON files, and are loaded in at runtime. Those familiar with how characters are loaded in can apply the same concepts here, except there is no parsing involved outside of a call to json.loads
. This is because items are far less complex from a structural standpoint and are easier to write in JSON than XML.
This list is constantly growing.
name
: String.
type
: Currently in flux. The general category the item can be put in, like clothing
.
icon
: Character (string of length 1). The graphic displayed on screen.
description
: String. Displayed when the item is examined.
attaches_to
: String. Body parts that the item applies to. Should be in the format of lshoulder|rshoulder
, where |
separates different parts.
flags
: String. Various flags separated by |
. View the items in data/items
for an example of these. They will be documented later.
Please note that some item types expect additional keys from the ones above. These are undocumented until the types are finalized.
Items not belonging to the player are considered to be owned by the world. There is one way to determine this via code in addition to another that involves seeing the items in-game.
-
Probably the quickest way is to run a check for the
id
key. If an item has this key, it belongs to a character. If the item is dropped,id
is deleted. A simple check likeif 'id' in item
will suffice. -
If the item is being drawn on the level, then it has no ID.
Related page: [Developing - Characters (Inventories)](Developing: Items)
When a character receives an item, the id
key is created with a value attributed by the character itself. This value has no meaning outside of serving as a reference in functions related to items. The item can be retrieved by calling character['inventory'][id]
.