First, look here:
http://impactjs.com/documentation/weltmeister
near the bottom of the page, Dominic explains how to make connections between entities in weltmeister.
Once you've made your connections take a look at the biolab-entity-pack and take a look at EntityTrigger. This is a good example of how to send messages from one entity to another.
Essentially, you'd do something like this:
Imagine you have three entities: Player, Switch, and Platform
In wetmeister:
Set Switch's 'target.1' property to Platform's name property ( See above link ).
Desired behavior:
1. Player flips Switch
2. Switch causes Platform to do something, ie. to start moving.
Steps in code:
1. Player flips Switch, which turns on the Switch. I'm assuming you're doing this in the check function, which is cool.
2. Switch uses the value stored in its own 'target' property to grab a reference to Platform. ( Switch.target.1 === Platform.name ). Use ig.game.getEntityByName(this.target.1).
3. Now that Switch knows Platform, it can send Platform a message to turn itself on.
4.Platform turns itself on.
Code ( Just example stuff, you'll need to tweak this ):
Player doesn't really need to do anything
Switch:
// when Player touches Switch, it turns itself on
check : function( other ){
//if Action button is pressed
//Assuming that the player has to press a button to turn on Switch
if( ig.input.state( 'action' ) ){
//if other is Player, turn on switch.
if( other === Player )
this.on();
}
}
// the on function should do three things
on : function(){
// 1. turn myself on
this.isOn = true; //or however you are already handling this.
// 2. get reference to Platform
var platform = ig.game.getEntityByName( this.target.1 );
// 3. turn on platform
platform.on();
}
Platform:
//You'll need one property on Platform
shouldMove : false
//Platform turns itself on
on : function(){
//Start moving.
//This could be a simple call to a state machine that changes how
//your update function works.
this.shouldMove = true;
}
Your update function could looks something like this:
update : function(){
if( this.shouldMove ){
//Move myself
}
}
This way, Platform won't move until it's been messaged by Switch.
These functions and properties can be whatever you want. The above code is just to explain the concepts. You'll need to have a reference to Player to use in the check function ( I'm assuming you already know how to handle the checks ).
Thats pretty long-winded but, I hope it help get the idea across.