- Joined
- Aug 31, 2008
- Messages
- 1,121
Did you use a unit with 0 move speed?
What is the difference between Local and Global variables?
-Local variables are variables only usable by the function they’re declared in. These are used for cleaning Memory Leaks (which will be explained later), neatening code, and making script Multi-instanceable.
-Globals are variables which can be accessed by any function, but can also be changed by any function. This can be bad for multi-instanceability (which will now be referred to as MUI), depending. MUI will be discussed later on.
which of these is the variable? is it the *unit*? or is it the *u*? and what does it mean when u set *local unit u = createunit()*? does it mean there will be a unit created and this created unit's name is *u*? sorry i just never had a single programing class all my lifeHow do I create a local variable?
-There are two ways to creating/setting a variable.
function variable_test takes nothing returns nothing
local unit u = CreateUnit()
endfunction
This method creates and sets it in one line, at the beginning of the function.
uhm... whats this *…..*? is it the name of a unit (after u press ctr+d? cuz i didn't see any number or non-letter-symbols when i pressed ctr+d. like pally is Hpal)?function variable_test takes nothing returns nothing
local unit u
set u = CreateUnit(…..) //Creates a unit and sets the variable to it
endfunction
And this method creates a blank variable, to be set later on in the function.
i dont know wat *multi-instanceability* is ... does it mean exectue several actions at once? ... and what's the difference between actions and function? i mean they both perform ... an action. I'm kindda stuck on lesson 2 been reading it for couple hours and my brain hurts so i decided to ask![]()
and im gonna list a few more questions i got
1)
which of these is the variable? is it the *unit*? or is it the *u*? and what does it mean when u set *local unit u = createunit()*? does it mean there will be a unit created and this created unit's name is *u*? sorry i just never had a single programing class all my life
2)
uhm... whats this *…..*? is it the name of a unit (after u press ctr+d? cuz i didn't see any number or non-letter-symbols when i pressed ctr+d. like pally is Hpal)?
i have a lot more questions but plz answer these 1st so i can continue
ty
function variable_test takes nothing returns nothing
local unit u
set u = CreateUnit(hpea)
endfunction
what is wrong with that?
it says too few arguments.
what does that mean?
sorry im a noob when it comes to JASS
CreateNUnitsAtLoc(12,'hpea', Player(0), GetUnitLoc(u), 45.)
Too few arguments means that you're not supplying enough information to the function you're trying to call. Here's the function declaration for CreateUnit:function variable_test takes nothing returns nothing
local unit u
set u = CreateUnit(hpea)
endfunction
what is wrong with that?
it says too few arguments.
what does that mean?
sorry im a noob when it comes to JASS
native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit
set myUnit = CreateUnit(Player(0), 'hpea', 0., 0., 0.)
// Will create a peasant for Player Red at the center of the map facing to the right. (0 degrees = right, 90 = up, 180 = left, etc.)
It is running the function "BJDebugMsg" passing it the string "HI" for its parameter. That function looks like...i just understand the call BJDebugMsg ("HI")
function BJDebugMsg takes string msg returns nothing
local integer i = 0
loop
call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
set i = i + 1
exitwhen i == bj_MAX_PLAYERS
endloop
endfunction
It is running the function "BJDebugMsg" passing it the string "HI" for its parameter. That function looks like...So when run it calls the native function "DisplayTimedTextToPlayer" with a string value of "HI" that is repeated for every player.JASS:function BJDebugMsg takes string msg returns nothing local integer i = 0 loop call DisplayTimedTextToPlayer(Player(i),0,0,60,msg) set i = i + 1 exitwhen i == bj_MAX_PLAYERS endloop endfunction
Not that much different from getting a GUI trigger to run another GUI trigger after placing a value in a global variable. The difference comes from the higher performance and use of the stack when calling a function rather than creating a new thread and heap (global) usage for running another trigger in GUI.
That is the function signature. Types a function take make up the function parameters that are passed to the function when it is called. The single type a function returns is what type the function can be treated as when using it as an argument. To understand what function parameters, return type and such mean then look up practically any programming resource as it is a common feature of a lot of programming languages.i know still im stuck at function takes nothing return nothing
What are your current triggers? Maybe make a thread about this in WorldEdit Help Zone or Triggers and Scripts forum section?How can I use the jass for solve this?
Dr Super Good said:What are your current triggers? Maybe make a thread about this in WorldEdit Help Zone or Triggers and Scripts forum section?
Usually one creates a trigger and then use one of the menu options to convert it to custom script.How do I know where to write the code?
Usually one creates a trigger and then use one of the menu options to convert it to custom script.
Okay, so there is no issue with putting all your JASS code in their own separate triggers? In my limited coding experience, typically function definitions and global variable definitions go at the "top" of your code. For WE/JASS, function definitions and global variables can be defined in their respective triggers, correct?The "master trigger" is the script header. That will appear above all other script.
It used to be the only way to force script to the top of the map script. However I think now the triggers are built in the order they appear (not created) so might no longer be necessary.
The main reason not to use it is for organization. You can put nice names next to each piece of script instead of a huge monolithic block of text. Additionally custom script triggers allow one to run code on map initialization, something the header does not without stepping into vJASS features.