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

CreateTrigger() srecific

Status
Not open for further replies.
Level 2
Joined
Jun 30, 2017
Messages
16
Good day!
I try to Create Trigger in middle of game but it does not work(
I use global variable and function not in librarry (function of action). But it does not helf.
How can i create a new trigger in the middle of game?

My code:
Code:
udg_t[1] = CreateTrigger()
        TriggerRegisterPlayerSelectionEventBJ( udg_t[1], p, true)
        //TriggerRegisterAnyUnitEventBJ( udg_t[1], EVENT_PLAYER_UNIT_ISSUED_ORDER )
        TriggerAddAction( udg_t[1], function MyMessage)

And MyMessage didn't start =(
 
Level 2
Joined
Jun 30, 2017
Messages
16
No, at start i have log info:
Code:
    nothing MyMessage() {
        DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, "test")
But if it is syntax problem.. i think compiler can found it
 
Level 2
Joined
Jun 30, 2017
Messages
16
Yes.. i dont saw that "u" I initialize later. it work)

BUT! I have a new.. more important question:
I want to use a structure.
In some place of all triggers i will init this structure (local Mystr)
And than i want to use Mystr.CreateNewTrigger(), when "CreateNewTrigger" will contain:

Code:
trigger t = CreateTrigger()
TriggerRegisterPlayerSelectionEventBJ( t, p, true)
TriggerAddAction( t, function this.SomeAction)

i try use this.. but compiler show error that i can not use "this", i change it to

Code:
TriggerAddAction( t, function SomeAction)

And compiler show me "cannot found SomeAction". Again i change it to

Code:
TriggerAddAction( t, method SomeAction)

and it show me that it can not found it...

HOW can i use method of structure as action of trigger?
 
Level 2
Joined
Jun 30, 2017
Messages
16
I can not correctly tell you about it.. my english is bad. I will try again:

At first i want to use action of trigger with local variables!
I see 2 ways:
1) Use structure (about it i told at prev. post)
2) Use function (as action) with arguments (i dont know how add action with args to trigger)

Do anyone know any way?
 
Level 2
Joined
Jun 30, 2017
Messages
16
I understand how vjass and stuctures work!
And... if we wnt to use dynamic functions we must understand how to use method as action with variables(arguments)... but.. i think it is impossible
 
Level 2
Joined
Jun 30, 2017
Messages
16
And how it helps me?

If i have:

nothimg somefunc() {
local trigger t = GetTriggeringTrigger()
//now i want to use variable 'i'
}

struct MYstr {
trigger t
integer i
nothing new(integer k) {
i = k
t = CreateTrigger()
TriggerRegisterPlayerSelectionEventBJ( t, p, true)
TriggerAddAction( t, function somefunc)
}
}

And how can i use 'i' in function 'somefunc'???
 
Level 2
Joined
Jun 30, 2017
Messages
16
Yes.. it will work. I dont think about GetHandleId...
But it seems like a long way.
And i found and use now another way.. more simple and must be more efficient (work faster in my case)
but you help me.. thanks
 
Last edited:
Level 2
Joined
Jun 30, 2017
Messages
16
In structure i start a loop with checking does current unit selected or not.
This function will start not often and will finish after a few seconds. So.. this is symple way to solve my problem as i think
 
Level 2
Joined
Jun 30, 2017
Messages
16
may be i told not correctly, but.. I use this:
Code:
        loop
            exitwhen (IsUnitSelected(mes_u, own_p) == true)
            TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 2))
        endloop
 
Status
Not open for further replies.
Top