> 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
How you would pass data around depends on what your embedding library
provides.
Ideally, you pass data between script and code in a manner similar to
how that data's stored.
Data exchange is actually the hard part -- chances are you need to
create some OO perl structures to pass data back and fourth.
Another possibility is to have C hooks for building the data, in
this example all af_* and make_affect() would be C functions that
map appropriately and handle their arguments:
sub bless_char
{
$x = make_affect(); /* `$x' may very well be a string representation,
holding binary codes organized in a particular
manner that would be meaningful to the data
exchange process but look like hieroglyphics
to a human: it doesn't matter, so long as it
can be interpreted by what needs to read it */
af_set_duration($x, 3);
af_set_location($x, APPLY_HITROLL); /* You probably need to
write a constants.pm file to
include to use things like APPLY_*/
af_set_modifier($x, 3);
af_set_type($x, SPELL_BLESS);
af_affect_to_char($x, shift $_);
}
Chances are though, that your perl embedding library provides a way
to emulate more complex data structures like aggregate structs,
where if you map properly you could have
sub bless_char
{
$ch = shift;
$x->duration = 3;
$x->location = APPLY_HITROLL;
$x->modifier = 3;
$x->type = SPELL_BLESS;
af_affect_to_char($ch, $x, 0, 0);
}
The perl code becomes structurally simpler, except the data exchange
becomes more complex (perhaps especially for things like strings)
-- an advantage of making all changes with individual functions
is that only the data you need to change has to be exchanged
(other than the return of the bits that represent a structure)
-Mysid
--
+---------------------------------------------------------------+
| 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