Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
I've reasontly learned the basics of jass, while this took me a lot of time to figure out, i have some problems/questions i would like help to solve. And please tell me if this should be in the Trigger/script forum?
1: i tried a couple of times, but i can't get the loop to work, would anyone please show me an example of it so i can se how its done?
2: how to transfere local valures between functions, this one caused me a lot of trouble. An example will be good too here.
local integer i = 0
loop
exitwhen i == 5
call BJDebugMsg("This action has runned")
set i = i+1
endloop
This should execute 5 times for i=0,1,2,3,4
not for 5 because it instantly exits loop when it encounters exitwhen with a true expression
To transfers local variables you need to transfer them to a global variable first
I guess you want to transfer variables into timers
That requires a handle storage system such as "Local Handle Variables"
So with that you can store variables in any handle such as unit, timer, destructable, etc
Struct is something like a group of arrayed variables
for example
JASS:
struct moar
unit u
integer a
endstruct
will be something like... hmm I couldnt find an example. Anyway its Like this its NOT this
JASS:
globals
unit array u__moar
integer array a__moar
endglobals
When you create a struct like local moar omfg = moar.create() it generates and array index which isnt currently in use
You can clear an index by destroying it like call omfg.destroy()[/code] which will say that "I dont use the index that I gave to omfg anymore"
and when you call something like [icode=jass]call KillUnit(omfg.u)
it turns to something like call KillUnit(u_moar[omfg])
and yes omfg here is actually an integer which you can use as integer too
(Benefits of it for being integer that you can store it in a timer with a System that allows you to store variables in timer as I told up there So you can just transfer struct index into timer instead of many variables, In that way its better because reading a variable from global variable is faster than reading from game cache <if you will use game cache>)
Private is simple
for example you have a scope
which like
[code=jass]scope metalgear
private function Actions takes nothing returns nothing
endfunction
endscope[/code]
in this way your function will be reneamed like (NOT as) metalgear_Actions and it cannot be accessed from an another function
Its benefits that you can use same function name multiple times
And that may allow you to... for example you have a spell and you want to make another spell familiar to it
you just copy the trigger and change scope name instead of changing name of all triggers
And in scopes you can define any function as initializer instead of InitTrig
example
[code=jass]scope metalgear initializer METALGEAR
private function METALGEAR takes nothing returns nothing
endfunction
endscope[/code]
METALGEAR gets executed in map initialization
They certainly are.
Your other sentence is wrong, you can use vJass with JassHelper, which just happens to be implented into JNGP.
Need_O2, nice job, though your explanation of the private keyword is wrong. The private keyword will not just add <scopename>_<functionname>, it will add a random amount of "_". The public keyword adds only one "_".
You can view the compiled code by making an error, which will show the code. This is how it is compiled:
JASS:
scope Test
//Private function
private function func1 takes nothing returns nothing
endfunction
//Public function
public function func2 takes nothing returns nothing
call //This will make a compile error, which lets us view the script
endfunction
endscope
JASS:
// scope Test begins
//Private function
function Test___func1 takes nothing returns nothing
endfunction
//Public function
function Test_func2 takes nothing returns nothing
call //This will make a compile error, which lets us view the script
endfunction
// scope Test ends
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.