vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

[Jass 101] - Statements & Structure

moyack · 10332

0 Members and 1 Guest are viewing this topic.

[Jass 101] - Statements & Structure
on: February 11, 2013, 09:31:10 PM

Remembering the previous tutorial we were ready to start coding. In fact we revealed what's inside those GUI blocks ans we saw they were just functions. Now it's time to understand the structure and how we should write.

When the code in the map is armed in the *.j file, it will condense the code in this way:

Code: jass
  1. //Global section
  2. globals
  3.  
  4.    //here you'll find all the global variables in the map
  5.  
  6. endglobals
  7. //End of the Global section
  8.  
  9. //Function section: here you will find all the functions that will manage the map.
  10. //...
  11.  
  12. function bla1 takes ... returns ...
  13.    // here will be a bunch of functions
  14. endfunction
  15.  
  16. function bla2 takes ... returns ...
  17.    // and more functions... :D
  18. endfunction
  19.  
  20. //... and more functions ... :)
  21.  
  22. function main takes nothing returns nothing
  23.    // Here's the main initial function
  24. endfunction

In JASS the function's order is very important in the sense that any function required by another function must be over the caller one. Here's an example:

IncorrectCorrect
Code: jass
  1. function Caller takes nothing returns nothing
  2.     // some code...
  3.     call Called()
  4.     // More code...
  5. endfunction
  6.  
  7. function Called takes nothing returns nothing
  8.     // Do some stuff...
  9. endfunction
Code: jass
  1. function Called takes nothing returns nothing
  2.     // Do some stuff...
  3. endfunction
  4.  
  5. function Caller takes nothing returns nothing
  6.     // some code...
  7.     call Called()
  8.     // More code...
  9. endfunction

to be continued...
« Last Edit: July 23, 2013, 08:03:03 AM by moyack »



[Jass 101] - Statements & Structure
Reply #1 on: February 14, 2013, 12:15:20 AM

Awww, please teach us more on the next tutorial. Or maybe me? lol

Chronicles of Darkness
by: SonofJay

A BlizzMod Hosted Project

They can hate, let them hate, make them hate.


[Jass 101] - Statements & Structure
Reply #2 on: February 14, 2013, 07:36:47 AM

I'm on it... this weekend I'll continue with this part.


 

Chaos Realm - The world of Game modders and wc3 addicts     WC3JASS.com - The JASS Vault   Jetcraft - A Starcraft II mod