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

Unknown Code Bug

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
I have these two functions:

JASS:
function RegisterVars takes integer i returns nothing
    local CharDat dat = CharDat.create()
    set dat.Vitality = 1.0
    set dat.Dexterity = 1.0
    set dat.Focus = 1.0
    set dat.Attack = 0.0
    set dat.Defense = 0.0
    set dat.Health = 50.0
    set dat.Mana = 10.0
    set dat.Mregen = 0.0
    set dat.Hregen = 0.0
    set dat.AttackSpeed = 0.0
    set dat.CritChance = 0.0
    set dat.EvaChance = 0.0
    set dat.BlockChance = 0.0
    set dat.StunChance = 0.0
    set dat.DropChance = 0.0
    call SaveInteger(CD, i, 1, dat)
endfunction

and

JASS:
function FuncInit takes nothing returns nothing
    local destructable skin
    local integer m = 1
    local integer PID = GetPlayerId(GetTriggerPlayer())
    local CharDat dat
    call RegisterVars(PID)
    set dat = LoadInteger(CD, PID, 1)
endfunction

These two functions are in separate libraries. When I save though it says "Undeclared function RegisterVars" But when I call RegisterVars in another library then it works. Any Ideas why?

UPDATE: Interesting... I fixed it. But all I did was change the name of the library that help FuncInit. The original name of the library was; CCS. Now I changed it to CreationSystem and it works perfectly fine.

Is there something wrong with CCS?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
It might have been an issue of alphabetical order. If you try to call a function that has not been yet declared, it won't work.

This will work:
JASS:
library a

    function AA takes nothing returns nothing
    endfunction

endlibrary

JASS:
library b

    function BB takes nothing returns nothing
        call AA()
    endfunction

endlibrary

This won't work:
JASS:
library a

    function AA takes nothing returns nothing
        call BB()
    endfunction

endlibrary

JASS:
library b

    function BB takes nothing returns nothing
    endfunction

endlibrary

To make the latter work, you can add library a requires b
 
Status
Not open for further replies.
Top