• 🏆 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!

Undeclared variable [Jass]

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Ok longer time ago that I start a topic but I don't get it. I want make somehow a sliding system. I just try something but I always get 4 errors:
Undeclared Variable x1
Undeclared Variable y1
Undeclared Variable x2
Undeclared Variable y2

JASS:
function Trig_Slide1_Con takes nothing returns boolean
    return (GetUnitTypeId(GetFilterUnit()) == 'h000') and (GetTerrainType(x1, y1) == 'Idki')
endfunction

function Trig_Slide1_Act takes nothing returns nothing
    call SetUnitPositionLoc(GetEnumUnit(), Location(x2, y2))
endfunction

function Trig_Slide1_Actions takes nothing returns nothing
    local real x1 = GetLocationX(GetUnitLoc(GetEnumUnit()))
    local real y1 = GetLocationY(GetUnitLoc(GetEnumUnit()))
    local real x2 = GetLocationX(GetUnitLoc(GetEnumUnit())) + 9.00 * Cos(GetUnitFacing(GetEnumUnit()))
    local real y2 = GetLocationY(GetUnitLoc(GetEnumUnit())) + 9.00 * Sin(GetUnitFacing(GetEnumUnit()))
    local group g = CreateGroup()
        
    call GroupEnumUnitsInRect(g, gg_rct_Map, Filter(function Trig_Slide1_Con))
    call ForGroup(g, function Trig_Slide1_Act)
    
    set x1 = 0
    set x2 = 0
    set y1 = 0
    set y2 = 0
    call DestroyGroup(g)
endfunction
    
//===========================================================================
function InitTrig_Slide1 takes nothing returns nothing
    set gg_trg_Slide1 = CreateTrigger(  )
    call TriggerRegisterTimerEvent(gg_trg_Slide1, 0.03, true)
    call TriggerAddAction( gg_trg_Slide1, function Trig_Slide1_Actions )
endfunction

It's the first time that I try to deal with "ForGroup" and "GroupEnumUnits" ... so I bet there will be other mistakes, but the important one is now, why I get these 4 errors???

Greetings
~ The Bomb King > Dr. Boom
 
I think you mean GetUnitX(GetEnumUnit()) and GetUnitY(GetEnumUnit()).

You can't have access to x2 and y2 because they are not global variables, so you'll have to make a global variable so that the filter can read them.

Your filter should just be:

JASS:
function Trig_Slide1_Con takes nothing returns boolean
    if (GetUnitTypeId(GetFilterUnit()) == 'h000') and (GetTerrainType(x1, y1) == 'Idki') then
        call SetUnitPosition(GetEnumUnit(), x2, y2) // don't use SetUnitPositionLoc
    endif
    return false
endfunction

And, instead of creating/destroying a group needlessly:

JASS:
call GroupEnumUnitsInRect(bj_lastCreatedGroup, gg_rct_Map, Filter(function Trig_Slide1_Con))

bj_lastCreatedGroup always exists, never destroyed, so for a quick enum-grab like this it's all you need.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Ok thing is I want to make one of my older trigger into Jass:

http://www.hiveworkshop.com/forums/world-editor-help-zone-98/slippery-ice-trigger-blues-help-ice-trigger-unsolved-172954/#post1646834

And in Jass I don't want use variables just locals. I converted this GUI Trigger to jass to see the basic how it looks like and then I create this Jass trigger ( in my first post here ) but this doesn't work.

So I need a Jass trigger that work, like this GUI trigger. [And for those you don't understand: I just want a jass trigger with the same function ( no need improvements at this case and no people who say... no make this not this ...)

Greetings
~ The Bomb King > Dr. Boom
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Hmm can you show me the GUI trigger in Jass with globals please?^^

Maybe we mean the same but I say something different. Actually I don't know much about jass - so if you can show me the full trigger in jass - I can see

Thanks and greetings
~ The Bomb King > Dr. Boom
 
Status
Not open for further replies.
Top