Quote:
Originally Posted by callimuc
Wouldnt it be thiso?
|
This is one of those cases where
this will still refer to then NPC.
Uploaded this npc in a level I was in:
PHP Code:
function onPlayerEnters() {
this.nick = "NPC";
echo("Test");
echo("-" SPC this.nick);
for (temp.p: players) {
with (temp.p) {
echo("+" SPC this.nick SPC player.nick);
}
}
}
echos
PHP Code:
Test
- NPC
+ NPC Leader fp4
@blackbelben: Get rid of the with statement and your code should work fine, at least the section you posted should.
PHP Code:
for (temp.p: players) {
if (temp.p.x < this.x) {
this.dir = 1;
this.x -= (this.speed);
}
if (temp.p.x > this.x) {
this.dir = 3;
this.x += (this.speed);
}
if (temp.p.y < this.y) {
this.y -= (this.speed);
}
if (temp.p.y > this.y) {
this.y += (this.speed);
}
}