<!-- oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
      Quest for a button that sets a sequence on some object. 
      This quest should be assigned to the entity that also holds the 
      button mesh. This variant will run a sequence in the target entity.
      Parameters:
	 $target_ent: target entity on which we will do the action.
	 $target_op_on: sequence operation that we will perform on the
	     target mesh once the button is pressed on.
	 $target_op_off: sequence operation that we will perform on the
	     target mesh once the button is pressed off.
	 $onx, $ony, $onz: relative move for the button to go on.
	 $offx, $offy, $offz: relative move for the button to go off.
      oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo -->
<library>
  <addon plugin="cel.addons.quest">
<quest name="ButtonSeq">
	<default name="x_on" value="0"/>
    	<default name="x_off" value="0"/>
    	<default name="y_on" value="0"/>
    	<default name="y_off" value="0"/>
    	<default name="z_on" value="0.5"/>
    	<default name="z_off" value="-0.5"/>
    	<default name="duration" value="500"/>
    	<state name="init">
	    <trigger type="timeout">
	    	<fireon timeout="100" />
		<reward type="sequence" entity="$target_ent" sequence="$target_op_off" />
		<reward type="newstate" state="off" />
	    </trigger>
	</state>
    	<state name="off">
	    <trigger type="meshselect">
	    	<fireon entity="$this" />
		<reward type="sequence" entity="$this" sequence="but_on" />
		<reward type="newstate" state="to_on" />
	    </trigger>
	</state>
    	<state name="to_on">
	    <trigger type="timeout">
	    	<fireon timeout="$duration" />
		<reward type="sequence" entity="$target_ent" sequence="$target_op_on" />
		<reward type="newstate" state="on" />
	    </trigger>
	</state>
    	<state name="on">
	    <trigger type="meshselect">
	    	<fireon entity="$this" />
		<reward type="sequence" entity="$this" sequence="but_off" />
		<reward type="newstate" state="to_off" />
	    </trigger>
	</state>
    	<state name="to_off">
	    <trigger type="timeout">
	    	<fireon timeout="$duration" />
		<reward type="sequence" entity="$target_ent" sequence="$target_op_off" />
		<reward type="newstate" state="off" />
	    </trigger>
	</state>
    	<sequence name="but_on">
	    <op type="transform" duration="$duration" entity="$this">
		<v x="$x_on" y="$y_on" z="$z_on" />
	    </op>
	</sequence>
    	<sequence name="but_off">
	    <op type="transform" duration="$duration" entity="$this">
		<v x="$x_off" y="$y_off" z="$z_off" />
	    </op>
	</sequence>
</quest>
</addon>
</library>


