JASS: Moving From GUI to Jass, the Start

chango

New Member
Reaction score
1
Memory leaks...

Hi,

This is a very complete tutorial, and easy to read even for the people who dont know programming at all.

I'm really new to we (less than a week ;D) but i have a lot of years in programming, and i want to know about how jass manage the memory leak problem.

So the question is if i call a function like this:

Code:
GetRectCenter(GetEntireMapRect())

and save it in a local point variable, when the trigger is over and the variable disappear the memory is released or not ?

And for my first proyect i m doing a very very very simple Hero arena, but i don't know if it's better to do every trigger with JASS or should i make all the things in GUI untill i found something that is not posible to do with it and then do that in JASS?.

Thank's.
 
E

Evero

Guest
THANK YOU !

Finally a neat tutorial that actually explains everything so detailed that those of us who didn't speak the english language when we used diapers can understand.

Thank you
 

Frizz.Meister

New Member
Reaction score
0
As someone who knows loads of GUI but no jass at all I thank you for enlightneing me. Im only up to math and integer section but, this is the only tutorial i have found that makes sense. Awesome job you know exactly how to explain things!
 

12sea21

New Member
Reaction score
5
THIS WAS THE BEST TUT EVER MAN!!!!!!!!!! i learnt jass just off that!!!!!!! w00t!!!!!!!!! im gonna look at other tuts though..
 

tooltiperror

Super Moderator
Reaction score
231
I could not get through Vexorian's tutorial because it was complicated, but this was easy to follow and excellent!

+ Reputation!

Just a suggestion:
I think you should add how to make events into your Tutorial.

Everyone needs to know that.

I also don't understand taking and returning.

Like, does it actually take it from the map, and replace it with a variable?
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
JASS:
// takes:
function TakeAnInteger takes integer i returns nothing
     call BJDebugMsg(I2S(i)
endfunction
function Init takes nothing returns nothing
     call TakeAnInteger(7) // this will call our shiny function above this one, and display 7
     call TakeAnInteger(638) // same thing, but displays 638
endfunction

// returns:

function Return takes nothing returns string
     return "Hello World!"
endfunction
function Init takes nothing returns nothing
     call BJDebugMsg(Return()) // displays "Hello World!", without quotes.
endfunction


More or less, that's it.
 

tooltiperror

Super Moderator
Reaction score
231
But I don't understand what it means.

Like if it takes an integer, does it subtract it or something?
 

BRUTAL

I'm working
Reaction score
118
Do you know what parameters are?
When a function 'takes' something that's pretty much it.
 

Avaleirra

Is back. Probably.
Reaction score
128
Great tutorial! I only have one question: will newgen WE have the JASS thing that let's you learn the actions/conditions?

And I'm a tiny bit confused on how JASS triggers trigger. I know it has something to do with the parameter though...
 

Nestharus

o-o
Reaction score
84
Great tutorial! I only have one question: will newgen WE have the JASS thing that let's you learn the actions/conditions?

It has a function that includes all of the natives so you can learn the API for unit events/retrieval, player events/retrieval, and etc.

As for conditions/actions on triggers, if you'd like to learn more about them chapter 22 from my apparently horrid guide.

http://www.thehelper.net/forums/showthread.php?t=137090

It also includes the answer to your next question, which I put here for your convenience.

Learning the API on all the handles can be tough. There are many natives and there aren't many guides out there that go over a lot of them in-depth. For example, unit groups (a tough one), player API (very extensive), game API, etc..

There's a lot to learn, but if you are focused enough you can get through it.

And I'm a tiny bit confused on how JASS triggers trigger. I know it has something to do with the parameter though...

Section from my lousy guide-
Register Events to Triggers
Events are in-game events that the trigger responds to. For example, you might make a trigger fire when a unit dies on the map. When using triggers, you can get the triggering handles involved as well, for example, you can retrieve the unit that caused the trigger to fire.

Trigger events are stored in an event handle. Once an event is registered on a trigger, it can never be removed, meaning that you have to destroy the trigger if you want to get rid of the event. Events also take up memory.

When adding an event to a trigger, the event handle is always returned. The only use for this is that you could set up a trigger's events in global declaration
JASS:

trigger t = CreateTrigger()
event e = TriggerRegisterEvent(t, event) //not an actual native


The event id that fired the trigger can be retrieved with [ljass]GetTriggerEventId[/ljass]
[ljass]constant native GetTriggerEventId takes nothing returns eventid[/ljass]

From here, you can use the event id to determine what type of event the trigger fired off of. The event id that is returned is an actual event id, for example the event id for unit even death. The event id can be converted into an event and from there used to registered events of the same type of w/e. The problem is that the actual event type is unknown, so you'd really have to know what to convert the event to.

Conversion Methods Are
JASS:

constant native ConvertDialogEvent takes integer i returns dialogevent
constant native ConvertGameEvent takes integer i returns gameevent
constant native ConvertPlayerEvent takes integer i returns playerevent
constant native ConvertPlayerUnitEvent takes integer i returns playerunitevent
constant native ConvertUnitEvent takes integer i returns unitevent
constant native ConvertWidgetEvent takes integer i returns widgetevent


Useful Trigger Event utility http://www.thehelper.net/forums/showpost.php?p=1029299&postcount=1


To further elaborate, I'll take a section from chapter 23 of my crap guide to be used as an example.

Players and Triggers
Player events can be registered on triggers with [ljass]TriggerReigsterPlayerEvent[/ljass]
[ljass]native TriggerRegisterPlayerEvent (trigger whichTrigger, player whichPlayer, playerevent whichPlayerEvent) returns event[/ljass]

The player events are-
JASS:

Event response natives include-
[ljass]constant native GetEventPlayerState takes nothing returns playerstate[/ljass]


In essence, if you were to do this-


Trigger t would fire whenever Player 0 pressed the down arrow key.


I know I explained everything horribly as I always do, but hopefully I helped you a little -.-.
 

Avaleirra

Is back. Probably.
Reaction score
128
Your guide isn't lousy or bad. It's just way more complicated than this one :p.
 

Avaleirra

Is back. Probably.
Reaction score
128
I sortof understand. I might need a few simple example triggers that might be used in a game... But we should use PM's instead so this thread doesn't get messy :p.
 

Oreo_clan

New Member
Reaction score
4
31 pages eh...? Dang! There should be a printed version of this then... Would make things a bit easier on the eyes... And just holding it would be amusing...

Also, I was quite surprised when you said English wasn't your native language. Your English is VERY impressive. It's very clean and easy to read! But then again, I'm only a college student and I only read part one so far... (err... Maybe not even that... The introduction at least.)

I look forward to the day I finish the whole thing.
 

jig7c

Stop reading me...-statement
Reaction score
123
i have a question

JASS:
function multiply takes integer a, integer b returns integer
    local integer counter = 1
    local integer ConstantA = a  // if integer a is a parameter name, why is it being set here?
    loop
        exitwhen counter > b
        set a = a + constantA
        set counter = counter + 1
    endloop
    return a
endfunction


in your tut, where you provide the above example, i don't understand how it suppose to multiply, but more importantly, if above script is good, why is the bottom script illegal!

in the above script; integer a is in the parameter above and then used in a function below
the bottom script is illegal because parameter name "p" is in the user-defined function and also in the function list...

i thought you couldn't name function variables and parameter names the same!!!!


JASS:
function wrong takes play p returns nothing
    local unit p // You have parameter and local with the same name!
    local integer s
    local real s // 2 variables with the same name!
endfunction
 

Lehona

New Member
Reaction score
12
Note: We can set values to globals easily the same way

Code:
udg_global_name = value

Shouldn't this be "set udg_global_name = value"?

Edit: @jig7c: 'a' is used to do some math in the (user-) function, but it's not declared (declared = "created") there, just used. If you aren't allowed to use parameters in the function, they'd pretty useless.
 

sephiroth123

New Member
Reaction score
0
It helps!

It greatly helped me! Now I understand the significance of JASS over GUI. Thanks for your tutorial!:thup:
 

viktorpapa

New Member
Reaction score
2
4.3.4 Other Loops

And then we have other loops, in the exitwhen we can put any condition that will be checked every loop run, what means you can put whatever condition you wish and the loop will run until that condition is met. You can tell the loop to run until some player have some amount of some resource, or make the loop run until a unit dies… Whatever, you can put it all there.

Ive never tried jass but according to my coding knowledge (c#,java,pascal) and as i know how computers and processors work
i really doubt you can do those things, or actually you can, but it would end up in an infinite loop.

Edit: Ok, I explain a bit more precisely: The program cant calculate any other values and variables while its running the loop so those variables wont ever change which could stop the loop, see?:) tbh i assume warcraft doesnt support multitasking and multi-core processors, but even if it would, it would be slow like the frozen hell and probably cause nasty errors like various overflows.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top