Marauroa Core API: Difference between revisions

Content deleted Content added
imported>Hendrik Brummermann
imported>Hendrik Brummermann
Line 101:
</source>
 
These methods add attributes to the RPClass and set their type and visibility. You can also set the parent of this class. Of course, however,classes awithout classparents canare have no parent (bepossible, parentless)too.
 
Once the class has been filled, you can query the data using these methods. These methods alowallow you to get the class name of the class, the the type of an attribute, determine if an attribute exists and to know if that RPClass is a subclass of another.<br>
 
Once the class has been filled, you can query the data using these methods. These methods alow you to get the class name of the class, the the type of an attribute, determine if an attribute exists and to know if that RPClass is a subclass of another.<br>
'''Query''':
<source lang="java">
Line 113 ⟶ 114:
</source>
 
You can query the system classes using these methods. Note that it is '''not''' a good idea to modify them once you are running. The class definitions are send to the client on connect hence if you change the class definitions in the middle of a game you will crash your clients!<br>
 
'''Class wide query''':
<source lang="java">
* '' boolean hasRPClass(String name)''
* '' RPClass getRPClass(String name)''
</source>
 
Line 128 ⟶ 130:
// a general entity with a position
RPClass objclass = new RPClass("entity");
objclass.add("x", RPClass.BYTE);
objclass.add("y", RPClass.BYTE);
 
// an entity specialized in players
objclass = RPClass("player");
objclass.isA("entity");
objclass.add("name", RPClass.SHORT_STRING);
objclass.add("dirdirection", RPClass.SHORT_STRING);
objclass.add("score", RPClass.INT);
objclass.add("super", RPClass.BYTE);
objclass.add("!vdir", RPClass.STRING,RPClass.HIDDEN);
objclass.add("!hdir", RPClass.STRING,RPClass.HIDDEN);
objclass.add("?kill", RPClass.FLAG);
</source>
 
Each time you create a new RPClass, as long as you give it a name ( ie: playerentity, positionplayer, ... ), it will be added to the system list of classes.
 
Notice in the example that the HIDDENhidden attribute must be specified if you want the RPClass to have this property otherwise by default an attribute is visible.
 
Note: You can choose not to use RPClasses in your application BUTbut thethat performanceincreases penalty will be big onnetwork bandwidth and CPU usage.
 
== RPAction ==