Trying to make a function, lots of problems.

Evan1993

Ultra Cool Member
Reaction score
30
I don’t know what the problem is, but JassCraft gives me ~27 statement out of function, comparing two variables of different primitive types (except real and integer) is not allowed, and it also says my all locals are un-declared, and not arrays! :mad:
Here's the code:
PHP:
function Shadow takes unit shadowedunit real faderate real duration returns nothing
local unit array Shadows
local integer array vertex
local timer SDuration
call StartTimerBJ( SDuration, false, 30 )
  set bj_forLoopAIndex = 1
    loop
        exitwhen TimerGetRemaining(SDuration) == 0.00
        call CreateNUnitsAtLoc( 1, GetUnitTypeId(shadowedunit), GetOwningPlayer(shadowedunit), GetUnitLoc(shadowedunit), GetUnitFacing(shadowedunit) )
        set Shadows[bj_forLoopAIndex] = GetLastCreatedUnit()
        call SetUnitVertexColor( Shadows[bj_forLoopAIndex], 100, 100, 100, 50 )
        set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = bj_forLoopAIndex
    loop
       exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set vertex[bj_forLoopAIndex] = vertex[bj_forLoopAIndex] -  faderate
        if vertex[bj_forLoopAIndex] == 0 then
        call RemoveUnit( Shadows[bj_forLoopAIndex] )
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
        call IssueTargetOrder( Shadows[bj_forLoopAIndex], "move", shadowedunit )
        call SetUnitTimeScalePercent( Shadows[bj_forLoopAIndex], 15.00 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
 returns nothing
endfunction
 

Chocobo

White-Flower
Reaction score
409
Code:
 function Shadow takes unit shadowedunit, real faderate, real duration returns nothing
local unit array Shadows
local integer array vertex
local timer SDuration
call StartTimerBJ( SDuration, false, 30 )
  set bj_forLoopAIndex = 1
    loop
        exitwhen TimerGetRemaining(SDuration) == 0.00
        call CreateNUnitsAtLoc( 1, GetUnitTypeId(shadowedunit), GetOwningPlayer(shadowedunit), GetUnitLoc(shadowedunit), GetUnitFacing(shadowedunit) )
        set Shadows[bj_forLoopAIndex] = GetLastCreatedUnit()
        call SetUnitVertexColor( Shadows[bj_forLoopAIndex], 100, 100, 100, 50 )
        set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = bj_forLoopAIndex
    loop
       exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set vertex[bj_forLoopAIndex] = (vertex[bj_forLoopAIndex] - faderate)
        if vertex[bj_forLoopAIndex] == 0 then
        call RemoveUnit( Shadows[bj_forLoopAIndex] )
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
        call IssueTargetOrder( Shadows[bj_forLoopAIndex], "move", shadowedunit )
        call SetUnitTimeScalePercent( Shadows[bj_forLoopAIndex], 15.00 )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

This should work, but in Line 16, there is a weird error.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
The weird error is trying to subtract a real from an integer...

You can convert it if needed:
set vertex[bj_forLoopAIndex] = vertex[bj_forLoopAIndex] - R2I(faderate)


Though you may want to rethink it... you probably had a reason to use integer for one and real for the other... :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top