LEGO::NXT::Manual::Plugins - Using and creating plugins for LEGO::NXT.
Plugins are useful for when you are writing a script and you need to add some extra functionality to your LEGO::NXT object.
To use a plugin all you have to do is pass the plugin's name, minus the LEGO::NXT:: bit, to the use statment. So, for example, if you wanted to use the LEGO::NXT::Scorpion plugin you would:
use LEGO::NXT qw( Scorpion );
This then extends the LEGO::NXT class to have all of the methods of the LEGO::NXT::Scorpion class.
None at the moment!
Writing your own plugin is very simple. Just write a standard perl class, there are no requirements. Likely you will want to "use base(LEGO::NXT);" and/or one of the existing plugins.
A good way to get started is to look at the source of an existing plugin.
Rather than using the plugin system you could instead subclass LEGO::NXT and whatever other modules you want. This gives you the ability to add your own custom methods to the LEGO::NXT object that apply only to your particular situation.
package MyNXT; use base qw( LEGO::NXT LEGO::NXT::Scorpion ); use LEGO::NXT::Constants; ... 1;
Then in your script:
use MyNXT; my $nxt = MyNXT->new();
Aran Deltac <email@example.com>