help!! as2 (solved)

Subscribe to help!!  as2 (solved) 4 posts

avatar for gulzaibthegreat1 gulzaibthegr... 291 posts
Flag Post

i have a turn variable which gets updated everytime somebody does their turn. i also have

var effect1:boolean = false

and that boolean is set to true under certain conditions, now under

function onEnterFrame(){

i have it so that
if(effect1 = true){

now im not sure how to write it so that every time a turn is done for a variable (lets make that variable e1health) to go down by 10 (-= 10)

 
avatar for saybox saybox 2675 posts
Flag Post

First,

if(effect1 == true)

You use two = signs in conditions.

Once that works, just change the variable with regular maths. For example:

if(flying==true){
arm_stamina-=1
}

which would make your arms tired if you were flying.

The = sign in the maths there tells flash to perform the operation on itself, it’s the same as writing arm_stamina=arm_stamina-1.

 
avatar for gulzaibthegreat1 gulzaibthegr... 291 posts
Flag Post

okay yes i get that but the problem is how would i do it so that it only happens at the end of a turn? from what i see about this code:

if (effect1 == true){
e1health -= 10
}

is that for as long as effect1 is true it will continually take 10 health off of e1health. But i want it to do it once a turn for certain amount of turns which corresponds with my other variable (turn) and i am very confused as to how i would
do this

edit: alright so i sort of fixed it by adding a new variable:

 var effect_turn:Boolean = false;

than after every turn i said that effect turn would be true, and than i changed effect1 == true code to:
if (effect1 == true && effect_turn == true){
e1health -= 10;
effect_turn == false;
}

now if i would add a timer, and put a
timer +=1
in side the top code and say that if timer = blank amount that effect would be false… would that work? let me test this 1 minute.

alright it works! okay guys this is solved thanks anyway

 
avatar for saybox saybox 2675 posts
Flag Post

is that for as long as effect1 is true it will continually take 10 health off of e1health.


Well, yeah, that is what you asked, after all.

If it’s meant to run once a turn then it shouldn’t be in an enterFrame event, though. put it in a function and run it at the start of the turn :P