Re: Embedding Perl into CircleMUD

From: Torgny Bjers (artovil@arcanerealms.org)
Date: 09/08/02


On 02-09-08 08.50, "Patrick Dughi" <dughi@IMAXX.NET> wrote:

>> I am a little way into my scripting language quest, and I just wondered if
>> anybody had already implemented Perl into their CircleMUD, and if said
>> person would be willing to show me some working examples?  I do not need
>> something that patches clean against bpl21 if you know what I mean, just
>> something that I can fiddle with with the help of the Perl/C API and some
>> basic examples and preferably some Perl code that you use to run through the
>> embedded interpreter.
>
>       Oooh, this is so easy to do, and yet, I don't have the time to
> discuss all the little quirks that catch you up.  However, I can give you
> the two pages that got me started on it (I also had a book which covered
> this subject, but it wasn't very indepth, so skip that for now).
>
> http://www.perldoc.com/perl5.6/pod/perlcall.html  and
> http://www.perldoc.com/perl5.6/pod/perlembed.html
>
>       In short, grab a copy of the perl library, perl.h and extern.h
> (erm.. somewhere in the standard perl distribution), and link them in with
> your program using some magic call to ExtUtils::Embed.
>
>       Some of the regex searching using the match(), matches(), and
> substitute() functions from that documentation has come in rather handy.
>
>       In anycase though, you can probably get more examples that are
> clearer than anything I can cut and paste from my own stuff.
>
>       Just be ready to spend a bit of time getting things to
> link/compile correctly, especially if you're using perl code which depends
> on other modules.

Already had that working before I sent the email. :)  What I am particularly
interested is the actual CircleMUD implementation.  In this case, I am going
to use this for our spell system, so I need some sort of design idea on how
to treat the data needed for the Perl-scriped spell code.  For instance, how
would I pass data between the Perl script and Circle?  Those kind of
implementations are what I cannot understand yet.  I mean, I understand how
to pass a Perl sub a set of vars, but I don't really grasp how to get the
things I need from the character/victim/room/object affected by the spell,
and how would I go about sending stuff back to the mud?

For instance, if I wanted to make an affect spell, I suppose that I could
pass the Perl sub an array with vars, then return an array with the affects
in it and use the AV array functions to get the data from the array.  I
could perhaps return an array with all the data, that has a set structure,
that I then parse in the C code.  Uhm.  Or not?

I know that embedded scripting languages are the tabu of the coding world,
and you are not allowed to talk about this by some unwritten law, but help
me out here a little... *cries*

Regards,
/Torgny

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT