pass local into timer and return

Frozenwind

System maker
Reaction score
99
I wanna know wether it's possible or not to pass some local value into a timerfunction and then return it.
I got some offset variable and I want to pass it into a timer and then increase it and the timer reruns.

I got this:

JASS:
function Trig_TB_JASS_Functions_Loop_Actions takes nothing returns nothing

endfunction

function Trig_TB_JASS_Functions_Actions takes nothing returns nothing


    // BEGIN INITATION


    local location array loc
    local unit cast = GetSpellAbilityUnit ()
    local real array angle
    local real offset = 0.00
    local integer array A
    local integer array B
    local lightning array light
    local location array temppoint
    local timer t

    set temppoint[0] = GetUnitLoc (cast)
    set A[0] = 0
    set A[1] = 2
    loop
        exitwhen A[0]>A[1]
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_088" )
        set angle[A[0]] = I2R( A[0] * 120)
        set loc[A[0]] = GetUnitLoc (cast)
        set light[A[0]] =  AddLightningLoc( "HWPB", temppoint[0], temppoint[0] )
        set A[0] = A[0] + 1
    endloop

    
    // END INITATION
    // BEGIN LOOPING

    
    set A[0] = 0
    set A[1] = 50
    set B[1] = 2
    loop
        exitwhen A[0]>A[1]
        set offset = offset + 5
        set B[0] = 0
        call DisplayTextToForce( GetPlayersAll(), R2S (offset) )
////////////////////////////////////////////////
        loop
            exitwhen B[0]>B[1]
            set angle[B[0]] = angle[B[0]] + 4
            set temppoint[1] = PolarProjectionBJ(loc[B[0]], offset, angle[B[0]])
            call RemoveLocation (loc[B[0]])
            set loc[B[0]] = temppoint[1]
            set temppoint[1] = null
            set B[0] = B[0] + 1
        endloop

        set B[0] = 0
        set B[1] = 2
        loop
            exitwhen B[0] > B[1]
            if B[0] == 2 then
                set temppoint[2] = loc[0]
            else
                set temppoint[2] = loc[B[0]+1]
            endif
            call MoveLightningLoc( light[B[0]], loc[B[0]], temppoint[2] )
            set temppoint[2] = null
            set B[0] = B[0] + 1
        endloop
///////////////////////////////////////////
        set A[0] = A[0] + 1
    call PolledWait( 0.01 )
    endloop
    call RemoveLocation (temppoint[0])
    set temppoint[0] = null
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_089" )


    // END LOOPING


endfunction

//===========================================================================
function InitTrig_TB_JASS_Functions takes nothing returns nothing
    set gg_trg_TB_JASS_Functions = CreateTrigger(  )
    call TriggerAddAction( gg_trg_TB_JASS_Functions, function Trig_TB_JASS_Functions_Actions )
endfunction
I got that I want the function that I marked with "//////" to happen in the timerfunction.

But, how can I increase those real values every time the timer reruns?
Or is it possible to count the number of times the timer expires into a local?
Cos in that case I can make it a formula as in: offset+5*integer

frozenwind.

PS
Don't worry I got a casting unit, this JASS trigger gets runned by a GUI trigger:
Code:
TB Cast It
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to MySpell 
    Actions
        Trigger - Run TB JASS Functions <gen> (ignoring conditions)
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
btw i suggest you to use a jass event instead of putting in some GUI and also about passing local to timer function you can't pass it unless you use a global to transfer the value beetwen function or to use an attachment system
 

Frozenwind

System maker
Reaction score
99
But if I'd use a global I gotta reset it every time I rerun the function,
and I dun know wether that would be possible, cos then I could just use a normal loop, but that ain't smooth.

frozenwind.

BTW
I got my reasons for using GUI event, later on I add a few actions there....
It's for the implentdifficulty of the spell.
 

Cohadar

master of fugue
Reaction score
209
Perhaps looking at some of spells ~Gals~ submitted might give you a clue?

I feel the need for bangheading...
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
You have two options:

1. Use an attachment system to attach a local variable to the timer variable.

2. There's a handy function for storing integers into timers without an actual system, its at wc3campaigns.net which is down (again!) so I don't have it, but perhaps you could attach a struct to it?
 

Frozenwind

System maker
Reaction score
99
I'd love to, but then there is a small problem:
I dun know what "structs" are:p,

I'll search for a tutorial tommorow about structs, am too tired to read a tutorial now. (22:00 ~ 10:00 PM)

frozenwind.
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
Structs are only something found in vJass, which requires the NewGen editor. If you don't own this or you don't already have a good grasp on JASS, I wouldn't try to learn it just yet.
 

Frozenwind

System maker
Reaction score
99
Muwa, I'll just try it,
I might not be that advanced with JASS yet bit I can get a good view of triggers in my head...
Besides I'm doing the highest level at my school.

Who doesn't try won't ever win.

frozenwind(, whichs goes off now).
 

Cohadar

master of fugue
Reaction score
209
2. There's a handy function for storing integers into timers without an actual system, its at wc3campaigns.net which is down (again!) so I don't have it, but perhaps you could attach a struct to it?

hilton.gw.oiccam.com/forums.php
wc3c is not down, it just has DNS problems

What function are you talking about?
 

Cohadar

master of fugue
Reaction score
209
roflmao, yet another hack abuse.

Note that it does not solve his problem because he needs a periodic timer.
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
Yes it does, simply restart the timer in the callback function.

And you can also attach other handles to it if you really wanted to, but I2H might screw you over....
 

Hero

─║╣ero─
Reaction score
250
Or is it possible to count the number of times the timer expires into a local?

Yes that is possible...just have an integer that is set in the first function then store it using handle vars, tables (whatever you like better) then just retrieve it each time the timer code function is called and set it to itself+1 then store it again. Then you can always check if it equals 3 or whatever you need it to equal
 

Frozenwind

System maker
Reaction score
99
So 2 options: (maybe 3)
  • Structs
  • Table/Handle var to count number of times the timer expires
  • (maybe) let the trigger call itsself using a timer (only possible if I can pass value in timer, but I'd need A or B for that, right?)

Ok, time to read tutorials about structs first:)

frozenwind.
 

SFilip

Gone but not forgotten
Reaction score
634
Structs aren't an attachment system.
 

Frozenwind

System maker
Reaction score
99
Uhm..

This might be possible then:

JASS:
//quote=The_Kingpin
function GetTimerInt takes timer t returns integer
    return R2I(TimerGetRemaining(t) + 0.5)
endfunction

Run 2 timers, 1 timer is a single run timer and 1 is a continuing timer.
((Timer1 starttime) - (Timer1 remaintime)) / (timer2 'cooldown')

Like that I can count the number of times its running?

frozenwind.

EDIT: but then I still need a way to pass it to my 2nd function :S (which continuious runs)
 

Cohadar

master of fugue
Reaction score
209
Structs aren't an attachment system.

But they can be used to pass data to timers.

Btw there was some strange attachment system I saw floating around here,
it was called BCD or AVG, something like that... :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top