Undeclared variable problem

killingdyl

Active Member
Reaction score
6
Bare with me, i am very new to jass. I am making this trigger but i keep getting this error with an undeclared variable and i know i declared it.
Heres the code
JASS:
function Trig_Elemental_Vortex_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001Func001Func002C takes nothing returns boolean
    if ( not ( GetUnitTypeId(Dummy[(bj_forLoopAIndex)]) == 'h002' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001Func001C takes nothing returns boolean
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false ) ) then
        return false
    endif
    if ( not ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit())) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001A takes nothing returns nothing
    if ( Trig_Elemental_Vortex_Func011Func001Func001C() ) then
        if ( Trig_Elemental_Vortex_Func011Func001Func001Func002C() ) then
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl" )
        else
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" )
        endif
    else
        call DoNothing(  )
    endif
endfunction

function Trig_Elemental_Vortex_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location casterLoc = GetUnitLoc(GetTriggerUnit())
    local real Real = 0
    local location array LocOffset
    local unit array Dummy
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 8
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        set LocOffset[(bj_forLoopAIndex)] = PolarProjectionBJ(casterLoc, 700.00, Real)
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), "move", LocOffset[bj_forLoopAIndex] )
        call UnitApplyTimedLifeBJ( 3.50, 'BTLF', GetLastCreatedUnit() )
        set Dummy[(bj_forLoopAIndex)] = GetLastCreatedUnit()
        set Real = (Real + (360/8))
        set LocOffset[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set Real = (360/16)
    set bj_forLoopAIndex = 9
    set bj_forLoopAIndexEnd = 16
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, 'h002', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        set LocOffset[(bj_forLoopAIndex)] = PolarProjectionBJ(casterLoc, 500.00, Real)
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), "move", LocOffset[bj_forLoopAIndex] )
        call UnitApplyTimedLifeBJ( 3.50, 'BTLF', GetLastCreatedUnit() )
        set Dummy[(bj_forLoopAIndex)] = GetLastCreatedUnit()
        set Real = (Real + (360/8))
        set LocOffset[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction( 3.45 )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 16
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForGroupBJ( GetUnitsInRangeOfLocAll(50.00, GetUnitLoc(Dummy[(bj_forLoopAIndex)])), function Trig_Elemental_Vortex_Func011Func001A )
        set Dummy[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set casterLoc = null
endfunction

//===========================================================================
function InitTrig_Elemental_Vortex takes nothing returns nothing
    set gg_trg_Elemental_Vortex = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Elemental_Vortex, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Elemental_Vortex, Condition( function Trig_Elemental_Vortex_Conditions ) )
    call TriggerAddAction( gg_trg_Elemental_Vortex, function Trig_Elemental_Vortex_Actions )
endfunction

Also if u find any leaks tell me please. Thanks
 

Lehona

New Member
Reaction score
12
Seems like converted GUI :(

And tell us what variables seems not to be declared.
 

Exide

I am amazingly focused right now!
Reaction score
448
You are using a local variable in another function:

First you declare the variable in this function:
function Trig_Elemental_Vortex_Actions takes nothing returns nothing

Then you are using it in a condition:
function Trig_Elemental_Vortex_Func011Func001Func001Func002C takes nothing returns boolean

local variables doesn't transfer between functions.

(It's the 'Dummy' variable, btw.)

You should loop through it in the same function as you declared it in, and remove that condition completely.

Converted GUI is horrible, btw. :p
 

killingdyl

Active Member
Reaction score
6
ok can u walk me through it or something, and im using locals cuz im making them mui. As i said very very new to this. (and i know converted gui is horrible, but gotta start somewhere right?)
 

shiFt

Member
Reaction score
8
Declare all the variables that you would need in more than one function at the top of the trigger in a globals block.
JASS:
globals // this is the block
       unit Dummy 
endglobals


Then when you use the variable set a value to it in the function you want to use , random example making a dummy unit at a units location:
JASS:
set Dummy= CreateUnit(Player, DummyUnit, GetWidgetX(U), GetWidgetY(U) ,0.00)
 

Lehona

New Member
Reaction score
12
You need vJass/NewGen for that - if you don't want to use it (I recommend you to, but maybe you have a Mac or sth.) just declare it as a GUI-Variable and use udg_<name>.
 

shiFt

Member
Reaction score
8
..or you can just get NewGen :), its alot better/easier to learn that way, iv found
 

Exide

I am amazingly focused right now!
Reaction score
448
I haven't used World Editor in a long time, and my skills are very rusty.
I will help you with a few hints first:

When using a loop in GUI, WE (by default) uses the variables:
bj_forLoopAIndex and bj_forLoopAIndexEnd
_Index is the number that changes for each loop, and _End is for the game to know when to stop looping. -Logic.

We can replace these with a local integer variable:
JASS:

function blabla takes nothing returns nothing
local integer i = 0
loop
exitwhen i &gt; 10    //This loop goes from 0 to 10 = eleven times
//Do actions..
set i = i + 1
endloop
endfunction


This loop is now perfectly local.

Now you can add a condition, by adding 'If/Then':

JASS:

if (GetUnitTypeId(Dummy[*Local_Integer_Variable_Here*]) == &#039;h002&#039;) then
//Put actions here..
endif


If you put this condition within the loop, it should check every unit's Id in the Dummy Variable.


If we put it all together it should look something like this:

JASS:

function myloop takes nothing returns nothing
local integer i = 0
//Don&#039;t forget to declare the local Dummy -variable!

loop
exitwhen i &gt; 10

if (GetUnitTypeId(Dummy<i>) == &#039;h002&#039;) then
//Put actions here..
endif

set i = i + 1
endloop

endfunction
</i>
 

Exide

I am amazingly focused right now!
Reaction score
448

cleeezzz

The Undead Ranger.
Reaction score
268
>How would i combine it into 1(one) function?

you cant, you need at least two (for what you're trying to do)

you need to 1. define the trigger, add event/action. and then 2. the action itself

i suggest you make a working GUI trigger, convert it to JASS, look up a tutorial (theres a bunch that help you move from GUI to JASS), and learn how to change converted GUI into good JASS. thats probably the best way to learn

btw, hi exide
 

killingdyl

Active Member
Reaction score
6
How would i combine these functions? I have taken it apart and figured out what each part does, every time theres an if/then/else in gui, it makes it into a seperate function. How do i fix that?

Here are the action codes:
JASS:
function Trig_Elemental_Vortex_Func011Func001Func001Func002C takes nothing returns boolean
    if ( not ( GetUnitTypeId(Dummy[(bj_forLoopAIndex)]) == &#039;h002&#039; ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001Func001C takes nothing returns boolean
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false ) ) then
        return false
    endif
    if ( not ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit())) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001A takes nothing returns nothing
    if ( Trig_Elemental_Vortex_Func011Func001Func001C() ) then
        if ( Trig_Elemental_Vortex_Func011Func001Func001Func002C() ) then
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), &quot;Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl&quot; )
        else
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), &quot;Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl&quot; )
        endif
    else
        call DoNothing(  )
    endif
endfunction

function Trig_Elemental_Vortex_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location casterLoc = GetUnitLoc(GetTriggerUnit())
    local real Real = 0
    local location array LocOffset
    local unit array Dummy
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 8
    loop
        exitwhen bj_forLoopAIndex &gt; bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, &#039;h003&#039;, GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        set LocOffset[(bj_forLoopAIndex)] = PolarProjectionBJ(casterLoc, 700.00, Real)
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), &quot;move&quot;, LocOffset[bj_forLoopAIndex] )
        call UnitApplyTimedLifeBJ( 3.50, &#039;BTLF&#039;, GetLastCreatedUnit() )
        set Dummy[(bj_forLoopAIndex)] = GetLastCreatedUnit()
        set Real = (Real + (360/8))
        set LocOffset[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set Real = (360/16)
    set bj_forLoopAIndex = 9
    set bj_forLoopAIndexEnd = 16
    loop
        exitwhen bj_forLoopAIndex &gt; bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, &#039;h002&#039;, GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        set LocOffset[(bj_forLoopAIndex)] = PolarProjectionBJ(casterLoc, 500.00, Real)
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), &quot;move&quot;, LocOffset[bj_forLoopAIndex] )
        call UnitApplyTimedLifeBJ( 3.50, &#039;BTLF&#039;, GetLastCreatedUnit() )
        set Dummy[(bj_forLoopAIndex)] = GetLastCreatedUnit()
        set Real = (Real + (360/8))
        set LocOffset[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction( 3.45 )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 16
    loop
        exitwhen bj_forLoopAIndex &gt; bj_forLoopAIndexEnd
        call ForGroupBJ( GetUnitsInRangeOfLocAll(50.00, GetUnitLoc(Dummy[(bj_forLoopAIndex)])), function Trig_Elemental_Vortex_Func011Func001A )
        set Dummy[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set casterLoc = null
endfunction
 

Lehona

New Member
Reaction score
12
Instead of
JASS:
 If (MyFunc()) then

write

JASS:
 If (WhatShouldBeTrue == true) then


So in your example:
JASS:
function Trig_Elemental_Vortex_Func011Func001A takes nothing returns nothing
    if (( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false) and ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit())) == false) then
        if ( Trig_Elemental_Vortex_Func011Func001Func001Func002C() ) then
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), &quot;Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl&quot; )
        else
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), &quot;Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl&quot; )
        endif
    else
        call DoNothing(  )
    endif
endfunction


And so on.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top