Update of /cvsroot/net-script/netscript2/docs/netscript/src
In directory sc8-pr-cvs1:/tmp/cvs-serv4593
Added Files:
ExampleLibrary.pm
Log Message:
--- NEW FILE: ExampleLibrary.pm ---
#--------------------------------------------------------
# $Id: ExampleLibrary.pm,v 1.1 2002/12/04 19:24:25 derkork Exp $
#
# NetScript and all related materials, such as documentation,
# are protected under the terms and conditions of the Artistic License.
# (C) 2000-2002 by Jan Thomä, insOMnia
# mailto: ko...@in...
#--------------------------------------------------------
use strict;
#/**
# This is an example for a simple library. It just adds the
# $(EXAMPLE)-variable to the global namespace. This variable
# holds the string "This is an example." Libraries
# generally should not import themselves or depend on each other.
# They should just import the core classes, provided with the
# interpreter and classes, which are shipped with the library.
#*/
package Examples::ExampleLibary;
use base qw(NetScript::Libraries::Library);
use NetScript::Interpreter;
#/**
# Ctor.
# @public
#*/
sub new {
my $proto = shift; # get Prototype
my $class = ref($proto) || $proto;
my $this = $class -> SUPER::new();
$this;
}
sub init {
my ($this, $interpreter) = @_;
$this -> SUPER::init( $interpreter );
# register the variable
$this -> interpreter() -> getState() ->
setVariableValue( "EXAMPLE", "This is an example." );
}
1; #make require happy
|