Marauroa Core API: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Hendrik Brummermann |
imported>Hendrik Brummermann |
||
| Line 156: | Line 156: | ||
== RPObject and RPSlot == |
== RPObject and RPSlot == |
||
RPObjects are the containters of data in Arianne. An RPObject is an |
RPObjects are the containters of data in Arianne. An RPObject is an Attributes element with a list of RPSlots attached. |
||
RPSlots are slots on objects that items can be placed on/in, such as backpacks, pockets, boxes, ...<br> |
|||
RPSlots are slots owned by an RPObject into which other RPObjects can be placed (like items in a backpack) |
|||
The methods of the RPObject to modify slots are: |
The methods of the RPObject to modify slots are: |
||
<source lang="java"> |
|||
public void addSlot(RPSlot slot) |
|||
* ''RPSlot getSlot(String name)'' |
|||
public RPSlot getSlot(String name) |
|||
public void removeSlot(String name) |
|||
public boolean hasSlot(String name) |
|||
public Iterator slotIterator() |
|||
</source> |
|||
The above methods are used to add a slot to the object, retrieve it, remove it and test if the slot exists. Finally the slot iterator is used to visit all the slots in the object. |
The above methods are used to add a slot to the object, retrieve it, remove it and test if the slot exists. Finally the slot iterator is used to visit all the slots in the object. |
||
<source lang="java"> |
|||
public RPObject.ID getID() |
|||
</source> |
|||
This is a helper method to get the unique ID of the object. |
This is a helper method to get the unique ID of the object. |
||
RPSlot |
RPSlot has a simple API: |
||
<source lang="java"> |
|||
* void add(RPObject object) |
|||
public void add(RPObject object) |
|||
public RPObject get(RPObject.ID id) |
|||
public boolean has(RPObject.ID id) |
|||
public RPObject remove(RPObject.ID id) |
|||
public void clear() |
|||
| ⚫ | |||
</source> |
|||
The clear() method removes all the objects in the slot. |
|||
| ⚫ | |||
| ⚫ | |||
<source lang="java"> |
|||
| ⚫ | |||
</source> |
|||
It is used to visit all the objects of the slot. |
It is used to visit all the objects of the slot. |
||
<source lang="java"> |
|||
<pre> |
|||
// create an object of RPClass player and set some attribute values |
|||
object |
RPObject object = new RPObject("player"); |
||
object.put(" |
object.put("name", "example"); |
||
| ⚫ | |||
// create a slot called backpack |
|||
RPSlot slot = new RPSlot("backpack"); |
|||
| ⚫ | |||
| ⚫ | |||
object.addSlot(slot); |
object.addSlot(slot); |
||
</pre> |
|||
// create an object of RPClass "coin" and put it into the slot |
|||
RPObject coin = new RPObject("coin"); |
|||
| ⚫ | |||
</source> |
|||
Now for the complex part. Where it all becomes a little nuts!: IRPZone and IRPRuleProcessor interfaces |
Now for the complex part. Where it all becomes a little nuts!: IRPZone and IRPRuleProcessor interfaces |
||