Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Modules: Building blocks for the Daft Adventure

by Masem (Monsignor)
on Jun 12, 2001 at 15:41 UTC ( [id://87774]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub do_stat {
        my ( $dice, $mod ) = @_;
        my $roll = RPG::Dice::roll ( $dice );
        return &$mod( $roll );
    }
    
  2. or download this
    # anonymous function call
    my $roll = do_stat( "3d6", sub { int($_[0]/2)-5; } );
    ...
    # Named function call
    sub modify { int($_[0]/2)-5; }
    my $roll2 = do_stat( "3d6, \&modify );
    
  3. or download this
    my @data = ( { name => 'STR',
                   dice => '3d6',
    ...
        $_->{ roll } = 
            &{ $_->{ modifier } }( RPG::Dice::roll( $_->{ dice } ) );
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://87774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-20 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found