- Joined
- Jul 15, 2007
- Messages
- 36
Hello all, and thank-you for reading this.
I should point out; I am just starting to use JASS after soley GUI'ing for a few projects.
I have a couple of JASS problems that I'd like help with;
Problem 1) Have i named them wrong?
I have tried the following script. The intent is that it fires when a unit enters "gg_rct_Player1Zone" (defined in the world editor). It checks if the player that belongs to that zone has "lives" left (integer array gg_lives[x], defined in the WE variable editor), and if it is less than or equal to zero, to warp the unit to another zone, and issue a move order.
I get the following errors when the WE compiles the map when saving;
"expected a name" at
"type mismatch in assignment" at
{EDIT}
reading the handlevars thread, could I be looking at the wrong line, and the problem is with the
and then trying to null a unit variable?{/EDIT}
have i defined the variables wrongly?
(additionally tried to remove leaks; are these valid leaks? have i fixed them?)
Problem 2) Reducing the copy-paste
As I am running several copies of essentially the same code, with minor variations, for each player zone, can I use the same "conditions" function for all of them? I.E. can I rename
to
and change all the triggers that need to satisfy that condition to
and if I do, could that cause problems when multiple triggers are calling it, or does each instance of a trigger access it independantly and the return value doesn't get mucked up?
(did that make sense? I.E. by having multiple triggers running that call the same conditions, is that better/worse than having a copy for each trigger, for which the only difference is the actions.)
Problem 3) GUI -> JASS
Being new to using JASS, I'm not really sure how to put it into the world editor. Basically at the moment I seem to need to make each trigger from the "new trigger" command in the GUI, convert it to text, then paste that trigger in.
Is it possible to put more than one set of functions in? I.E. instead of the GUI having "Warp1", "Warp2", "Warp3", all of which are similar, can i put them all in one "trigger" in the GUI? It seems to be doing things in the background like defining trigger objects in the globals.
If so, how? do I have to put "globals" and define the trigger objects at the start of the script? Will multiple copies of that be compiled by WE?
Problem 4) Global Variables
How do I define variables manually, bypassing the WE variable control window? do i just put
Thank-you again for bothering to read this
Cheers,
AussieLauren
I should point out; I am just starting to use JASS after soley GUI'ing for a few projects.
I have a couple of JASS problems that I'd like help with;
Problem 1) Have i named them wrong?
I have tried the following script. The intent is that it fires when a unit enters "gg_rct_Player1Zone" (defined in the world editor). It checks if the player that belongs to that zone has "lives" left (integer array gg_lives[x], defined in the WE variable editor), and if it is less than or equal to zero, to warp the unit to another zone, and issue a move order.
I get the following errors when the WE compiles the map when saving;
"expected a name" at
JASS:
set l = gg_lives[0]
JASS:
set l = null
{EDIT}
reading the handlevars thread, could I be looking at the wrong line, and the problem is with the
JASS:
set u = GetTriggerUnit()
have i defined the variables wrongly?
JASS:
//---------------------------------------------------------------------------
// Skip player one is status is not playing, when unit enters player1 zone
function Trig_Skip1_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) != 'n000'
endfunction
function Trig_Skip1_Actions takes nothing returns nothing
local unit u
local integer l
set u = GetTriggerUnit()
set l = gg_lives[0]
if l <= 0 then
call SetUnitPositionLoc( u, GetRandomLocInRect(gg_rct_Player1Spawn) )
call IssuePointOrderLocBJ( u, "move", GetRectCenter(gg_rct_Player2Hall) )
set u = null
set l = null
else
return
endif
return
endfunction
//===========================================================================
function InitTrig_Skip1 takes nothing returns nothing
set gg_trg_Skip1 = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Skip1, gg_rct_Player1Zone )
call TriggerAddCondition( gg_trg_Skip1, Condition( function Trig_Skip1_Conditions ) )
call TriggerAddAction( gg_trg_Skip1, function Trig_Skip1_Actions )
endfunction
(additionally tried to remove leaks; are these valid leaks? have i fixed them?)
Problem 2) Reducing the copy-paste
As I am running several copies of essentially the same code, with minor variations, for each player zone, can I use the same "conditions" function for all of them? I.E. can I rename
JASS:
function Trig_Skip1_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) != 'n000'
endfunction
JASS:
function Trig_Notn000_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) != 'n000'
endfunction
and change all the triggers that need to satisfy that condition to
JASS:
call TriggerAddCondition( gg_trg_Skip1, Condition( function Trig_Notn000_Conditions ) )
and if I do, could that cause problems when multiple triggers are calling it, or does each instance of a trigger access it independantly and the return value doesn't get mucked up?
(did that make sense? I.E. by having multiple triggers running that call the same conditions, is that better/worse than having a copy for each trigger, for which the only difference is the actions.)
Problem 3) GUI -> JASS
Being new to using JASS, I'm not really sure how to put it into the world editor. Basically at the moment I seem to need to make each trigger from the "new trigger" command in the GUI, convert it to text, then paste that trigger in.
Is it possible to put more than one set of functions in? I.E. instead of the GUI having "Warp1", "Warp2", "Warp3", all of which are similar, can i put them all in one "trigger" in the GUI? It seems to be doing things in the background like defining trigger objects in the globals.
If so, how? do I have to put "globals" and define the trigger objects at the start of the script? Will multiple copies of that be compiled by WE?
Problem 4) Global Variables
How do I define variables manually, bypassing the WE variable control window? do i just put
JASS:
globals
// User-defined
leaderboard udg_leaderboard01 = null
integer udg_integer01 = 0
integer udg_integer02 = 0
integer udg_integer03 = 0
trigger gg_skip1 = null
Thank-you again for bothering to read this
Cheers,
AussieLauren