ID:160142
 
Okay at the moment i have code like this

mob
proc
test()
if(src.test1 == 1)
if(src.test2 == 1)
if(src.test3 == 1)
//keeps going etc.
else
src.test3 = 1
else
src.test2 = 1
else
src.test1 = 1


Is there a more easier way to do this? It will check if certing tests are available or not, if they are not it will go check the next, and so on.
Basically... look up the && and || operators. Also read up on boolean vars and boolean checking.
if(test1 && test2 && test3)
//if all three expressions are true values...
do_stuff
else //if at least one of the expressions is false...
do_something_else
In response to Kaioken
Kaioken wrote:
Basically... look up the && and || operators. Also read up on boolean vars and boolean checking.
if(test1 && test2 && test3)
> //if all three expressions are true values...
> do_stuff
> else //if at least one of the expressions is false...
> do_something_else


Thanks but its not exactly what im looking for, what I want is if Test1 is not available it will check for test2 is or not, if test 1 is it will make test1 not available and the same way with 2, and 3. In your way i cannot find out which is availble and to make it not availble.
Switch() procedure.
In response to Andre-g1
Andre-g1 wrote:
Switch() procedure.

Doesn't switch() only check for one argument?
He's trying to valiadate three different variables though, unless you would aim for the use of just one varibale that contains all the bitflags (which might be better ;)).

As for the original poster, maybe some more informations would help.
Are all three used as booleans?
Can two or more be true at a time?
What exactly do you want to do when one is true and when one is false?
How many of them do you have, three as in the example, or more?
In response to Schnitzelnagler
You can check multiple values separating it by commas.

He should just make one variable have values like 1,2,3,4 for the tests made. Then he could use switch() which is far more efficient.
In response to Schnitzelnagler
Schnitzelnagler wrote:
Andre-g1 wrote:
Switch() procedure.

Doesn't switch() only check for one argument?
He's trying to valiadate three different variables though, unless you would aim for the use of just one varibale that contains all the bitflags (which might be better ;)).

As for the original poster, maybe some more informations would help.
Are all three used as booleans?
Can two or more be true at a time?
What exactly do you want to do when one is true and when one is false?
How many of them do you have, three as in the example, or more?

What Im trying to do really is have a check, if Test1 is true, then go check if Test2 is true or false, if if Test1 is false, make Test1 true, stop right there, if Test2 is true go check if test 3 is also true or false, if Test 1 is true but Test2 is false, make Test2 now true, and stop right there, if Test 3 is true, stop everything, if not make test 3 true as well. I want to make this really into a check if a certain spot on a map is available and if so, you would get teled there if not, it will try to find a available spot for you.
In response to Onimushia
Then, give values to a variable called test.

Like

mob/var/test

test = 1

test = 2

test = 3

test = 4

//etç, depending on what test they are. Then you do the following :

mob/proc/Test()
switch(test)
if(1) // blah
if(2) // blah

//etç
In response to Andre-g1
Andre-g1 wrote:
Then, give values to a variable called test.

Like

> mob/var/test
>
> test = 1
>
> test = 2
>
> test = 3
>
> test = 4
>
> //etç, depending on what test they are. Then you do the following :
>
> mob/proc/Test()
> switch(test)
> if(1) // blah
> if(2) // blah
>
> //etç
>
>


Thanks, but its still not what im looking for, anyway thanks for the help Andre-g1. Pretty much the way your telling me is that 2 people can be in the same spot, which i do not want all, when transported to a spot i want no one to be in the same spot, ever.
Either way, you're making all the tests equal to 1.
In response to Kaiochao
Kaiochao wrote:
Either way, you're making all the tests equal to 1.

Yes I am, but they are named different Test1 , Test2, and Test 3 they are 3 seperate variables and later will be renamed for Area1, Area2, Area3.
In response to Onimushia
Why do you need them at all if you're only setting them to 1? Seems pointless if that's all you're doing with them.
In response to Kaiochao
Kaiochao wrote:
Why do you need them at all if you're only setting them to 1? Seems pointless if that's all you're doing with them.

To check if they are open are not, because once a player goes there, it should not let another player in, until that original player leaves that area
In response to Onimushia
Whatever you're doing, it seems rather messily designed. If you just need to check if certain areas are clear, why not uh... do just that? In order...? In a loop?
In response to Onimushia
Wouldn't it be better for the Area to have a variable that determines if someone is in the area.

Then you could just use Enter() and Exit() to change and check each area's variable.
In response to KirbyAllStar
KirbyAllStar wrote:
Wouldn't it be better for the Area to have a variable that determines if someone is in the area.

Then you could just use Enter() and Exit() to change and check each area's variable.

Finally, and thanks, that will work perfectly, on what I want to do.
In response to KirbyAllStar
Or... you could just do it by actually checking if there's a player within the area directly, instead of keeping track of silly, non-robust vars. >_>
In response to Kaioken
Very true. :D
mob/proc/Test()
for(var/X in 1 to 3)
if(!("Text[X]" in vars)) CRASH("This is the equivalent of using :,\
so this wouldn't be good except in extreme situations."
)
var/Y = src.vars["Test[X]"]
if(!Y)
Y = 1
break