Version 2, last updated by sirebral at Jul 27 02:52 2009 UTC

The plugin for this lesson is Die_Roll_Authenticator

Now, you are probably thinking that the last plugin was going to make every able to max haxxors OpenRPG. On the contrary. The last three functions I introduced to you derive from three main chat features. Here is a run down of what I showed you as extra. 1. pre_parse is the text that comes directly from your chat entry; when you press enter the chat will go through parsing and then you can capture that data in the pre parse function. 2. plugin_incoming_msg is a function that you can use to capture text as it is coming to your software. And idea on how to use this will be presented later, but that will be extra credit. 3. post_msg is a function that posts messages to chat. This function is pretty arbitrary and by passes the parsers, so we want to use this sparingly.

This lesson takes the old Hello World plugin and changes the last three functions and the plugin_enabled function. We use the plugin enabled function to create an object that passes False until the users software goes through the parser. This is key, because in the last plugin the roll did not pass through the parser, but this also shows that we can collect data from outside functions to use internally within ours. '

def plugin_enabled(self):
    self.passed_parse = False
    pass

The next change comes with the last three functions. What we are doing is with these last three functions is changing the object in the pre_parse function, in the event the software goes through that function. `

def pre_parse(self, text):
    self.passed_parse = True
    return text

We are skipping the plugin_incoming_msg function `

def plugin_incoming_msg(self, text, type, name, player):
    return text, type, name

And then we are making some final changes to the post_msg code. These final changes ask the software if the posted message has been parsed, and then asks it to find the [ character within the text string. If the message has not been parsed and contains [, the symbol for a die roll, then the user of the plugin will be given an discreet message that says the die is a Strange Roll! `

def post_msg(self, text, myself):
    text = text.replace('Plugin', '[1d20]')               #You can remove this feature!
    if self.passed_parse == False and text.find('[') > 0: #Checks to see if the data was parsed, 
        self.chat.InfoPost("Strange Roll!")               #and if it contains a die string
    else:
        self.passed_parse = False
    return text

You should now be learning that plugins are easier to modify then you may have at first thought. Plugins draw from the OpenRPG code and can replace the and even re write portions of Core functions. This feature makes OpenRPG adaptable to meet any standards.

To see this plugin in action, you can enable your Hello World plugin, and then use the command. You will see that I have replaced the text 'Plugin' with '[1d20]'. This not only helps trigger the plugin's new feature, but it also shows us that we can actually replace text. If you where so inclined as a developer you could code a plugin that forced die rolls to be re rolled through your parser. Of course this would ensure that users are not cheating as they could have with the Hello World plugin, but it is a draconic action that is a little over board.

Thanks for reading this lesson.