null/create trigger()

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

namespoofer
V.I.P.
Posts: 332
Joined: March 4th, 2007, 12:39 am
Location: United States

null/create trigger()

Post by namespoofer »

Under globals, what is the difference from declaring

Code: Select all

trigger test = CreateTrigger()
trigger test = null
Is there a difference? Do you not have to 'call InitTrig_test = CreateTrigger()' ?

wahhhhh
Spoofzz
Image
Doesn't Dekar make the world easier?

"I Wumbo. YOU Wumbo. He she me.. WUMbo. Wumbo; WumboING; WumBOLogy; the study of WUMBO. It's first grade, Spongebob!"
"I'm sorry I doubted your great wisdom Patrick!"

Catch me on Azeroth (U.S. East) - NameSpoofer
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Post by Aero »

Code: Select all

trigger trigname = null
"trigname" here is a trigger variable. It is null, it has no value. It's not yet a 'trigger'.

What InitTrig functions do is 'set trigname=CreateTrigger()' which turns your trigger variable from null to a trigger. Once a trigger variable is a trigger and not null, it can have events, conditions and actions attached to it.

That is what InitTrig does ("InitiateTrigger")

Code: Select all

trigger trigname = CreateTrigger()
"trigname" here is still a trigger variable. However, instead of being declared as a null trigger variable, it is declared as already a trigger. Hence, we skipped a step.

What this means is that we don't need to "set trigname=CreateTrigger()" because it's already created. InitTrig still serves the purpose of attaching the events, conditions and actions to the trigger so we still need it. You CAN get rid of InitTrig if you move the functions which attach events, conditions and actions to function main or function InitCustomTriggers.

This is what a lot of trigger optimizers do to get rid of useless InitTrig functions to save space and speed up map a bit.
namespoofer
V.I.P.
Posts: 332
Joined: March 4th, 2007, 12:39 am
Location: United States

Post by namespoofer »

Heh, thanks Aero, that's a little like what I was thinking! Now can you answer my other topic? :D
Image
Doesn't Dekar make the world easier?

"I Wumbo. YOU Wumbo. He she me.. WUMbo. Wumbo; WumboING; WumBOLogy; the study of WUMBO. It's first grade, Spongebob!"
"I'm sorry I doubted your great wisdom Patrick!"

Catch me on Azeroth (U.S. East) - NameSpoofer
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Post by Aero »

~.~ I did