Marauroa Core API: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Hendrik Brummermann |
imported>Hendrik Brummermann |
||
| Line 101: | Line 101: | ||
</source> |
</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 |
These methods add attributes to the RPClass and set their type and visibility. You can also set the parent of this class. Of course classes without parents are possible, too. |
||
| ⚫ | |||
| ⚫ | |||
'''Query''': |
'''Query''': |
||
<source lang="java"> |
<source lang="java"> |
||
| Line 113: | Line 114: | ||
</source> |
</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! |
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! |
||
'''Class wide query''': |
'''Class wide query''': |
||
<source lang="java"> |
<source lang="java"> |
||
boolean hasRPClass(String name) |
|||
RPClass getRPClass(String name) |
|||
</source> |
</source> |
||
| Line 128: | Line 130: | ||
// a general entity with a position |
// a general entity with a position |
||
RPClass objclass = new RPClass("entity"); |
RPClass objclass = new RPClass("entity"); |
||
objclass.add("x",RPClass.BYTE); |
objclass.add("x", RPClass.BYTE); |
||
objclass.add("y",RPClass.BYTE); |
objclass.add("y", RPClass.BYTE); |
||
// an entity specialized in players |
// an entity specialized in players |
||
objclass = RPClass("player"); |
objclass = RPClass("player"); |
||
objclass.isA("entity"); |
objclass.isA("entity"); |
||
objclass.add("name",RPClass.SHORT_STRING); |
objclass.add("name", RPClass.SHORT_STRING); |
||
objclass.add(" |
objclass.add("direction", RPClass.SHORT_STRING); |
||
objclass.add("score",RPClass.INT); |
objclass.add("score", RPClass.INT); |
||
objclass.add("super",RPClass.BYTE); |
objclass.add("super", RPClass.BYTE); |
||
objclass.add("!vdir",RPClass.STRING,RPClass.HIDDEN); |
objclass.add("!vdir", RPClass.STRING,RPClass.HIDDEN); |
||
objclass.add("!hdir",RPClass.STRING,RPClass.HIDDEN); |
objclass.add("!hdir", RPClass.STRING,RPClass.HIDDEN); |
||
objclass.add("?kill",RPClass.FLAG); |
objclass.add("?kill", RPClass.FLAG); |
||
</source> |
</source> |
||
Each time you create a new RPClass, as long as you give it a name ( |
Each time you create a new RPClass, as long as you give it a name (ie: entity, player, ... ), it will be added to the system list of classes. |
||
Notice in the example that the |
Notice in the example that the hidden 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 |
Note: You can choose not to use RPClasses in your application but that increases network bandwidth usage. |
||
== RPAction == |
== RPAction == |
||