| 1 | #!/usr/bin/perl | ||
| 2 | package zmptest; | ||
| 3 | #: Version: 1.0 | ||
| 4 | #: Description: An example plugin that shows how to implement ZMP packages | ||
| 5 | #: Author: A S Lewis | ||
| 6 | #: Copyright: This plugin is in the public domain, but you are encouraged to share any modifications | ||
| 7 | # and improvements you make! | ||
| 8 | |||
| 9 | # =-=-=-=-=-=-=-=-=-= | ||
| 10 | # PLUGIN INSTRUCTIONS | ||
| 11 | # =-=-=-=-=-=-=-=-=-= | ||
| 12 | # | ||
| 13 | # This example plugin responds to ZMP commands at imaginary MUD, deathmud.com 6666. You can modify | ||
| 14 | # it to respond to ZMP commands at any real world | ||
| 15 | # | ||
| 16 | # The plugin needs to be loaded before you connect to a real world. Connect to any world in | ||
| 17 | # 'offline' mode, and then type: | ||
| 18 | # | ||
| 19 | # ;addinitialplugin -s | ||
| 20 | # ;save | ||
| 21 | # | ||
| 22 | # A ZMP package called 'axmud' is created every time Axmud starts (before connecting to any world) | ||
| 23 | |||
| 24 | use strict; | ||
| 25 | #use diagnostics; | ||
| 26 | use warnings; | ||
| 27 | |||
| 28 | # Standard BEGIN / END functions | ||
| 29 | BEGIN { | ||
| 30 | |||
| 31 | use Glib qw(TRUE FALSE); | ||
| 32 | |||
| 33 | # Global variables (for the plugin) | ||
| 34 | use vars qw( | ||
| 35 | $PACKAGE | ||
| 36 | ); | ||
| 37 | } | ||
| 38 | |||
| 39 | END {} | ||
| 40 | |||
| 41 | # Create the ZMP package object | ||
| 42 | $PACKAGE = Games::Axmud::Obj::Zmp->new( | ||
| 43 | # ZMP package name | ||
| 44 | 'com.deathmud', | ||
| 45 | # Specify a world profile name, if you want the ZMP package to work only at that world. If you | ||
| 46 | # specify 'undef', it's available for any waold | ||
| 47 | undef, | ||
| 48 | # ZMP commands and the function (in this plugin) that responds to them | ||
| 49 | 'hello', | ||
| 50 | \&hello_world, | ||
| 51 | ); | ||
| 52 | |||
| 53 | # Response functions | ||
| 54 | |||
| 55 | sub hello_world { | ||
| 56 | |||
| 57 | my ($session, $packageCmd, @paramList) = @_; | ||
| 58 | |||
| 59 | $session->writeText('ZMPTEST: ' . $packageCmd . ' ' . join(' ', @paramList)); | ||
| 60 | |||
| 61 | # Axmud expects functions to return some kind of success or failure value. The default is 1 for | ||
| 62 | # success, 'undef' for failure | ||
| 63 | return 1; | ||
| 64 | } | ||
| 65 | |||
| 66 | # Package must return a true value | ||
| 67 | 1 |