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

[JASS] Need to know what I did wrong

Status
Not open for further replies.
Level 7
Joined
Jan 22, 2013
Messages
293
JASS:
function A1_Actions takes nothing returns nothing
    set ugd_TempUnit = GetTriggerUnit(  ) // (which is the unit enters region/rect and tosses them over to another trigger)
    set udg_TempUnitGroup = udg_site1  // set a temp unit group that will travel over when Function X12 is called
    call TriggerExecute( function X12 ) // runs function X12 which is an instant to work like a Multiple trigger instance
endfunction

function A1 takes nothing returns nothing
    local region R1 = CreateRegion(  ) 
    set A1 = CreateTrigger(  )
    call RegionAddRect( R1, gg_rct_site_1) // adding pre-placed rect to local region
    call TriggerRegisterEnterRegion( A1, R1) // detects the entering unit of local region
    call TriggerAddAction( A1, function A1_Actions ) //runs A1_actions
    set R1 = null //recycles the local
endfunction

Well, I am helping a person save space on their map so I have taken his wall of 25 enter region triggers (which all need to be separate)

(I understand udg_Variables OH NO, Yes it is ugly as sin, but it needs to be use-able with this guys GUI so he can understand it with his custom scripting.)

I believe my problem is with the Unit Group, I just don't know for sure what the hell is wrong, I have never been able to have my Jass helper work, it freezes up when loading the issues then my maps always shut down so I don't have that option.

Any solutions?
 
Level 7
Joined
Apr 5, 2011
Messages
245
Mm... o_O Pointing on mistake maybe?
Look, here is the right way to make trigger work:
JASS:
function Trig_fffdfgawefaw_Actions takes nothing returns nothing
    call DoNothing(  )
endfunction

//===========================================================================
function InitTrig_fffdfgawefaw takes nothing returns nothing
    set gg_trg_fffdfgawefaw = CreateTrigger(  )
    call TriggerAddAction( gg_trg_fffdfgawefaw, function Trig_fffdfgawefaw_Actions )
endfunction
Function InitTrig_fffdfgawefaw is called during map init. Then function creates triggers and trigger catches event.
 
Level 7
Joined
Jan 22, 2013
Messages
293
Mm... o_O Pointing on mistake maybe?
Look, here is the right way to make trigger work:
JASS:
function Trig_fffdfgawefaw_Actions takes nothing returns nothing
    call DoNothing(  )
endfunction

//===========================================================================
function InitTrig_fffdfgawefaw takes nothing returns nothing
    set gg_trg_fffdfgawefaw = CreateTrigger(  )
    call TriggerAddAction( gg_trg_fffdfgawefaw, function Trig_fffdfgawefaw_Actions )
endfunction
function InitTrig_fffdfgawefaw is called during map init. Then function creates triggers and trigger catches event.



Ok so I got to set up a intilize trigger to create the functions, gotcha.

JASS:
function InitTrig_A takes nothing returns nothing
    set A1 = CreateTrigger(  )
endfunction

So something like this instead of having it inside the function A1
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
The problem is set A1 = CreateTrigger() and not the name of the function.

ap0calypse said:
Functions and triggers are different. If your trigger name (in the editor) is "A1", then it is actually named "gg_trg_A1" and not "A1".

You can replace it with local trigger t = CreateTrigger(), or set gg_trg_A1 = CreateTrigger(), or even A1, but then you have to define a global variable with the name "A1".
 
Level 7
Joined
Jan 22, 2013
Messages
293
The problem is set A1 = CreateTrigger() and not the name of the function.



You can replace it with local trigger t = CreateTrigger(), or set gg_trg_A1 = CreateTrigger(), or even A1, but then you have to define a global variable with the name "A1".

lol well none of my triggers in the file are going to use the name of the "trigger name (in the editor)" Anyway, So you are saying I have to make them Globals. I never used "Globals yet" I believe they are placed in the map's script rather then in a trigger file correct?


I have 25 of that same function in one trigger file (In editor) so Yes I would most likely need the Globals then since I am not using the (Trigger name in Editor) Correct?

Edit: wait a moment I will post a example on what I received from what you said

So

JASS:
function A1_Actions takes nothing returns nothing
    set ugd_TempUnit = GetTriggerUnit(  )
    set udg_TempUnitGroup = udg_site1
    call TriggerExecute( function X12 )

function A1 takes nothing returns nothing
    local region R1 = CreateRegion(  )
    local trigger A1 = CreateTrigger(  )
    call RegionAddRect( R1, gg_rct_site_1)
    call TriggerRegisterEnterRegion( A1, R1)
    call TriggerAddAction( A1, function A1_Actions )
    // Local region should get nulled correct?
endfunction
The above shouldn't need the Global now correct?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
lol well none of my triggers in the file are going to use the name of the "trigger name (in the editor)" Anyway, So you are saying I have to make them Globals. I never used "Globals yet" I believe they are placed in the map's script rather then in a trigger file correct?
As I've said twice before: you can also use a local trigger if you're not sure about the globals.
You probably have used globals before, though. If you've ever create any variable in the GUI variable editor, you've created a global.

With JNGP, you can define globals like this:
JASS:
globals
    trigger A1
    trigger A2
endglobals
Doesn't matter where this is placed in the script (it will always be moved to the top anyway).

Without JNGP, you can create them in the variable editor (though they will be named "udg_varName" in that case).

The easiest is still local trigger t = CreateTrigger().
 
Level 7
Joined
Jan 22, 2013
Messages
293
JASS:
globals
    trigger A1
    trigger A2
    trigger A3
    trigger A4
    trigger A5
    trigger A6
    trigger A7
    trigger A8
    trigger A9
    trigger A10
    trigger A11
    trigger A12
    trigger A13
    trigger A14
    trigger A15
    trigger A16
    trigger A16
    trigger A17
    trigger A18
    trigger A18
    trigger A19
    trigger A20
    trigger A21
    trigger A22
    trigger A23
    trigger A24
    trigger A25
    unit B1
    group C1
endglobals

function A1_Actions takes nothing returns nothing
    set B1 = GetTriggerUnit()
    set C1 = udg_site1
    call TriggerExecute( gg_trg_Mystical_Site_Insta_Trigger )

function A1 takes nothing returns nothing
    local region R1 = CreateRegion()
    set A1 = CreateTrigger()
    call RegionAddRect( R1, gg_rct_site_1)
    call TriggerRegisterEnterRegion( A1, R1)
    call TriggerAddAction( A1, function A1_Actions )
endfunction

not working
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
nobody noticed?

JASS:
    call TriggerExecute( function X12 )
->
JASS:
    call TriggerExecute( some_trigger_variable )

TriggerExecute takes a trigger not a code(function)
TriggerExecute runs all functions registered to the trigger via TriggerAddAction

to the A1 problem
As maker said, you should change the name of function A1

You cant have function and global or local(or both) variables with same name. How would compiler know when you are trying to use function object and when variable?
 
nobody noticed?

JASS:
    call TriggerExecute( function X12 )
->
JASS:
    call TriggerExecute( some_trigger_variable )

TriggerExecute takes a trigger not a code(function)
TriggerExecute runs all functions registered to the trigger via TriggerAddAction

to the A1 problem
As maker said, you should change the name of function A1

You cant have function and global or local(or both) variables with same name. How would compiler know when you are trying to use function object and when variable?

wow lol i guess not. ik i didnt notice it lol.

if u want to run a function in jass do it this way
JASS:
call X12()
if it takes arguements put the arguements in the correct order. in the parenthesis. seperate them by commas.

the actions in GUI are function calls.
 
Level 7
Joined
Jan 22, 2013
Messages
293
JASS:
function A1_Actions takes nothing returns nothing
    set ugd_TempUnit = GetTriggerUnit(  )
    set udg_TempUnitGroup = udg_site1
    call TriggerExecute( function X12 )
 
function A1 takes nothing returns nothing
    local region R1 = CreateRegion(  )
    local trigger A1 = CreateTrigger(  )
    call RegionAddRect( R1, gg_rct_site_1)
    call TriggerRegisterEnterRegion( A1, R1)
    call TriggerAddAction( A1, function A1_Actions )
    // Local region should get nulled correct?
endfunction


I have to admit, you guys pointed out some good things but the most important one, I removed intentionally to see what sort of help I am getting.

Notice:
JASS:
function A1_Actions takes nothing returns nothing
    set ugd_TempUnit = GetTriggerUnit(  )
    set udg_TempUnitGroup = udg_site1
    call TriggerExecute( function X12 )
// Uh oh. no endfunction

Guys..... nothing even needs said on that.


Other:

Ok so I clearly don't understand some of the structure, well not many people explain the minor detail structuring they explain the primary structure then these new jass people are always struggling. Well, I am now going to ask you guys questions that will allow me to fix it instead of asking you guys to give me example on how to fix what you see.

1. Why does a Function Only called A1 Conflict with a Global named Trigger A1, if Global A1 is the trigger referring to Function A1. Don't give me an answer like, well Trigger's and functions are different. Well I know that, but that doesn't tell me how to get Function A1 to only be called A1, to tell me.

2. If I am told that have to have an InitTrig_A1, then does an InitTrig_A1 work like a Init Event like in GUI, or does this just allow the function to exist in general.

3. If I have 25 Functions working separately that only hold events, do then need InitTrig_[TriggerName] I mean like If you are converting between GUI to Jass and you always known Init Triggers to always run the triggers when they have that event, you aren't thinking of InitTrig_A1 for Jass because you have only ever known it as an event rather then Registering the events into the start of the game to even work.

4. If I have the name of the function as InitTrig_A1 do I still use the name A1 to refer to the function's name.

5. How many InitTrig_BLah Functions can you have in a single trigger file, and if only 1 is the case how in the hell can I get 25 of them to all work in one Trigger Editor File.

6. Does a Local region need nulled, cause most locals always need nulled.

JASS:
function A1_Actions takes nothing returns nothing
    set B1 = GetTriggerUnit()
    set C1 = udg_site1
    call TriggerExecute( gg_trg_Mystical_Site_Insta_Trigger )
endfunction
 
function A1 takes nothing returns nothing
    local region R1 = CreateRegion()
    set A1 = CreateTrigger()
    call RegionAddRect( R1, gg_rct_site_1 )
    call TriggerRegisterEnterRegion( A1, R1 )
    call TriggerAddAction( A1, function A1_Actions )
endfunction

the call triggereexecute I was making look more simple but this is what the call trigger's name really is.
 
Ok so I clearly don't understand some of the structure, well not many people explain the minor detail structuring they explain the primary structure then these new jass people are always struggling. Well, I am now going to ask you guys questions that will allow me to fix it instead of asking you guys to give me example on how to fix what you see.

1. Why does a Function Only called A1 Conflict with a Global named Trigger A1, if Global A1 is the trigger referring to Function A1. Don't give me an answer like, well Trigger's and functions are different. Well I know that, but that doesn't tell me how to get Function A1 to only be called A1, to tell me.

2. If I am told that have to have an InitTrig_A1, then does an InitTrig_A1 work like a Init Event like in GUI, or does this just allow the function to exist in general.

3. If I have 25 Functions working separately that only hold events, do then need InitTrig_[TriggerName] I mean like If you are converting between GUI to Jass and you always known Init Triggers to always run the triggers when they have that event, you aren't thinking of InitTrig_A1 for Jass because you have only ever known it as an event rather then Registering the events into the start of the game to even work.

4. If I have the name of the function as InitTrig_A1 do I still use the name A1 to refer to the function's name.

5. How many InitTrig_BLah Functions can you have in a single trigger file, and if only 1 is the case how in the hell can I get 25 of them to all work in one Trigger Editor File.

6. Does a Local region need nulled, cause most locals always need nulled.

first the one u didnt number ill be covering this in my tutorial when i get a chnace to edit it.

now onto the questions
1) its like creating 2 different variables with the same name. the compiler says it cant be done because it doesnt know what variable u r using at the time.

2)InitTrig is what GUI / Jass uses to create a trigger since they cant be created in the globals block

3) the only time u need InitTrig is to create a trigger or other things need for the functions to work.
i use this to easily display text for me in my map.
JASS:
function textall takes string s, integer p returns nothing
    local integer L = 0
    loop
        exitwhen L > 5
        call DisplayTimedTextToPlayer( Player(L), 0,0, 5, playerColors + s + color)
        set L = L + 1
    endloop
endfunction

function textallPlayerC takes string s returns nothing
    local integer p = 0
    loop
        exitwhen p > 5
        call DisplayTimedTextToPlayer( Player(p), 0,0, 5, playerColors + s + color)
        set p = p + 1
    endloop
endfunction

function text takes string s, integer p returns nothing
    call DisplayTimedTextToPlayer( Player(p), 0,0, 10, playerColors + s + color)
endfunction

function texti takes integer s returns nothing
    call DisplayTimedTextToPlayer( Player(0), 0,0, 20, playerColors[0] + I2S(s) + color)
endfunction

function textr takes real s returns nothing
    call DisplayTimedTextToPlayer( Player(0), 0,0, 20, playerColors[0] + R2S(s) + color)
endfunction
JASS:
function InitTrig_Battlegrounds takes nothing returns nothing
    local trigger t = CreateTrigger()
    local trigger t1 = CreateTrigger()
    local trigger t2 = CreateTrigger()
    local trigger t3 = CreateTrigger()
    local trigger t4 = CreateTrigger()
    local region r = CreateRegion()
    call startup()
    set trg_BKC_Timers = CreateTrigger()
    call TriggerAddAction( trg_BKC_Timers, function timerStartup)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddAction( t, function kills)
    call TriggerRegisterEnterRegion( t1, KotBr, null)
    call TriggerAddAction( t1, function KotB_adding)
    call TriggerRegisterLeaveRegion( t2, KotBr, null)
    call TriggerAddAction( t2, function KotB_leaving)
    call TriggerAddAction( t3, function leader)
    call RegionAddRect( r, gg_rct_Battlegrounds_Entrance_P0)
    call RegionAddRect( r, gg_rct_Battlegrounds_Entrance_P1)
    call RegionAddRect( r, gg_rct_Battlegrounds_Entrance_P2)
    call RegionAddRect( r, gg_rct_Battlegrounds_Entrance_P3)
    call RegionAddRect( r, gg_rct_Battlegrounds_Entrance_P4)
    call RegionAddRect( r, gg_rct_Battlegrounds_Entrance_P5)
    call TriggerRegisterEnterRegion( t4, r, null)
    call TriggerAddAction( t4, function moveUnits)
    set t4 = null
    set r = null
    set t = null
    set t1 = null
    set t2 = null
endfunction

4) no it doesnt the name is now InitTrig_A1 instead of just A1

5)i think u can have multiple but its not needed. u can create all 25 events and triggers in one InitTrig

6)yes all local handles need to be nulled
 
Level 7
Joined
Jan 22, 2013
Messages
293
JASS:
function InitTrig_ABC takes nothing returns nothing
    //=======================================
    //Massive local shadow lol
    //=======================================
    local trigger A1 = CreateTrigger()
    local trigger A2 = CreateTrigger()
    local trigger A3 = CreateTrigger()
    local trigger A4 = CreateTrigger()
    local trigger A5 = CreateTrigger()
    local trigger A6 = CreateTrigger()
    local trigger A7 = CreateTrigger()
    local trigger A8 = CreateTrigger()
    local trigger A9 = CreateTrigger()
    local trigger A10 = CreateTrigger()
    local trigger A11 = CreateTrigger()
    local trigger A12 = CreateTrigger()
    local trigger A13 = CreateTrigger()
    local trigger A14 = CreateTrigger()
    local trigger A15 = CreateTrigger()
    local trigger A16 = CreateTrigger()
    local trigger A17 = CreateTrigger()
    local trigger A18 = CreateTrigger()
    local trigger A19 = CreateTrigger()
    local trigger A20 = CreateTrigger()
    local trigger A21 = CreateTrigger()
    local trigger A22 = CreateTrigger()
    local trigger A23 = CreateTrigger()
    local trigger A24 = CreateTrigger()
    local trigger A25 = CreateTrigger()
    local region r1 = CreateRegion()
    local region r2 = CreateRegion()
    local region r3 = CreateRegion()
    local region r4 = CreateRegion()
    local region r5 = CreateRegion()
    local region r6 = CreateRegion()
    local region r7 = CreateRegion()
    local region r8 = CreateRegion()
    local region r9 = CreateRegion()
    local region r10 = CreateRegion()
    local region r11 = CreateRegion()
    local region r12 = CreateRegion()
    local region r13 = CreateRegion()
    local region r14 = CreateRegion()
    local region r15 = CreateRegion()
    local region r16 = CreateRegion()
    local region r17 = CreateRegion()
    local region r18 = CreateRegion()
    local region r19 = CreateRegion()
    local region r20 = CreateRegion()
    local region r21 = CreateRegion()
    local region r22 = CreateRegion()
    local region r23 = CreateRegion()
    local region r24 = CreateRegion()
    local region r25 = CreateRegion()
    //===========================================
    //Add actions and events to functions
    //===========================================
    call TriggerAddAction( A1, function A1_Actions)
    call TriggerAddAction( A2, function A2_Actions)
    call TriggerAddAction( A3, function A3_Actions)
    call TriggerAddAction( A4, function A4_Actions)
    call TriggerAddAction( A5, function A5_Actions)
    call TriggerAddAction( A6, function A6_Actions)
    call TriggerAddAction( A7, function A7_Actions)
    call TriggerAddAction( A8, function A8_Actions)
    call TriggerAddAction( A9, function A9_Actions)
    call TriggerAddAction( A10, function A10_Actions)
    call TriggerAddAction( A11, function A11_Actions)
    call TriggerAddAction( A12, function A12_Actions)
    call TriggerAddAction( A13, function A13_Actions)
    call TriggerAddAction( A14, function A14_Actions)
    call TriggerAddAction( A15, function A15_Actions)
    call TriggerAddAction( A16, function A16_Actions)
    call TriggerAddAction( A17, function A17_Actions)
    call TriggerAddAction( A18, function A18_Actions)
    call TriggerAddAction( A19, function A19_Actions)
    call TriggerAddAction( A20, function A20_Actions)
    call TriggerAddAction( A21, function A21_Actions)
    call TriggerAddAction( A22, function A22_Actions)
    call TriggerAddAction( A23, function A23_Actions)
    call TriggerAddAction( A24, function A24_Actions)
    call TriggerAddAction( A25, function A25_Actions)
    //=============================================
    //Add Rect to Local Regions
    //=============================================
    call RegionAddRect( r1, gg_rct_site_1)
    call RegionAddRect( r2, gg_rct_site_2)
    call RegionAddRect( r3, gg_rct_site_3)
    call RegionAddRect( r4, gg_rct_site_4)
    call RegionAddRect( r5, gg_rct_site_5)
    call RegionAddRect( r6, gg_rct_site_6)
    call RegionAddRect( r7, gg_rct_site_7)
    call RegionAddRect( r8, gg_rct_site_8)
    call RegionAddRect( r9, gg_rct_site_9)
    call RegionAddRect( r10, gg_rct_site_10)
    call RegionAddRect( r11, gg_rct_site_11)
    call RegionAddRect( r12, gg_rct_site_12)
    call RegionAddRect( r13, gg_rct_site_13)
    call RegionAddRect( r14, gg_rct_site_14)
    call RegionAddRect( r15, gg_rct_site_15)
    call RegionAddRect( r16, gg_rct_site_16)
    call RegionAddRect( r17, gg_rct_site_17)
    call RegionAddRect( r18, gg_rct_site_18)
    call RegionAddRect( r19, gg_rct_site_19)
    call RegionAddRect( r20, gg_rct_site_20)
    call RegionAddRect( r21, gg_rct_site_21)
    call RegionAddRect( r22, gg_rct_site_22)
    call RegionAddRect( r23, gg_rct_site_23)
    call RegionAddRect( r24, gg_rct_site_24)
    call RegionAddRect( r25, gg_rct_site_25)
    //========================================
    // Unit enters region
    //========================================
    call TriggerRegisterEnterRegion( A1, r1, null)
    call TriggerRegisterEnterRegion( A2, r2, null)
    call TriggerRegisterEnterRegion( A3, r3, null)
    call TriggerRegisterEnterRegion( A4, r4, null)
    call TriggerRegisterEnterRegion( A5, r5, null) 
    call TriggerRegisterEnterRegion( A6, r6, null)
    call TriggerRegisterEnterRegion( A7, r7, null)
    call TriggerRegisterEnterRegion( A8, r8, null)
    call TriggerRegisterEnterRegion( A9, r9, null)
    call TriggerRegisterEnterRegion( A10, r10, null) 
    call TriggerRegisterEnterRegion( A11, r11, null)
    call TriggerRegisterEnterRegion( A12, r12, null)
    call TriggerRegisterEnterRegion( A13, r13, null)
    call TriggerRegisterEnterRegion( A14, r14, null)
    call TriggerRegisterEnterRegion( A15, r15, null) 
    call TriggerRegisterEnterRegion( A16, r16, null)
    call TriggerRegisterEnterRegion( A17, r17, null)
    call TriggerRegisterEnterRegion( A18, r18, null)
    call TriggerRegisterEnterRegion( A19, r19, null)
    call TriggerRegisterEnterRegion( A20, r20, null) 
    call TriggerRegisterEnterRegion( A21, r21, null)
    call TriggerRegisterEnterRegion( A22, r22, null)
    call TriggerRegisterEnterRegion( A23, r23, null)
    call TriggerRegisterEnterRegion( A24, r24, null)
    call TriggerRegisterEnterRegion( A25, r25, null)
    //============================================
    //nulling all the locals..... 
    //============================================
    set A1 = null
    set A2 = null
    set A3 = null
    set A4 = null
    set A5 = null
    set A6 = null
    set A7 = null
    set A8 = null
    set A9 = null
    set A10 = null
    set A11 = null
    set A12 = null
    set A13 = null
    set A14 = null
    set A15 = null
    set A16 = null
    set A17 = null
    set A18 = null
    set A19 = null
    set A20 = null
    set A21 = null
    set A22 = null
    set A23 = null
    set A24 = null
    set A25 = null
    set r1 = null
    set r2 = null
    set r3 = null
    set r4 = null
    set r5 = null
    set r6 = null
    set r7 = null
    set r8 = null
    set r9 = null
    set r10 = null
    set r11 = null
    set r12 = null
    set r13 = null
    set r14 = null
    set r15 = null
    set r16 = null
    set r17 = null
    set r18 = null
    set r19 = null
    set r20 = null
    set r21 = null
    set r22 = null
    set r23 = null
    set r24 = null
    set r25 = null
endfunction

yada yada.

still not what I wanted because I need the events separate so I could easily manual set the regions instead of having to make a loop. Because for one, I suck at making loops in Jass lmao, but yeah w/e.


I have a question, about the null behind the TriggerRegisterEnterRegion. Is there a way for me to use that in some way to locate which event has gone off? o_O
 
Level 7
Joined
Jan 22, 2013
Messages
293
nope but u can find the region in the action the trigger triggers through the TriggerAddAction()

u can use a
JASS:
local region r = GetTriggeringRegion()

DAMIT dude, I asked you like 8 time sin private messages for something like that, god damit.

I'd give you rep if I could
 
Whats this massive block of enter region events for?
A tower defence movement trigger? In this case, you can probably go with one single event and store the "move to" coordinates in an array instead of having 25 different functions.

You can also abuse ExecuteFunc(" bla ") with string concatenation to avoid having to register 25 functions manually, but it breaks the "compress names" feature of vexorians map optimizer, so meh, you might be better off without.
 
Status
Not open for further replies.
Top