Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   players in room (https://forums.graalonline.com/forums/showthread.php?t=47367)

Kaimetsu 08-24-2003 07:56 AM

It depends. The name of the game is implicit intentions; personally I don't like searching through endless conditions to understand what somebody is doing. If the conditions are related then yeah, fine, but otherwise it's stupid.

TB3 08-24-2003 08:37 AM

I didnt read all the way to the third page but.....

In order for more people to be in the room playerenters will have to be triggered.... *DUH* you dont need a timeout loop to lag the server any or little just a simple
NPC Code:


if(created) {
this.minplayers=5;
}
if(playerenters) {
if(playerscount>=this.minplayers){
blah();
}
}



THat would be sufficient right or did i miss something?


[edit]
NPC Code:


if(created) {
this.minplayers=5;
this.mode=0;
this.check=0;
}
if(playerenters||playerleaves) {
this.mode=(playerscount>=this.minplayers? 1 : playerscount<this.minplayers? 0 );
if(this.mode!==this.check) {
door();
}

}

function door() {
this.check=this.mode
if(this.mode=1) {//Opening
blah;
}
if(this.mode=0) {//Closing
blah;
}
}



THeres a more complex edit it should work *goez to zleep im tired*

Tseng 08-24-2003 09:12 AM

Quote:

Originally posted by Kaimetsu
It depends. The name of the game is implicit intentions; personally I don't like searching through endless conditions to understand what somebody is doing. If the conditions are related then yeah, fine, but otherwise it's stupid.
if (playerchats && strequals(#c,give me pie)) {
//Some cool pie-giving coding
}

I've been arguing related the whole time. :)

Kaimetsu 08-24-2003 10:15 AM

Quote:

Originally posted by Tseng
I've been arguing related the whole time. :)
Indeed, but I'm not addressing just you :)

Snakeandy7 08-24-2003 11:46 AM

Quote:

Originally posted by TB3

NPC Code:


if(created) {
this.minplayers=5;
this.mode=0;
this.check=0;
}
if(playerenters||playerleaves) {
this.mode=(playerscount>=this.minplayers? 1 : playerscount<this.minplayers? 0 );
if(this.mode!==this.check) {
door();
}

}

function door() {
this.check=this.mode
if(this.mode=1) {//Opening
blah;
}
if(this.mode=0) {//Closing
blah;
}
}



THeres a more complex edit it should work *goez to zleep im tired*

I'm sorry but, why does your script question it self?...

Dach 08-24-2003 06:18 PM

Quote:

Originally posted by Snakeandy7

I'm sorry but, why does your script question it self?...

its an operand (one of them), basically a quicker way of doing an if else type thing
myvar = (flag? valueiftrue : vlaueiffalse)
and I guess you can layer them... never tried that :megaeek:

TB3 08-25-2003 06:40 AM

Quote:

Originally posted by Snakeandy7

I'm sorry but, why does your script question it self?...

As below an operand its realy good to use in some situations but can be easily messed up if you dont know what your doing.

Quote:

Originally posted by Dach


its an operand (one of them), basically a quicker way of doing an if else type thing
myvar = (flag? valueiftrue : vlaueiffalse)
and I guess you can layer them... never tried that :megaeek:

Yep you can layer them and it does it in order so it can be very helpfull, also if there is no value for false it doesnt set it to anything so it makes it even more helpfull


All times are GMT +2. The time now is 11:25 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.