Hello Plugin World
History Key
- New content
Removed content
Recent Versions
Choose two versions to compare, or click the link to view it.
Here is an example plugin called, Hello Plugin World! This functional plugin helps developers write their very first plugin. It also shows what is mandatory for a plugin to work. These are the bare minimums for a plugin to work.
import orpg.pluginhandler #Mandatory import. This is the Plugin Handler.
import wx #Import wx if you want to create your own menu.
class Plugin(orpg.pluginhandler.PluginHandler):
def __init__(self, plugindb, parent):
orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
self.name = 'Hello Plugin World'
self.author = 'Prof Sir Ebral'
self.help = 'Hello World is a basic Plugin that shows off the ease\n'
self.help += 'at which plugins can be created. The source helps \n'
self.help += 'explain which portions of a plugin are needed for\n'
self.help += 'developers to learn to write their own.'
##All the above material is mandatory. It defines the Plugin Class and then initiates it. The self.name, self.author,
##and self.help assists in defining your plugin.
def plugin_menu(self): #Option Function, though it adds a nice GUI menu
##You can create a menu here.
pass #We are passing this step
def plugin_enabled(self): #Required Function
##You can create text commands here that will enable when the plugin is enabled.
##Other features that are needed when the plugin enables can also be created here.
self.plugin_addcommand('/helloworld', self.on_hello, '- Tell the world Hello Plugin World!')
pass
def plugin_disabled(self): #Required Function
##You will need to disable text commands here.
self.plugin_removecmd('/helloworld')
pass
def on_hello(self, cmdargs):
##We call cmdargs with text commands. This allows us to add arguments to the command.
##cmdargs and how they are used will be covered later.
self.chat.Post('Hello Plugin World!', True, True)