<!-- oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
      Quest for a button. 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 set a state
	 $state_on: sequence operation that we will perform on the
	     target mesh once the button is pressed.
	 $state_off: sequence operation that we will perform on the
	     target mesh once the button is pressed off.
	 $on_distance,off_distance: relative move for the button to go on 
	 (x axis).
      oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo -->
<library>
  <addon plugin="cel.addons.quest">
<quest name="ButtonState">
    	<state name="init">
	    <trigger type="timeout">
	    	<fireon timeout="100" />
		<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 entity="$target_ent" type="newstate" state="$state_on" />
		<reward type="newstate" state="to_on" />
	    </trigger>
	</state>
	<state name="to_on">
	    <trigger type="timeout">
	    	<fireon timeout="100" />
		<reward type="newstate" state="on" />
	    </trigger>
	</state>
	<state name="on">
	    <trigger type="meshselect">
	    	<fireon entity="$this" leave="true" />
		<reward entity="$target_ent" type="newstate" state="$state_off" />
		<reward type="newstate" state="to_off" />
	    </trigger>
	</state>
	<state name="to_off">
	    <trigger type="timeout">
	    	<fireon timeout="100" />
		<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="100" entity="$this">
		<v x="$on_distance" y="0" z="0" />
	    </op>
	</sequence>
	<sequence name="but_off">
	    <op type="transform" duration="100" entity="$this">
		<v x="$off_distance" y="0" z="0" />
	    </op>
	</sequence>
</quest>
</addon>
</library>


