How most stuff works
Entities and the events they can trigger *blob*
Stay with me. I am going to show you what that sentence means in this tutor.
Assume there is an entity. For example a func_explosive, like the Wall
in Siwa Oasis. You agree with me that this wall can be destroyed, right?
There you have it already: the entity is the Siwa Oasis wall (the
func_explosive) and the event this entity can trigger is something like
“explode”, or “boom” or “bäääm”.
Luckily (?) the authors of this scripting language did not give it a name like
“boom” or “bäääm” and luckily i was never in that development team when that
language was invented, but you get the drill. In this specific case, instead of
“bäääm”, they gave this event a name like “death”.
So why are entities and events so important for this scripting language? You
might already guessed it: whenever something happens to some entity in your map,
a special code section inside your mapscript will get executed. Of course,
if there is no such a section, nothing gets executed *doh*.
Ok, so far: we know there are entities in your map. And these entities can
trigger events, which in turn can trigger some special code sections in your
mapscript. Your task will be to wire it all up. This requires from you:
1) prepare your entity in Radiant
2) prepare your a special code section inside the mapscript for that entity
In Radiant you simply set a scriptname to an entity. The name (value) of that
scriptname is up to you, i call it “my_herp_derp_entity” for now. That is
already half of the “wiring”. The wire needs to go from your map right into the
mapscript. So far, there is nothing like a mapscript, so we just create one and
place a special code section in it (do not worry how to create a mapscript and
where to put it, this will be explained in the tutorial “first mapscript” and
many more). The special code section will look like this:
And now for events. We already know that there is an event called “death” for
this entity. So we extend the script:
Do you see the comment named “// code”, this is where all your code is. All this
code will get executed when the entity “my_herp_derp_entity” actually gets
blown to pieces AKA it dies.
That’s it. Assume you have another entity, and you want to have it connected to
the mapscript, so what you do is simply give it another scriptname (a unique
one) and go ahead and prepare the special code section for that scriptname in