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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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