-
Notifications
You must be signed in to change notification settings - Fork 0
Events selectors
Sometimes, it happens that we want to apply an action on specific events at run. For instance, we would like the events n°1 and n°2 to jump when we click on them.
It is obviously possible to do such a thing with conditions; however, all commands that are doing actions on an event can, instead of taking their ID (and thus being applied on only one event), take a particular construction which is called a selector.
Let's take this command, for instance:
Returns true if the mouse click one of the events of the given selector.
Name|Type|Description --- | --- | ---
events
|Selectors
|Events' selector
This command returns true
if the mouse has clicked on the event given as argument, right when the command is called. This expression is totally valid: mouse_click_event?(1)
and will return true
if a mouse's click has occured on the event n°1 (false
otherwise).
Now, let's suppose that we want to perform the same action (so, knowing if we have clickedà on event n°1, n°2 or n°3 ? You will probably say that this is an easy thing and that we could do something like that: If Script : mouse_click_event?(1) OR mouse_click_event?(2) OR mouse_click_event?(3)
but this is not quite handy. In order to specify all the events on which we want to apply a peculiar action, we can pass more than an integer as the events
argument (Yes, the integer is the most primitive selector).
Beyong the use of an integer to reference an event, we have the Product
selector. With it, we can select a list of events: events(id1, id2, etc.)
. We can give it an infinite list of events and it will only take the ones which are truely existing. From that moment on, if we want to know if the event n°1, n°2 or n°3 and also the hero (event n°0) has been clicked on, we could use this selector: events(1, 2, 3, 0)
; which will result in the end in this: mouse_click_event?(events(1, 2, 3, 0))
.
The simple selector forces you to clearly specify all the IDs on which you want to perform an action. But is also possible to generate selector, just like that: events{|id| generator}
. For instance, in order to generate a selector containing all the events whose ID is above ten: events{|id| id > 10}
. It is also possible to bind the generator's condition with logical operators; for instance: events{|id| id > 15 and id < 100}
will provide an events' selector whose events'ID is greater than 15 and less than 100.
Obviously, you can use RME commands inside a selector's generator. For instance: events{|id| event_x(id) > 14 and event_y(id) > player_y}
, will generate a selector of events whose X position is greater than 14 and which are located under the hero.
It is possible to both select and combine, for instance: events(1,2,3){|id| event_x(id) > 15}
, will produce a selector containing the events n°1, n°2 and n°3 but also every events whose X coordinate is greater than 15.
It is also possible to create easily a selector which contains all the events and the hero. One way of doing such a thing woukd be: events{|id| id >= 0} in order to take all events whose ID is greater than or equal to 0. However, there is an handier selector:
all_eventsor
events(:all_events)`. We better use the first one.
There are two selectors which return only one event found in the events' list: once_events{|id| generator}
which will return the ID of the first corresponding event; and once_random_event{|id| generatorr}
which will return an event's ID randomly taken from the events corresponding tothe generator. For those two commands, if no event fits the selector, they will return nil
.
Sometimes, generators take too much events and we would like to exclude some of them. In order to do that, we can use the not
keyword. For instance: all_events.not(0)
will return a selector containing all events excepting the hero's one. Just as simple selectors, we can pass an infinity of identifiers to not
. For instance: events{|id| id%2 == 0}.not(2, 4, 16, 38)
is a selector which will take all event whose ID is an even number excepting 2
, 4
, 16
and 38
.
The not
method can also exclude with an exclusions' generator. For instance: all_events.not{|id| event_x(id) < player_x}
is a selector which will take all the events, excepting the one which are located at hero's left.
And as for simple generators, it is also possible to combine an event's list with a generator. For instance: all_events.not(0){|id| id > 13}
. (If you still don't understand this one, you better read once more this page !)
This command does not work on single selectors !
Usually, it happens that selectors become "huge" (because we want to filter events), don't hesitate to store them in variables. For instance:
# A selector containing all events which are
# located on the same vertical axes as the hero
# and whose identifier is an odd number
V[1] = events{ |id|
(event_y(id) == player_y) and (id%2 != 0)
}.not(0)
Introduction
Revised Syntax
- Switches and variables
- Local switches and local variables
- Tags and local tags
- Displaying informations in messages
Commands
Extended events
Advanced tools
RMEx use examples
- Create basic gauges
- Create gauges in battle
- Create easily a QuickTime Event
- A minimal multi-agents system
- Custom names typing system
- Titlescreen's skipper
Scripters corner