Help-Site Computer Manuals
  Algorithms & Data Structures   Programming Languages   Revision Control
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

link two or more objects together by a signal-relay chain

Games::3D::Link - link two or more objects together by a signal-relay chain


Games::3D::Link - link two or more objects together by a signal-relay chain


        use Games::3D::Thingy;

        use Games::3D::Link;

        # send signal straight through

        my $link = Games::3D::Link->new();

        my $src = Games::3D::Thingy->new();

        my $dst = Games::3D::Thingy->new();

        $src->link ($dst, $link);


Exports nothing on default.


Represents a link between two objects and allows relaying a signal between them.

A link has one (or more) inputs, and one (or more) outputs. Signals are send to the inputs via calling a subroutine (any of on(), off(), flip(), or signal()), and the signal will effect the state of the input. Each input will remember it's state and is per default in the off state.

Each link is by default an OR gate e.g. each incoming signal is relayed instantly to each output.

You can use $link->and_gate(1) to switch the link to the AND gate type.

In this state only when all the inputs are in the the same state, the specified signal (default is the state the inputs are in) is sent to all the outputs.

This means a link acts like an AND gate, only if all the inputs are in the same state, it triggers.



        Games::3D::Link::timer_provider( $class );

You need to call this before any link with delay will work. Pass as argument a classname or an object reference. This works best when you pass an Games::Irrlicht object :)

        my $app = Games::Irrlicht->new();

        Games::3D::Link::timer_provider( $app );

        my $link = Games::3D::Link->new( @options );

Creates a new link.



Returns true if the link is active, or false for inactive. Inactive links will not relay signals, but will still maintain their inputs.



Set the link to the active state. Newly created links are always active.



Set the link to inactive. Newly created ones are always active. Inactive links will not relay signals until they are activated again, but they will maintain their input states properly while inactive.

Return the link's unique id.


        print $link->name();

        $link->name('new name');

Set and/or return the link's name. The default name is the last part of the classname, uppercased, preceded by '#' and the link's unique id.




Put the signal into the link's input. The input can either be an ID, or just the object sending the signal. The object needs to be linked to the input of the link first, by using link(), or add_input().



Registers $object as a valid input source for this link. See also link().

Do not forget to also register the link $link as output for $object via $object-add_output($link);>. It is easier and safer to just use $link-link($src,$dst);>, though.



Registers $object as an output of this link, e.g. each signal the link relays will also be sent to this object. See also link().

Do not forget to also register the link $link as input for $object via $object-add_input($link);>. It is easier and safer to just use $link-link($src,$dst);>, though.



Is a combination of add_input() and add_output(), e.g links the source object via this link to the destination object. If the link was connecting other objects beforehand, these connections will also remain.



Sets the count of how many times the incoming signal is sent out. Default is 1. This acts basically as a multiplier, setting it to 2 will for instance send each incoming signal two times out, with a delay in between. The delay can be set with delay().

Returns the count.


        $link->delay(2000);             # 2 seconds

        $link->delay(1000,500);         # 1 second, and then 1/2 second

        $link->delay(1000,500,200);     # 1s, 1/2s, and both of them with

                                        # randomized by +/- 200 ms

Sets the delay between the receiving of the signal and it's relaying. The default for this is 0. Also sets the delay between each consecutive relay if count() is different than 1. The third parameter is an optional random offset applied to both delays.

Returns a list of (first_delay, resend_delay, random_offset).


        if ($link->once()) { ... }              # return true if one-time link

        $link->once(1);                         # enable one-time sending

        $link->once(0);                         # disable

Sets the one-time flag of the link. If set to a true value, the link will only re-act to the first signal, and then deactivate itself.

If the link is set to send for each incoming signal more than one signal (via delay()), they still will all be sent. Also, each of the outputs of the link will receive the signal. The once flag is only for the incoming signals, not how many go out.

You can enable the link again (with activate(), and it will once more work on one incoming signal.

Default is off, e.g. the link will work on infinitely many incoming signals.

Returns the once flag.


        if (defined $link->fixed_output()) { ... }

        $link->fixed_output(undef);                     # disable

        $link->fixed_output(SIG_ON);                    # always send ON

Get/set the fixed output signal. If set to undef (default), then the input signal will be relayed through (unless invert() was set, which would invert the input before sending it out), if set to a specific value, this set signal will always be sent, regardless of the input signal or the invert() flag.


        $link->and_gate(1) unless $link->and_gate();

Set/get the flag indicating this link is an AND gate.


        $link->invert(1) unless $link->invert();

Set/get the flag indicating this link is inverted.



Unlink all inputs and outputs from the link.



Add a timer to this link. See timer_provider.


(c) 2003, 2004, 2006 Tels <>


the Games::3D::Thingy manpage, the Games::Irrlicht manpage