Trigger Events Between Levels: Difference between revisions
Speedvoltage (talk | contribs) mNo edit summary |
No edit summary |
||
(13 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{LanguageBar}} | |||
== Introduction == | == Introduction == | ||
{{Note|This article is for singleplayer, as multiplayer games do not handle [[trigger_changelevel]]. For round based multiplayer games, you may change the nature of the next round using the same entity. See [[#External | {{Note|This article is for singleplayer, as multiplayer games do not handle [[trigger_changelevel]]. For round based multiplayer games, you may change the nature of the next round using the same entity. See [[#External links|External links]] at the bottom for more information.}} | ||
As levels become more complex, you may be unable to create a sequence where, for example, a button toggles a light due to engine limits. However, this doesn't mean it isn't possible to have an activator trigger an event in another map. | As levels become more complex, you may be unable to create a sequence where, for example, a button toggles a light due to engine limits. However, this doesn't mean it isn't possible to have an activator trigger an event in another map. | ||
{{Note|This article assumes you know how to set up level changes.}} | {{Note|This article assumes you know how to set up level changes.}} | ||
Line 6: | Line 7: | ||
== Single Use Env_Global == | == Single Use Env_Global == | ||
This first section highlights how to create an [[env_global]] that can be fired once only after being activated by an activator, which will be a [[func_button|button]] in this article. | This first section highlights how to create an [[env_global]] that can be fired once only after being activated by an activator, which will be a [[func_button|button]] in this article. | ||
{{Note|An env_global holds information that can be transferred to the next map transition or even after 15 map transitions. It doesn't matter. This is how the [[Half-Life 2]] [[mod]] [https://www.moddb.com/mods/underhell Underhell] handles the number of cards you have picked up (it makes use of the env_global's counter feature as well, | {{Note|An env_global holds information that can be transferred to the next map transition or even after 15 map transitions. It doesn't matter. This is how the [[Half-Life 2]] [[mod]] [https://www.moddb.com/mods/underhell Underhell] handles the number of cards you have picked up (it makes use of the env_global's counter feature as well, however, its code has been modified to include new I/O information.}} | ||
=== The Maps Setup === | === The Maps Setup === | ||
[[ | [[File:Map 1 Setup.png|thumb|250px|right|First Map Entity Setup.]] | ||
[[ | [[File:Globals_Entity_Setup.png|thumb|250px|right|Second Map Entity Setup.]] | ||
[[ | [[File:Env global State.png|thumb|250px|right|Env_global settings. They are identical in both maps.]] | ||
==== First Map - Entity Setup ==== | ==== First Map - Entity Setup ==== | ||
Line 20: | Line 21: | ||
{{Note|You do not have to choose from the drop down list. The <code>Global State To Read</code> can be anything, i.e. you can type anything in it. It is best to keep it simple and organized.}} | {{Note|You do not have to choose from the drop down list. The <code>Global State To Read</code> can be anything, i.e. you can type anything in it. It is best to keep it simple and organized.}} | ||
*(Optional) A [[game_text]] named <code>text_button_on</code> to check the env_global's state | *(Optional) A [[game_text]] named <code>text_button_on</code> to check the env_global's state | ||
{{Note|Use the console command <code>developer 4</code> if you want to print out entity information (such as outputs being called, etc.) and other meaningful information. The game_text entity is simply used to print text seperately from the <code>developer</code> console command so that if your map has complex I/O sequences spamming (such as [[logic_timer]] and [[logic_case]] entities), the game_text makes it easier.}} | |||
Line 27: | Line 29: | ||
*A [[logic_auto]] - with a <code>Global State To Read</code> set to <code>turn_on_light</code> (it must be the same as the env_global's) | *A [[logic_auto]] - with a <code>Global State To Read</code> set to <code>turn_on_light</code> (it must be the same as the env_global's) | ||
*The entity you want to fire (in this example - a [[light]] named <code>red</code>) | *The entity you want to fire (in this example - a [[light]] named <code>red</code>) | ||
Line 42: | Line 42: | ||
! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnPressed || light_global || TurnOn || <none> || 0.00 || Yes | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnPressed || !self || Lock || <none> || 0.01 || Yes | ||
|} | |} | ||
Line 53: | Line 53: | ||
! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnPressed || text_button_on || Display || <none> || 0.00 || Yes | ||
|- | |- | ||
|} | |} | ||
Line 66: | Line 66: | ||
! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnMapSpawn || red || TurnOn || <none> || 0.00 || Yes | ||
|} | |} | ||
{{bug|hidetested=1|Avoid using <code>OnMapTransition</code> with the logic_auto as crashing during a transition will cause problems when reloading a save.}} | |||
And that's it. If the button isn't pressed, the light will be off in the next level. As soon as it is pressed, the light will be turned on. | And that's it. If the button isn't pressed, the light will be off in the next level. As soon as it is pressed, the light will be turned on. | ||
Line 76: | Line 77: | ||
==== First Map - Entity Setup ==== | ==== First Map - Entity Setup ==== | ||
[[ | [[File:MultiUseGlobals.png|thumb|250px|right|First Map Entity Setup.]] | ||
[[ | [[File:Multi-Use_Env_Global's_Logic_Auto.png|thumb|250px|right|Second Map Entity Setup.]] | ||
In the first map, you need: | In the first map, you need: | ||
Line 91: | Line 92: | ||
*2 logic_auto entities: | *2 logic_auto entities: | ||
**The first one with a <code>Global State To Read</code> set to <code>turn_on_light</code> (it must be the same as the first env_global | **The first one with a <code>Global State To Read</code> set to <code>turn_on_light</code> (it must be the same as the first env_global in the first map) | ||
**The second one with a <code>Global State To Read</code> set to <code>turn_off_light</code> (it must be the same as the second env_global | **The second one with a <code>Global State To Read</code> set to <code>turn_off_light</code> (it must be the same as the second env_global in the first map) | ||
*The entity you want to fire (in this example - a light named <code>red</code>) | *The entity you want to fire (in this example - a light named <code>red</code>) | ||
Line 107: | Line 105: | ||
! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnPressed || light_global || TurnOn || <none> || 0.00 || No | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnPressed || light_global_off || TurnOff || <none> || 0.00 || No | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnPressed || text_button_on || Display || <none> || 0.00 || No | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnPressed || !self || Lock || <none> || 0.01 || No | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnUseLocked || light_global_off || TurnOn || <none> || 0.00 || No | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnUseLocked || light_global_on || TurnOff || <none> || 0.00 || No | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnUseLocked || text_button_off || Display || <none> || 0.00 || No | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnUseLocked || !self || Unlock || <none> || 0.01 || No | ||
|} | |} | ||
Line 133: | Line 131: | ||
! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnMapSpawn || red || TurnOn || <none> || 0.00 || No | ||
|} | |} | ||
Line 143: | Line 141: | ||
! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || OnMapSpawn || red || TurnOff || <none> || 0.00 || No | ||
|} | |} | ||
And that's all there is to it. | And that's all there is to it. | ||
== External links == | |||
== External | |||
Multiplayer - [https://www.youtube.com/watch?v=HjQUUPkfqDA Change The Nature Of Next Round] | Multiplayer - [https://www.youtube.com/watch?v=HjQUUPkfqDA Change The Nature Of Next Round] | ||
==See | ==See also== | ||
* [[Env_global]] | * [[Env_global]] | ||
* [[Logic_auto]] | * [[Logic_auto]] | ||
[[Category:Level Design | [[Category:Level Design]] |
Latest revision as of 04:42, 27 June 2025
Introduction

As levels become more complex, you may be unable to create a sequence where, for example, a button toggles a light due to engine limits. However, this doesn't mean it isn't possible to have an activator trigger an event in another map.

Single Use Env_Global
This first section highlights how to create an env_global that can be fired once only after being activated by an activator, which will be a button in this article.

The Maps Setup
First Map - Entity Setup
In the first map, you need:
- An activator (in this example - a button named
button
with a delay before reset set to-1
andDon't Move
set inFlags
) - An env_global named
light_global
- with aGlobal State To Read
set toturn_on_light

Global State To Read
can be anything, i.e. you can type anything in it. It is best to keep it simple and organized.- (Optional) A game_text named
text_button_on
to check the env_global's state

developer 4
if you want to print out entity information (such as outputs being called, etc.) and other meaningful information. The game_text entity is simply used to print text seperately from the developer
console command so that if your map has complex I/O sequences spamming (such as logic_timer and logic_case entities), the game_text makes it easier.
Second Map - Entity Setup
In the second map, you need:
- A logic_auto - with a
Global State To Read
set toturn_on_light
(it must be the same as the env_global's) - The entity you want to fire (in this example - a light named
red
)
The Input/Output Setup
First Map - Outputs
Open the activator (the button here) that will fire the env_global.
My Output > Target Entity Target Input Parameter Delay Only Once OnPressed light_global TurnOn <none> 0.00 Yes OnPressed !self Lock <none> 0.01 Yes
If you are using a game_text, fire it as well as you enable the env_global. Remember that the game_text is only used for debugging purposes. Remove it before shipping your level.
My Output > Target Entity Target Input Parameter Delay Only Once OnPressed text_button_on Display <none> 0.00 Yes
Second Map - Outputs
Open the logic_auto that will fire the entity or sequence (the light here).
My Output > Target Entity Target Input Parameter Delay Only Once OnMapSpawn red TurnOn <none> 0.00 Yes

OnMapTransition
with the logic_auto as crashing during a transition will cause problems when reloading a save.And that's it. If the button isn't pressed, the light will be off in the next level. As soon as it is pressed, the light will be turned on.
Multiple Use Env_Global
Let's say we want the light to be toggled on and off when pressing the button. It requires a little more setup, but the process is fairly easy.
First Map - Entity Setup
In the first map, you need:
- An activator (in this example - a button named
button
with a delay before reset set to-1
andToggle
andDon't Move
set inFlags
) - 2 env_global entities:
- The first one named
light_global
- with aGlobal State To Read
set toturn_on_light
- The second one named
light_global_off
- with aGlobal State To Read
set toturn_off_light
- The first one named
- (Optional) 2 game_text entities to check the env_global entities state
- The first one named
text_button_on
- The second one named
text_button_off
- The first one named
Second Map - Entity Setup
- 2 logic_auto entities:
- The first one with a
Global State To Read
set toturn_on_light
(it must be the same as the first env_global in the first map) - The second one with a
Global State To Read
set toturn_off_light
(it must be the same as the second env_global in the first map)
- The first one with a
- The entity you want to fire (in this example - a light named
red
)
First Map - Outputs
Open the activator (the button here) that will fire the env_global entities.
Second Map - Outputs
Open the logic_auto with Global State To Read
set to turn_on_light
(logic_auto that will turn on the light)
My Output > Target Entity Target Input Parameter Delay Only Once OnMapSpawn red TurnOn <none> 0.00 No
Open the logic_auto with Global State To Read
set to turn_off_light
(logic_auto that will turn off the light)
My Output > Target Entity Target Input Parameter Delay Only Once OnMapSpawn red TurnOff <none> 0.00 No
And that's all there is to it.
External links
Multiplayer - Change The Nature Of Next Round