• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] More vJass Woes!

Status
Not open for further replies.
Level 3
Joined
Feb 17, 2008
Messages
41
I know I am asking a lot of questions about vJass but I'm starting to get the hang of it. I was using my shrinkray spell that I did earlier and I kinda, 'copied' the vJass knockback spell. But it's just to help me understand, this is what I have so far down below. But when I compile it, it gives me a Identifier Redeclared: "ray". I'm assuming that there was a new sytnax of doing things when the tutorial was actually done, hence it was done in 10-13-2007. Any help?

JASS:
globals
    timer tim = CreateTimer()
    shrinkray ray array Ar
    integer Total = 0 
endglobals

struct shrinkray
       shrinkray ray
       unit u
       real size
endstruct


function Shrink takes unit u returns nothing
    local shrinkray ray = shrinkray.create() // I create a compile error.
    local integer q = 20
    set shrinkray = shrinkray.create()

    set ray.u = u
    
    call SetUnitPosition(u, GetUnit(u), GetUnitY(u))
    call PauseUnit(u, true)
    
    if Total == 0 then
        call TimerStart(Tim, .05, true, function Shrink_Execute)
    endif
    
    set Total = Total + 1
    set Ar[Total - 1] = ray
endfunction

function Shrink_Execute takes nothing returns nothing
    local shrinkray ray
    local integer i = 0
    local real newsize

    loop
        exitwhen i >= Total
        set ray = Ar[i]
        
        set newsize = ray.size - 5
        call SetUnitScalePercent(ray.u, newsize, newsize, newsize)
        
        if ray.size <= 30 then
            call PauseUnit(ray.u, false)
            set Ar[i] = Ar[Total - 1]
            set Total = Total - 1
            call ray.destroy()
        endif
        
        set i = i + 1
    endloop
    
    if Total == 0 then
        call PauseTimer(Tim)
    endif
endfunction
 
Level 3
Joined
Feb 17, 2008
Messages
41
Ops! A mistake, anyways I fixed it up and some syntax errors and it works now perfectly! Holy shit, I did a mui spell. Well kinda and I understand it too! Thanks Ghostwolf. You made me understand structs a shit ton more now. +rep for all the help you gave me.
 
Status
Not open for further replies.
Top