View Single Post
  #2  
Old 06-11-2009, 06:02 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Well, if you know the x/y use triggeraction.

Here's the door
HTML Code:
function onCreated() {
  this.setShape(1, 32, 32);
  level.doorPosition = {this.x, this.y};
}

function onActionOpenDoor(player) {
  //The door has been opened
}
Here's the switch to open the door
HTML Code:
function onCreated() {
  this.setShape(1, 32, 32);
}

function onPlayerTouchsMe() {
    //Let's just send the trigger every 3 seconds, between another touch
  if (this.lastsend > timevar2) return;
  this.lastsend = timevar2 + 3;

  triggeraction(level.doorPosition[0], level.doorPosition[1], "OpenDoor", player);
}
You'll notice that I saved the doors position in a global level variable. Easier than finding out the right position of the object, where ever it's moved it'll be in that position.
Reply With Quote