variable type


(DWM|Commando) #1

hey guys I want to make a variable (lets call it “x”) that will start at 0 and end at 100 and increase every 30 seconds by another variable (lets call it “y”). Now “y” is dependent on several other variables, ones that get set higher as time goes, but can also be set lower.

My problem is how would I make the variable “y”?

I don’t know what type of variable to use, or what procedure or whatnot. I know i need a (programming talk coming back) process that will run in the background to check to see if “x” is greater than or equal to 100. But how can I make the “y” variable so that multiple other variables can make it, and at it to “x” every 30 seconds.

my idea goes like this (i want to somehow make this into scripting the game understands)


trigger counter            //this is what must run in the back ground constantly, or at least every 30 seconds be called
{
accum x inc y
wait 30000
trigger self_check   //checks to see if its over 100
}

//then here are the multiple variables that make up "y"

trigger f
{
accum y inc 1.5
}

trigger d
{
accum y inc .5
}
//... so on

so i guess the question is can i make a variable that can be increased by another variable? and if so what type of variable or what not would i use? ie like an accum or sumthin else…
i hope that wasnt too hard to follow


(CooperHawkes) #2

for timing the 30 seconds i suggest a timer (func_timer IIRC)

and accums are integers only AFAIK

i’ll give it a try:


counter
{
    spawn
    {
        wait 100
        accum 0 set 0
    }
    trigger sum
    {
        accum 0 abort_if_greater_than 99
        accum 1 set 0
        trigger self calculate
        trigger self post_calculate
    }
    trigger calculate
    {
        globalaccum 0 abort_if_less_than 1
        globalaccum 0 inc -1
        accum 1 inc 1  // accum 1 holds a copy of globalaccum 0 to be able to restore it later
        accum 0 inc 1
        accum 0 abort_if_greater_than 99
        trigger self calculate
    }
    // restore globalaccum 0 (scratch this and accum 1 if you don't need to restore it)
    trigger post_calculate
    {
        accum 1 abort_if_less_than 1
        accum 1 inc -1
        globalaccum 0 inc 1
        trigger self post_calculate
    }
}

globalaccum 0 holds y (you still need to set this elsewhere)

accum 0 holds x

accum 1 holds a dummy variable to restore y (which has been decreased to 0 during the sum up)… if you don’t need to restore it (e.g. in case you overwrite it before the next 30 seconds), then you can remove this

call counter -> sum every 30 seconds using a func_timer / target_script_trigger

i hope it is working… didn’t test it and cannot test it here, since on the computer i am sitting at there is no ET installed (OMG!)

BTW: maybe a “accum 0 inc globalaccum 0” is doing the same… however, i am not sure if this construct is of valid syntax