1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  4. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  5. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Editor Bug? Can't initialize Gamecaches

Discussion in 'World Editor Help Zone' started by Anachron, Jan 19, 2009.

  1. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Well I am having problems with initialysing gamecaches.

    Everytime I do: set udg_GameCache = InitGameCache("Whatever")
    My Editor says: Can't convert string to GameCache

    WTF?

    udg_GameCache is a GameCache.. o_O
     
  2. D3zmodos

    D3zmodos

    Joined:
    Aug 9, 2008
    Messages:
    66
    Resources:
    0
    Resources:
    0
    Ok well my experience with JASS is rather limited so forgive me if I am wrong here:
    Its not complaining about the "udg_GameCache" part, if it where it would say "udg_GameCache is an undeclared variable" or something similar. The problem lies in the parameter the stuff in brackets after InitGameCache. It wants to see a Gamecache there but you give it a string. Maybe you mispelled it or something similar.

    I hope (but Im not being very hopeful :p) that this helps :)
     
  3. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    That should work... Could you post the whole function? The problem might lie in another line
     
  4. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Another problem


    Code (vJASS):
    private function Conditions takes unit caster returns boolean
      return GetSpellAbilityId() == AID and IsUnitPaused(caster) == false
    endfunction


    set g = GroupEnumUnitsInRange  (g, x, y,  256.00, Condition(function ConditionsOfEnum(caster)))


    The JassHelper says:
    Syntax error ( set g ... )
    Unable to use nothing here (g).

    Well and the function with the Gamecache is the normal function like in Local Handle Vars, I just replaced it with a global variable with type gamecache.
     
  5. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,944
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    set udg_GameCache = InitGameCache("Whatever") works fine if GameCache is a cache variable.

    set g = GroupEnumUnitsInRange (g, x, y, 256.00, Condition(function ConditionsOfEnum(caster)))
    Has to be inside a function. JASS only lets you execute code within functions for a logical reason. Thus what you are doing makes no sense.
     
  6. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    it actually is,...

    so the JNGP text is something like this:

    Code (vJASS):

    function condition takes unit u returns boolen
       return blah..
    endfunction

    function blah takes nothing returns nothing
    set g = GroupEnumUnitsInRange  (g, x, y,  256.00, Condition(function ConditionsOfEnum(caster)))
    endfunction

     


    I think the problem is the unit that I transfair with the condition, or?
     
  7. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Yup... condition functions shouldn't take parameters.

    And g is never declared... Is it a global variable?
     
  8. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    g actually is declared, I just removed it because its a bit waste of code I thought.

    But how the hell can I get a distant variable else, then?

    I am using Local Handle Vars Btw.
     
  9. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,944
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Well, you can not ask for help with syntax errors unless you post the WHOLE code and list ALL the variables used.

    Remember that functions can not call functions below them in the script.
     
  10. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Ok,
    here is an example of the code:

    Code (vJASS):
    function condition takes nothing returns nothing
    return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetFilterUnit())) == true
    endfunction

    function action takes nothing returns nothing
    local group g
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real x = GetUnitX(target)
    local real y = GetUnitY(target)

    set g = GroupEnumUnitsInRange (g, x, y, 256.00, Condition(function Conditions))

    call DestroyGroup(g)

    set g = null
    endfunction
     

    The only problem is that I don't want to check the owner of the Filterunit, but the owner of the caster. Is that possible?
     
  11. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,944
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Code (vJASS):

    globals
        player ActionOwner
    endglobals

    function Conditions takes nothing returns boolean
        return IsUnitEnemy(GetFilterUnit(),ActionOwner)
    endfunction

    function action takes nothing returns nothing
        local unit caster = GetTriggerUnit()
        local unit target = GetSpellTargetUnit()
        local real x = GetUnitX(target)
        local real y = GetUnitY(target)
        local group g = CreateGroup()

        set ActionOwner = GetOwningPlayer(caster)
        set g = GroupEnumUnitsInRange(g, x, y, 256, Condition(function Conditions))
        //set ActionOwner = null //Only needed if the caster will be destroyed shortly and the spell never recast, otherwise leave this disabled.

        call DestroyGroup(g)

        set g = null
        set caster = null
        set target = nill
    endfunction
     


    Notice the changes.
     
  12. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Lol a global player in local use, thanks man, didn't thought it was that easy.
    Damn, I think to difficult.
     
  13. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,944
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    It is not in local use, it is used as a global to transfer data between functions, however as there are no delays, this method provides full MUI.
     
  14. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Yeah, but how can you do it with delay?
     
  15. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,944
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Enum conditions do not let you use delays (doing so causes a execution crash stopping the imediate chain from being executed(all code run after the wait is not run)), so I do not know why you are asking.
     
  16. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Well, so waits can only be made while saving it in a global variable. THanks man, I learned again.

    JASS is so mysterious. Anyway, JASS rocks.
     
  17. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,944
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I never said that. Locals last until the end of a function, and that includes having waits in the middle of it.

    What I said is that in enum conditions, you can not wait as that causes a execution crash.
     
  18. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Thats what I meant.. Anyway, do you use Local Handle Vars or what?