HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Mismatch?

04-24-2004, 07:35 PM#1
fugly
Any idea as to why this brings up an error as a Type mismatch in assignment when trying to save?

Code:
function addRangedAI takes unittype n, real ranges returns nothing
     set udg_RUT[udg_targetcount + 1] = n  //this line
     set udg_range[udg_targetcount + 1] = ranges
     set udg_targetcount = udg_targetcount+1
endfunction

and yes, rut is a unittype array
Code:
function Order takes nothing returns nothing
local integer p = 1
local integer g = 1
local integer s = 1
local integer b = 1
local integer a = 1
local integer v = 1
local integer j = 1
local integer z = 1
call ForGroupBJ(udg_TargetHeros, function unitval)
loop
   exitwhen b>udg_targetcount
    loop
       exitwhen p > udg_targetcount
        loop
           exitwhen g >udg_targetcount
           set udg_TargetsLife[b] = R2I(RMinBJ(I2R(udg_LifeTargets[g]), I2R(udg_LifeTargets[p])))
           set g = g+1
        endloop
       set p = p + 1
   endloop
   loop
      exitwhen a>udg_targetcount
      if udg_TargetsLife[b] == udg_LifeTargets[a] then 
       set udg_LifeTargets[a] = 20000
       set s = s+1
       exitwhen true
      endif
      set a = a+1
   endloop
   set b = b+1
endloop
loop
  exitwhen j>udg_targetcount
  loop
    exitwhen v>udg_targetcount
    loop
      exitwhen z>udg_targetcount
[color=DarkRed]      if (GetUnitUserData(udg_Hero[v]) = udg_TargetsLife[z]) then
        set udg_Hero[v] = udg_Target[j]
      else[/color]
        set z = z + 1
    endloop
   set v = v + 1
   endloop
 set j = j + 1
endloop
endfunction
also why do those lines bring up erros of
first: expected '=='
second: expected a name
third: expected enloop (even though this is probably caused by error the first :8 )
04-24-2004, 09:37 PM#2
weaaddar
first off you do need an == to compare those two.
Also the worldedit type Unit Type is actually UnitId which is actually an integer. UnitType as your declaring in this function is an array of unit classifications. The fast way to fix it would be to change the type it takes to integer.
Other then that should be fine.
04-24-2004, 10:21 PM#3
Narwanza
If you already understand the difference between = and == then don't read on. The difference between '=' and '==' is quite big. When you put an = in your code, the engine tries to assign a value to a variable. Now if you say.

Code:
if (i = 1) then

You don't want to set the value of i = 1, you want to test if the value of i is equal to 1. That is why they created the == operator. So you can say.

Code:
if (i == 1) then

Now it won't try to assign the value of 1 to i, it will test if the value of i is equal(==) to 1. So think of a single = as "is assigned the value" and think of == as "is equal to".
04-25-2004, 01:55 PM#4
fugly
oh ok, but i forgot to mention, when i put in the '==' the world editor crashes =(
04-26-2004, 02:27 PM#5
Peppar
Quote:
Originally Posted by fugly
oh ok, but i forgot to mention, when i put in the '==' the world editor crashes =(

I would believe that the crash is caused by the lack of an Endif shortly after the highlighted code. WE is very sensitive about mismatched or unfinished block constructs.
04-27-2004, 01:44 AM#6
fugly
Peppar you win!!!