How to use switches in ScmDraft 2.0

Hello everyone,

I was hoping someone could help me with a switch that I’m trying to use on the map editor. I want to make it so that Player 1 acquires vespene gas exactly every 10 game seconds as long as the special building: Power Generator is still alive.

Correct terms is triggers lol

Conditions:

(Player who own power generator) commands at least 1 Power Generator

Action:

Set Resources - Add Gas
Wait 10000
Preserve Trigger

(Careful on wait action, it can mess things up. The way starcraft handles the wait function is garbage)

Umm no, there are things called “switches” in the game editor. I’m aware of normal triggers and the like for the most part, it’s switches that I’m having trouble with.

Well what you described you don’t need a switch to make that happen…

But just research for switches. Pretty easy.

Condition: Switch 1 is set

Action:

Do whatever

I’ll just try what you recommended above. Thank you. And the reason I wanted to learn about switches is because they can be overall more convenient to use in some circumstances. Such as the trigger I’m trying to make. For example, the switch would make it so that once the switch is taken into account the game engine would keep using it repeatedly instead of me having to input the resources every 10,000 milliseconds. I forgot what coding thing it’s closely related to but that’s why switches are important to use some times. Also, I did check online about switches but I can really only find 3 forums about it and none of them really answer my question.

Coding equivalent of switch is Boolean.

For what you want to do, switches are not needed:

– Conditions:
Always.
– Actions:
Modify death count for player (not in use on map): add 1 (a particular unit).
Preserve trigger.

– Conditions:
Player (who owns Power Generator) owns exactly 1 (or at least 1) Power Generator.
Player (not in use on map) has suffered at least 5 deaths of (a particular unit).
– Actions:
Modify death count for player (not in use on map): set to 0 (a particular unit).
Set resources for player (who owns Power Generator): add x gas.
Preserve trigger.

That’s more reliable than using the wait trigger. That’s also based on the triggers being run every 2 game seconds (i.e. every 2 game seconds, the death count is increased by 1, so every 10 seconds, while the Power Generator is still alive, the gas is added).
The reason for “at least” 5 deaths instead of “exactly” is just in case something happens and the trigger doesn’t activate at “exactly” 5 deaths.
It could be done with switches:

– Conditions:
Switch (number or name) is set.
– Actions:
Modify death count for player (not in use on map): add 1 (a particular unit).
Preserve trigger.

– Conditions:
Player (not in use on map) has suffered at least 5 deaths of (a particular unit).
– Actions:
Modify death count for player (not in use on map): set to 0 (a particular unit).
Clear switch (number or name).
Preserve trigger.

– Conditions:
Player (who owns Power Generator) owns exactly 1 (or at least 1) Power Generator.
Switch (number or name) is cleared.
– Actions:
Set resources for player (who owns Power Generator): add x gas.
Set switch (number or name).
Preserve trigger.

But why use 3 triggers when it can be done in 2?
Personally, I only really use switches for when multiple things need doing. For example:

– Objectives:
Destroy Stasis Cell.
Destroy Power Generator.
Protect Temple.

Always --> Clear switches 1, 2, 3.

Player (enemy) suffers at least 1 death of Stasis Cell --> Set switch 1.
Player (enemy) suffers at least 1 death of Power Generator --> Set switch 2.
Player (human) suffers at least 1 death of Temple --> Set switch 3.

Switches 1, 2 are set; Switch 3 is cleared --> Victory

That helps a lot, thank you so much :slight_smile: