• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Please Help

Status
Not open for further replies.
Level 3
Joined
Nov 3, 2017
Messages
34
Guys hello to everyone! Help to understand, I can not understand what's wrong. The meaning is such that I in a non-standard code prescribed functions!

JASS:
function SaveUnit takes handle param1, string param2, unit value returns nothing
       call SaveUnitHandle(udg_Cache, GetHandleId(param1), StringHash(param2), value)
endfunction
  
function GetUnit takes handle param1, string param2 returns unit
       return LoadUnitHandle(udg_Cache, GetHandleId(param1), StringHash(param2))
endfunction

In one trigger, when I call them all right, everything works fine, and in another trigger it says that there is no such function and it does not really save anything and the card does not work
 
Last edited by a moderator:
I fixed your tags to [code=jass].

In one trigger, when I call them all right, everything works fine, and in another trigger it says that there is no such function and it does not really save anything and the card does not work
Where's the code? - Ensure called functions are above the caller function. A function must be previously/above defined that an other can use it.
 
If you use the defaul world editor:
  • WE often prints out false erros, if you call a function which is not in the same File/Trigger and recently wrote/Insert the function, until the Map is saved + reopened.
  • To be able to save, even with in World Editors opinion wierd Code, make sure there is an function inside the map's head.
for example this one
JASS:
function EnableCode takes nothing returns nothing
endfunction
 
Level 3
Joined
Nov 3, 2017
Messages
34
I fixed your tags to [code=jass].


Where's the code? - Ensure called functions are above the caller function. A function must be previously/above defined that an other can use it.

Code:
function ASMain(){
        trigger t = CreateTrigger();
        unit u = GetTriggerUnit();
        unit s = GetSpellTargetUnit();
        SaveUnit(t, "ASCaster", u);
        SaveUnit(t, "ASTarget", s);
        SaveBool(t, "ASFinish", false);
        TriggerRegisterTimerEventPeriodic(t, 0.00001);
        TriggerAddAction(t, function ASAction);
    }


Here it writes function unknown SaveUnit
 
Level 3
Joined
Nov 3, 2017
Messages
34
You trolling? Make proper sense, post all code, give all information.

Non-standard code:

Code:
function InitHash takes nothing returns hashtable
        if bj_lastCreatedHashtable == null then
            set bj_lastCreatedHashtable = InitHashtable()
        endif
        return bj_lastCreatedHashtable
    endfunction
      
    function SX takes integer paramInteger_1 returns nothing
        call FlushChildHashtable(udg_Cache, paramInteger_1)
    endfunction
  
    function SvStr takes integer param1, string param2, string value returns nothing
        call SaveStr(udg_Cache, param1, StringHash(param2), value)
    endfunction
  
    function GetStr takes integer param1, string param2 returns string
        return LoadStr(udg_Cache, param1, StringHash(param2))
    endfunction
  
    function SaveUnit takes handle param1, string param2, unit value returns nothing
        call SaveUnitHandle(udg_Cache, GetHandleId(param1), StringHash(param2), value)
    endfunction
  
    function GetUnit takes handle param1, string param2 returns unit
        return LoadUnitHandle(udg_Cache, GetHandleId(param1), StringHash(param2))
    endfunction
  
    function SaveInt takes handle param1, string param2, integer value returns nothing
        call SaveInteger(udg_Cache, GetHandleId(param1), StringHash(param2), value)
    endfunction
  
    function GetInt takes handle param1, string param2 returns integer
        return LoadInteger(udg_Cache, GetHandleId(param1), StringHash(param2))
    endfunction
  
    function SaveBool takes handle param1, string param2, boolean value returns nothing
        call SaveBoolean(udg_Cache, GetHandleId(param1), StringHash(param2), value)
    endfunction
  
    function GetBool takes handle param1, string param2 returns boolean
        return LoadBoolean(udg_Cache, GetHandleId(param1), StringHash(param2))
    endfunction
  
    function SpellPreload takes integer paramInteger_1 returns nothing
        local unit dummy = CreateUnit(Player(15), 'u001', 0, 0, 270)
        call UnitAddAbility(dummy, paramInteger_1)
        call UnitRemoveAbility(dummy, paramInteger_1)
        call RemoveUnit(dummy)
    endfunction

Text Trigger:

Code:
//! zinc

library AimedShot{

    constant integer SPELL_ID = 'A02Y';
    constant integer DUMMY_SPELL = 'A033';
    constant integer BUFF_ID = 'B01S';
    constant integer DUMMY = 'u001';
  
    function ASCon() -> boolean{
        return GetSpellAbilityId() == SPELL_ID;
    }
    function ASAction(){
        trigger t = GetTriggeringTrigger();
        unit u = GetUnit(t, "ASCaster");
        unit s = GetUnit(t, "ASTarget");
        unit d;
        if (GetUnitState(s, UNIT_STATE_LIFE) > 0){
            if (GetUnitAbilityLevel(s, BUFF_ID) > 0){
                DisableTrigger(t);
                SaveBool(t, "ASFinish", true);
                d = CreateUnit(GetOwningPlayer(u), DUMMY, GetUnitX(s), GetUnitY(s), bj_UNIT_FACING);
                UnitAddAbility(d, DUMMY_SPELL);
                SetUnitAbilityLevel(d, DUMMY_SPELL, GetUnitAbilityLevel(u, SPELL_ID));
                UnitApplyTimedLife(d, 'BTLF', 1.);
                SetUnitPathing(d, false);
                ShowUnit(d, false);
                IssueTargetOrder(d, "drunkenhaze", s);
                d = null;
                if (GetUnitAbilityLevel(u, SPELL_ID) >= 4){
                    ADamage(u, s, GetHeroInt(u, true));
                }
                if (GetBool(t, "ASFinish") == true){
                    SX(GetHandleId(t));
                    DestroyTrigger(t);
                }
            }
        }
        else{
            DisableTrigger(t);
            SX(GetHandleId(t));
            DestroyTrigger(t);
        }
        t = null;
        u = null;
        s = null;
    }
    function ASMain(){
        trigger t = CreateTrigger();
        unit u = GetTriggerUnit();
        unit s = GetSpellTargetUnit();
        SaveUnit(t, "ASCaster", u);
        SaveUnit(t, "ASTarget", s);
        SaveBool(t, "ASFinish", false);
        TriggerRegisterTimerEventPeriodic(t, 0.00001);
        TriggerAddAction(t, function ASAction);
    }
    function onInit(){
        gg_trg_Aimed_Shot = CreateTrigger();
        TriggerRegisterAnyUnitEventBJ(gg_trg_Aimed_Shot, EVENT_PLAYER_UNIT_SPELL_EFFECT);
        TriggerAddCondition(gg_trg_Aimed_Shot, function ASCon);
        TriggerAddAction(gg_trg_Aimed_Shot, function ASMain);
        SpellPreload(DUMMY_SPELL);
    }
  
}

//! endzinc
 
Level 3
Joined
Nov 3, 2017
Messages
34
What does "not standard code" even mean? Have you read the previous tips we gave about function-caller dependency?

Yes. Well, in the editor of the triggers in the top, the name of the card, I click there and there subscribes non-standard code, I do not know how to explain. I'm new to this, I do not understand the whole lexicon
 
You should always explain, and give information instead of letting us work on assumptions. One code is working, one not -> you post one code, without any explaining.

Anyways you maybe meant you put the code into the map header in the trigger editor, which will be defined before normal GUI trigger.
So in "normal" triggers, in GUI, it should work to call functions from the header.
But a library code comes first, so the functions you need are not above. A library can require an other library to ensure the order position the library code gets generated.

I guess it's explained in the manual how to require an other library.
 
Level 3
Joined
Nov 3, 2017
Messages
34
You should always explain, and give information instead of letting us work on assumptions. One code is working, one not -> you post one code, without any explaining.

Anyways you maybe meant you put the code into the map header in the trigger editor, which will be defined before normal GUI trigger.
So in "normal" triggers, in GUI, it should work to call functions from the header.
But a library code comes first, so the functions you need are not above. A library can require an other library to ensure the order position the library code gets generated.

I guess it's explained in the manual how to require an other library.

Got it. Happened! Thank you!
 
Status
Not open for further replies.
Top