Get id

From Bennu Wiki
Revision as of 03:05, 2 October 2008 by Sandman (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Definition

INT get_id ( <INT processTypeID> )

Returns a ProcessID of a process of the specified ProcessType. On the next call of get_id() in the same process and in the same frame, the next process will be returned of the given type. After a frame statement, get_id() is reset and will return the first process of the given processType. When there are no more processes of a given type, which have not been returned, it will return 0.

get_id(0) returns processes of any type.

Parameters

INT processTypeID - The processTypeID of the processType to get the processes' processIDs of.

Returns

INT : The processID of a process of the given processType.

0 - There are no more processes of the given processType, which have not been returned.
>0 - The processID of a process of the given processType.

Example

Program example;
Begin
    signaltype(type Monkey,s_kill);
End

/**
 * Empty process
 */
Process Monkey()
Begin
End

/**
 * Signals every process of type 't' the signal 'signal'.
 */
Function int signaltype(int t, int signal)
Begin
    while( (x=get_id(t)) ) // while there is an unprocessed process left and store that in 'x'
        signal(x,signal); // signal the process with processID 'x'.
    end
End

// Of course, the very observant of you already noticed that signaltype(my_type,my_signal)
// does the same thing as the function signal(my_type,my_signal), but this is just to
// illustrate the workings.

/**
 * Signals every process the signal 'signal'.
 */
Function int signalall(int signal)
Begin
    while( (x=get_id(0)) ) // while there is an unprocessed process left and store that in 'x'
        signal(x,signal); // signal the process with processID 'x'.
    end
End

// get_id(0) returns a process of any type. This is a possible implementation of a
// function which signals all existing processes. Note that this can be dangerous to use,
// as in some cases you might want one or two processes to stay alive.

Used in example: signal()


Processinteraction Functions
Advance()Collision()Collision_box()Collision_circle()Exists()Get_angle()Get_dist()Get_id()Get_real_point()Get_status()Let_me_alone()Signal()Signal_action()Xadvance()