… | |
… | |
808 | } |
808 | } |
809 | |
809 | |
810 | wantarray ? @res : $res[0] |
810 | wantarray ? @res : $res[0] |
811 | } |
811 | } |
812 | |
812 | |
|
|
813 | =item cf::register_script_function $function => $cb |
|
|
814 | |
|
|
815 | Register a function that can be called from within map/npc scripts. The |
|
|
816 | function should be reasonably secure and should be put into a package name |
|
|
817 | like the extension. |
|
|
818 | |
|
|
819 | Example: register a function that gets called whenever a map script calls |
|
|
820 | C<rent::overview>, as used by the C<rent> extension. |
|
|
821 | |
|
|
822 | cf::register_script_function "rent::overview" => sub { |
|
|
823 | ... |
|
|
824 | }; |
|
|
825 | |
|
|
826 | =cut |
|
|
827 | |
813 | sub register_script_function { |
828 | sub register_script_function { |
814 | my ($fun, $cb) = @_; |
829 | my ($fun, $cb) = @_; |
815 | |
830 | |
816 | no strict 'refs'; |
831 | no strict 'refs'; |
817 | *{"safe::$fun"} = $safe_hole->wrap ($cb); |
832 | *{"safe::$fun"} = $safe_hole->wrap ($cb); |