• 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.

Undeclared Function ReturnItemBase

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
wut

JASS:
library DisplayGear

function DisplayGear takes unit u, player forPlayer returns nothing
    local integer i = 1
    local integer array i2
    call CreateUnitAtLoc(forPlayer, 'h000', udg_TempLoc, 0.)
    loop
        exitwhen i == 10
        set i2[i] = ItemToAbil(GetEquippedItemTypeId(forPlayer, i))
        if i == 0 then
            call UnitAddAbility(GetLastCreatedUnit(), ReturnItemBase(i2[i]))
        else
        endif
        set i = i + 1
    endloop
    set i = 1
    loop
        exitwhen i == 10
        if i2[i] == 0 then
        else
        endif
    endloop
            
endfunction

function ReturnItemBase takes integer slot returns integer
    if slot == 1 then
        return 'A00X'
    else
    endif
    if slot == 2 then
        return 'A00Y'
    else
    endif
    if slot == 3 then
        return 'A00S'
    else
    endif
    if slot == 4 then
    else
    endif
    return '0'
endfunction

endlibrary
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Problem is if u call a function then functiom must be above the caller function so 1st copy paste ReturnItemBase function above display gear

1.
call CreateUnitAtLoc(forPlayer, 'h000', udg_TempLoc, 0.)

u can do this


local unit u = CreateUnitAtLoc(forPlayer, 'h000', udg_TempLoc, 0)
.....
set u = null

and its shorter and easier to use

or use CreateUnit(forPlayer, 'h000', x,y, 0)
because its faster too

2.

JASS:
    if slot == 1 then
        return 'A00X'
    else
    endif
    if slot == 2 then
        return 'A00Y'
    else
    endif
.............
instead this, this more readable maybe faster too

JASS:
local integer i = '0'
    if slot == 1 then
        set i =  'A00X'
    elseif slot == 2 then
        set i = 'A00Y'
    elseif slot == 3 then
        set i = 'A00S'
    endif
return i

(or just keep return but with elseif ur xode shorter with 1 endif at each if )
 
Status
Not open for further replies.
Top