wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 06-23-2009, 05:37 AM   #1
Storyyeller
User
 
Join Date: Jun 2009
Posts: 46

Storyyeller has little to show at this moment (0)

Default Conditions: What are they good for?

I've gotten into the habit of not using conditions at all. Instead, I'll include the condition checking code at the beginning of my event function and make it return early if the check fails.

I've begun wondering if this is actually a good idea though. So I figured I'd ask some actual JASS experts.

Which way is more efficient? Using conditions or not?
Storyyeller is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 06-23-2009, 06:15 AM   #2
Bobo_The_Kodo
oO
 
Bobo_The_Kodo's Avatar
 
Join Date: Jul 2008
Posts: 580

Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)

Default

Conditions make cleaner code. The speed difference is negligeble, though they are faster than actions.
Bobo_The_Kodo is offline   Reply With Quote
Old 06-23-2009, 06:32 AM   #3
Storyyeller
User
 
Join Date: Jun 2009
Posts: 46

Storyyeller has little to show at this moment (0)

Default

Wouldn't having fewer functions to deal with lead to cleaner code, especially when the condition is only a single line?

Last edited by Storyyeller : 06-23-2009 at 06:32 AM.
Storyyeller is offline   Reply With Quote
Old 06-23-2009, 08:27 AM   #4
Bobo_The_Kodo
oO
 
Bobo_The_Kodo's Avatar
 
Join Date: Jul 2008
Posts: 580

Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)

Default

But the actions are only run when the conditions are true: they're seperate
Bobo_The_Kodo is offline   Reply With Quote
Old 06-23-2009, 12:55 PM   #5
Opossum
User
 
Opossum's Avatar
 
Join Date: Mar 2008
Posts: 205

Submissions (4)

Opossum will become famous soon enough (59)Opossum will become famous soon enough (59)

Default

If you have a big local chunk in your actions function then it's more efficient to have a condition added to the trigger because you can't return before the locals are initialized. Also you might even have to null some of them again before being able to return.
Opossum is offline   Reply With Quote
Old 06-23-2009, 01:02 PM   #6
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,375

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

You could do it all in the condition function instead and then return false, assuming you don't need waits.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 06-23-2009, 01:31 PM   #7
Michael Peppers
Lepus?
 
Michael Peppers's Avatar
 
Join Date: Jan 2009
Posts: 1,308

Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)

Default

Another thread about this

I suggest you to search before asking :)
__________________
Projects:Tutorials: Competitive AI Step by Step with AI Editor (Pending)
Resources: [AI Script] Michael Peppers's Melee AI template (Pending)
Michael Peppers is offline   Reply With Quote
Old 06-23-2009, 06:02 PM   #8
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by Michael Peppers
I suggest you to search before asking :)

Said a guy which didn't try to use the search tool.

Not offensive, but try to find this thread with it, hf.

EDIT :

Also you don't need to worry about leaks if you destroy a trigger with conditions, but you have to if you use action, then you must use TriggerRemoveAction and so in most of cases attach the action to the trigger.
TriggerClearActions doesn't help here, it just de activate the actions.

Last edited by Troll-Brain : 06-23-2009 at 06:07 PM.
Troll-Brain is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 11:27 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services