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

[snippet]BoolExprUtils for cJASS

Level 31
Joined
Jul 10, 2007
Messages
6,306
Changed around vexorian's BoolExprUtilities to be better in my opinion ^_^.

Instead of using BOOLEXPR_TRUE and BOOLEXPR_FALSE, you would just use TRUE and FALSE : D.

so
JASS:
//vex's
EnumDestructablesInRect(rect, BOOLEXPR_TRUE, function Hi)

//update with cJASS
EnumDestructablesInRect(rect, TRUE, function hi)

JASS:
//http://www.wc3c.net/showthread.php?t=101248
define
{
    <TRUE> = BoolexprUtils_BOOLEXPR_TRUE
    <FALSE> = BoolexprUtils_BOOLEXPR_FALSE
}

library BoolexprUtils initializer init
{
    public boolexpr BOOLEXPR_TRUE;
    public boolexpr BOOLEXPR_FALSE;

    private bool rettrue()
    {
        return true;
    }

    private bool retfalse()
    {
        return false;
    }

    private void init()
    {
        BOOLEXPR_TRUE = Condition(function rettrue);
        BOOLEXPR_FALSE = Condition(function retfalse);
    }
}
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Aren't TRUE and FALSE already constants defined in common/blizzard.j?

I remember seeing those in one of them.

This will break anything that uses those constants.

Untrue. While they may be defined, any instanced use of them is replaced, so using TRUE is actually using the true boolexpr in the boolean utilities. No, you can't use the TRUE or FALSE variables created by blizzard anymore by using this, but is there a point to using them when they just mean true, false. No, there really isn't =). It is perfectly safe to use ^_^, and I think using those 2 keywords as boolean expressions is a much better use for them than what they were originally there for. I doubt you'll find anyone who disagrees with that =P.

2 things:
-Imo cJASS shouldn't be a language which get's used here yet. It's still beta and most of the people don't know shit about it.
-If you say it's a snippet, why not post it in the thread for it?

1. As for your first question. Yes, cJASS is still beta but I have not actually found any issues with it. There are features and keywords missing that I think should be there, but as for bugs... =). In my opinion, it is perfectly safe to use. The only prob with it besides missing keywords and features is the fact that it has no manual, but just look up C if you have any questions ^_^.

Oh yes, Keep in mind that things that are similar to macros will not work in macros, things like define ^_^. This is logical to me, but for people who aren't familiar with the inner workings of vJASS and macros and what not, it probably wouldn't make any sense =P.

2. This is a pretty widely used snippet from wc3c =), it's also a pretty mandatory one for any resource designer. Main resources like this should be easy to find, and in fact I believe that the primary utilities like this one that serve for all purpose map making should be put into a framework and put into the map as they are used. They should be extensions to the language to fix various flaws and repetitive things that come with plain old JASS =).

Also, there have been other main stream snippets that have been submitted to threads. Snippets that are really for a specific purpose and could fit into a large puzzle should be put into a library of snippets with a way to easily browse and search them. Putting them all in a thread doesn't serve them justice and the chances of someone browsing through all the pages of that thread to find one little snippet is slim to none =).

Oh well, those are my own thoughts. Still, I beseech you to look at other tiny little snippets like this one, such as Recycle. Why do you think they were submitted as full blown threads?
 
Level 8
Joined
Oct 3, 2008
Messages
367
>Untrue.

So you say it's untrue and... then say that it is?

>but is there a point to using them when they just mean true, false

I've seen them used.

Hint hint: It's a baaad idea to use names already defined in common/blizzard.j.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
So you say it's untrue and... then say that it is?

Meant untrue to

This will break anything that uses those constants.

And now I get what he's saying ^_^. Yea, it will I guess, but they should be rewritten to true/false : o. Why on earth anyone would type TRUE as opposed to true is beyond me ;o. A better use of TRUE and FALSE would be as boolean expressions =).

Oh well ^_^.
 
Top