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

Jass entry-point?

Status
Not open for further replies.
Level 2
Joined
Aug 18, 2008
Messages
7
Hey, all.

I'm new to map development but have been experimenting with the Trigger Editor for most (ugh.) of today. I have some questions:

1. What is the entry-point for Jass? Is there a main() function?

2. Where should I place my Jass? In the "Custom Script Code" section in the Trigger Editor (with the map icon selected)? Should I make triggers, convert them to text, then overwrite the generated code with my Jass? And should I use one "trigger" per function? Per class? Per library? Should I not use the Trigger Editor at all?

3. If I'm using JassHelper with cjass and vjass, are there any libraries I need to import? Init functions I need to call? I'm using UMSWE.
 
Level 10
Joined
Jan 21, 2007
Messages
576
Hey, all.

I'm new to map development but have been experimenting with the Trigger Editor for most (ugh.) of today. I have some questions:

1. What is the entry-point for Jass? Is there a main() function?

2. Where should I place my Jass? In the "Custom Script Code" section in the Trigger Editor (with the map icon selected)? Should I make triggers, convert them to text, then overwrite the generated code with my Jass? And should I use one "trigger" per function? Per class? Per library? Should I not use the Trigger Editor at all?

3. If I'm using JassHelper with cjass and vjass, are there any libraries I need to import? Init functions I need to call? I'm using UMSWE.

1. Not really
2. The majority of your jass script (especially when you are just starting) will be placed within the triggers that you convert to text. You will overwrite the text generated yes but a good way to learn some basics of how to do things is by making the trigger in gui, and then converting it and seeing how it is done in jass. But keep in mind that the jass that you get when converting triggers is poorly optimized.

Otherwise yea, tutorials are win and you will probably spend a lot of time with them. And here is the vjass manual, http://www.wc3c.net/vexorian/jasshelpermanual.html has a lot of useful information once you get going.

GL!
 
Level 2
Joined
Aug 18, 2008
Messages
7
1. Not really
2. The majority of your jass script (especially when you are just starting) will be placed within the triggers that you convert to text. You will overwrite the text generated yes but a good way to learn some basics of how to do things is by making the trigger in gui, and then converting it and seeing how it is done in jass. But keep in mind that the jass that you get when converting triggers is poorly optimized.

Otherwise yea, tutorials are win and you will probably spend a lot of time with them. And here is the vjass manual, http://www.wc3c.net/vexorian/jasshelpermanual.html has a lot of useful information once you get going.

GL!

Hey, Gost. Thanks for your answers.

I'll take that advice, but I'm hoping to avoid GUI triggers entirely for end-products. I've been coding in (too many) other languages for years and will likely find Triggers cumbersome and obnoxious. Let's pretend I have no GUI triggers :). Should my entry-point code be in "Custom Script Code"? For example,
Code:
call initFunction()
call mainFunction()
 
Level 7
Joined
Nov 6, 2009
Messages
279
Hey, Gost. Thanks for your answers.

I'll take that advice, but I'm hoping to avoid GUI triggers entirely for end-products. I've been coding in (too many) other languages for years and will likely find Triggers cumbersome and obnoxious. Let's pretend I have no GUI triggers :). Should my entry-point code be in "Custom Script Code"? For example,
Code:
call initFunction()
call mainFunction()

I dont really get what you mean but if you mean what i got then yes.
And use jass tags:
JASS:
endfunction
 
Level 2
Joined
Aug 18, 2008
Messages
7
I dont really get what you mean but if you mean what i got then yes.
And use jass tags:
JASS:
endfunction

Great, thank you. I was mostly wondering about best-practices rather than feasibility. And I'll remember to use the JASS tags next time :)

Thanks for the responses, both of you.
 
Level 7
Joined
Nov 6, 2009
Messages
279
Level 40
Joined
Dec 14, 2005
Messages
10,532
  1. Yes, there are two in fact. config is called when the map information is needed (number of players etc)—more specifically, when the map is selected from the map list. main is called when the map script is loaded (about a quarter through the loading screen, maybe farther). Both are generated by the game so most of the time you won't worry about them unless you want to do some really advanced stuff.

    The entry point to a specific trigger is a function named InitTrig_TrigName where TrigName is that trigger's name (spaces are replaced by underscores, naturally). However, with modern vJass we just use "initializer" functions instead, which are declared from a scope, library, or struct.

    JASS:
    struct somestruc
        static method onInit takes nothing returns nothing
            //...
        endmethod
    endstruct
    
    scope somescope initializer myInitFunc
    function myInitFunc takes nothing returns nothing
        //...
    endfunction
    endscope
    
    library somelib initializer myOtherInitFunc
    private function myOtherInitFunc takes nothing returns nothing
        //...
    endfunction
    endlibrary

    By convention everything that is a library is within a library and everything else is within a scope, so InitTrigs can be considered deprecated.
  2. In vJass the Custom Script Section is considered deprecated due to its lack of organization, but it's really your decision where to put your code.
  3. There are no libraries you need, but many you may find useful depending on what you are trying to do. I rarely find myself not using TimerUtils due to its convenience (although a hashtable is an adequate modern substitute), but I generally can do without the rest.
 
Level 9
Joined
Nov 28, 2008
Messages
704
The answer for your "main" is that there is no reason to use an entry point. If you want to get something to init, use vJass libraries/scopes initializer keyword (read the vJass manual).

Also, do a couple GUI triggers, if only to get a feel for all the functions you can do. There are a couple you cant, but still.

If you are coding in JASS, also get Jass NewGen Pack, unless you already have it (you say you're using UMSWE, which is a bit outdated).

As for 3. there is nothing you need to import/include, EXCEPT for cJass typedefs. If you want to use int, bool, and such, you need to #include "cj_types.j" (well not really, you could #define those yourself, but still). And while you're at it, a simple #include "cj_antibj_base.j" and #include "cj_order.j" optimizes your maps code a bit.

If you dont import cj_types, then you have to use the default jass types of integer and boolean, as opposed to int and bool. Depends if you're used to C++ (I am).

Anyways, typically the one "trigger" I import into all my maps just has this text:

JASS:
#define MAPRECT = bj_mapInitialPlayableArea 
real MAX_X
real MAX_Y
real MIN_X
real MIN_Y

hashtable HASHTABLE

#define TWOPI = 6.28318
#define PI = 3.14159

#include "cj_types.j"
#include "cj_antibj_base.j"
#include "cj_order.j"

#define GLP = GetLocalPlayer()
#define UnitCauseDamage(attacker, target, amount) = UnitDamageTarget(attacker, target, amount, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)

#define DUMMY_ID = 'e000' //Replace with the right thing here.

library BasicDefinitions initializer Init
{
    private void Init()
    {
        MAX_X = GetRectMaxX(bj_mapInitialPlayableArea)
        MAX_Y = GetRectMaxY(bj_mapInitialPlayableArea)
        MIN_X = GetRectMinX(bj_mapInitialPlayableArea)
        MIN_Y = GetRectMinY(bj_mapInitialPlayableArea)
        HASHTABLE = InitHashtable()
    }
}
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
The answer for your "main" is that there is no reason to use an entry point.
There are reasons to edit main and config once in an age.

Also, do a couple GUI triggers, if only to get a feel for all the functions you can do. There are a couple you cant, but still.
Or just read common.j?

If you are coding in JASS, also get Jass NewGen Pack, unless you already have it (you say you're using UMSWE, which is a bit outdated).
UMSWE is built into NewGen nowadays.

If you dont import cj_types, then you have to use the default jass types of integer and boolean, as opposed to int and bool. Depends if you're used to C++ (I am).
If he can't adapt to writing integer and boolean instead of int and bool he'll have far larger problems. cJass is unhealthily nostalgic; there is more than one way to think about code let alone write it, and it's time to accept that (and other than defines cJass doesn't actually provide any functionality that I can think of).
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Set/Call removal.
I said functionality, not stupid pointless syntax changes.

Out of curiosity, an example please?
If you want to change the initialization stuff which is called, for example (or when it is called).

I was also playing with config a while ago to figure out what you could do and what it did. I found some interesting stuff although I've forgotten it all since.
 
Level 12
Joined
Dec 10, 2008
Messages
850
You can change alot of stuff you can edit elsewere in the editor and things you cant change with the 2. Main lets you set the ambeint sounds for night and day cycles, overwrite what actions play what sound, change were rects are located, things in init functions and a few other things. The code I was looking at was missing its config function though, but that lets you set the maps name, discription, loading screen, and a few other things
 
Status
Not open for further replies.
Top