• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] Saving in Table

Status
Not open for further replies.
Level 5
Joined
Sep 16, 2008
Messages
47
i got simple question. Here is code that i wrote to ask, it's just quick made example.

Let's say in the loop onCast i save some real that i use in CTLExpire.

But how can i change this value?

if i write:
JASS:
set a = a + 10

I need this value to change every loop.

it's like. In loop 1 it's 50 but in loop 2 it's 100, in loop 3 it's 150
JASS:
set distance = distance + 50

JASS:
scope spell

    globals
        private constant integer SPELL_CODE = 'A000'
    endglobals
    
    private struct spell
    
        private static unit array caster
        
        private static integer array i
        
        static Table array tab
    
        implement CTL
        
            local real index = 0
            local real amount = 10
            local real a
        
        implement CTLExpire
        
            loop
            
                set a = tab[this].real[index]
            
                set index = index + 1
            
                exitwhen index == amount
                
            endloop
            
            set i[this] = i[this] - 1
            
            if i[this] == 0 then
            
                set caster[this] = null
                call destroy()
            
            endif
        
        implement CTLNull
        implement CTLEnd
    
        private static method onCast takes nothing returns nothing
        
            local thistype this = create()
            
            local real index = 0
            local real amount = 10
            local real a = 0
            
            set caster[this] = GetTriggerUnit()
            
            set i[this] = 50
            
            set tab[this] = Table.create()
            
            loop
            
                set a = a + 10
                
                set tab[this].real[index] = a
            
                set index = index + 1
            
                exitwhen index == amount
                
            endloop
        
        endmethod
    
        private static method onInit takes nothing returns nothing
            call RegisterSpellEffectEvent(SPELL_CODE,function thistype.onCast)
        endmethod
    
    endstruct

endscope
 
Status
Not open for further replies.
Top