Lever, switch, 2-way target sets

From The DarkMod Wiki
Jump to: navigation, search

written by Fidcal


Introduction

Here is a way to make one lever trigger different targets depending which way it is thrown. it would also work with any switch or say a door so you get a different effect when it is opens to when it closes.


Summary

The method works by relaying the lever's triggering through two counters which are put out of sync by another temporary counter.


How to set up the lever

  • Create three trigger_count entities, C1, C2, and C3.
  • Both C1 & C2 you give the property/value: repeat 1 but C3 you give repeat 0
  • Both C1 & C2 you give the property/value: count 2 but C3 you give count 1
  • C1 targets one set of targets (say Light 1 in a test)
  • C2 targets the other set of targets (say Light 2 in a test)
  • C3 targets C2
  • 1 lever targets all 3 trigger_count entities, C!, C2, & C3


The resulting effect of the lever setup

Imagine a setup with two test lights, Light 1 and 2.

But either light could instead be any number of different targets.


You push the lever forward.

Light 2 toggles on/off but Light 1 is unaffected.


You pull the lever back.

Light 1 toggles on/off but Light 2 is unaffected.

... and so on. Only one target (or set of targets) is affected when you push the lever forward. A different target is affected when you pull the lever back.


Explanation

You don't need to read this to get it to work. You only need to know #How to set up the lever

trigger_count entities count down from their count value but don't relay the trigger on to their own target(s) until the count reaches zero.

If the trigger_count entity also has repeat 1 set then after reaching zero and triggering its target(s) it resets the count value back to the original spawnarg value. But if repeat was 0 then it only triggers its target(s) once then does nothing further (a bit like trigger_once except after a count.)


This is what happens in detail:

You push the lever forward:

  • It decrements counter 1 from 2 to 1
  • It decrements counter 2 from 2 to 1
  • It decrements counter 3 from 1 to 0
  • Counter 3 has reached 0 so it triggers counter 2
  • This puts counter 2 out of sync with counter 1
  • Counter 3 has repeat 0 so is not used again
  • So counter 2 has been decremented from 1 to 0
  • So Counter 2 toggles Light 2 on/off
  • Counter 2 has repeat 1 so it resets count to 2
  • Net result when lever pushed forward is that Light 2 is toggled on or off but Light 1 is unaffected.

You pull the lever back:

  • It decrements counter 2 from 2 to 1
  • It decrements counter 1 from 1 to 0
  • So Counter 1 toggles Light 1 on/off
  • Counter 1 has repeat 1 so it resets count to 2
  • Net result when lever pulled back is that Light 1 is toggled on or off but Light 2 is unaffected.

You push the lever forward:

  • It decrements counter 1 from 2 to 1
  • It decrements counter 2 from 1 to 0
  • So Counter 2 toggles Light 2 on/off
  • Counter 2 has repeat 1 so it resets count to 2
  • Net result when lever pushed forward is that Light 2 is toggled on or off but Light 1 is unaffected.

and repeats. Each throw of the lever only one light is affected. This could of course be any number of different targets on each of counters 1 and 2.