GM: event perform

From GMpedia.org Wiki

Jump to: navigation, search
The correct title of this article is event_perform(type,num). It appears incorrectly here because of technical restrictions.
The correct title of this article is event_perform(). It appears incorrectly here because of technical restrictions.


Arguments

type = One of 11 events that you can see in the window that pops up if you click on "Add Event" in an object. numb = One of those events that is listed under each single "type".

Limitations

none

Note: Please remove limitations and port them in the "Remarks" section at the end of the article.

So that function performs whatever code and/or Drag and Drop Actions that exist in another event. Which event is indicated by the arguments "type" and "numb".

event_perform(ev_create,0);

If you click on "Add Event", then click on the "type" called "keyboard" you will now see a long list of keyboard events. Each one is a "numb". Another example: Click on "Add Event" and then click on "Create" (like the above example indicates). This time there is NO list popping up, because there is only 1 kind of create event. In this case "numb" is zero.

In order to apply the function you need to know what are the codes for "types" and "numbs".

There are 11 types:

  • ev_create
  • ev_destroy
  • ev_step
  • ev_alarm
  • ev_keyboard
  • ev_mouse
  • ev_collision
  • ev_other
  • ev_draw
  • ev_keypress
  • ev_keyrelease

So one of those is applied as the first argument in the function event_perform(type,numb).

For the second argument "numb" there are these possibilities:

If the type is "ev_create", "ev_destroy", "ev_collision" or "ev_draw" then "numb" is 0.

If the type is "ev_alarm" then "numb" is simply the number of the alarm event.

If the type is "ev_step", "ev_mouse" or "ev_other" then "numb" is one of the constants you can find in this chapter in the help file: The Game Maker Language (GML) > Game play > Generating events


If the type is "ev_keyboard", "ev_keypress" or "ev_keyrelease" then "numb" is one of the constants for vi

This article was originally found at the Game Maker Knowledge Base, contributed by Weird Dragon.
See the talk page for details
Personal tools