Page 1 of 2

Declaring a Varible

Posted: June 16th, 2007, 2:10 pm
by Bartimaeus²
How do I declare a varible, eg,

function Trig_Gold_Conditions takes nothing returns boolean
if ( not ( IsPlayerInForce(GetTriggerPlayer(), udg_Chetz) == true ) ) then
return false
endif
return true
endfunction

function Trig_Gold_Actions takes nothing returns nothing
call SetPlayerStateBJ( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, S2I(SubStringBJ(GetEventPlayerChatString(), 7, 20)) )
endfunction

I get the error : Undeclared Varible : udg_Chetz

How do I fix this?

Posted: June 16th, 2007, 2:15 pm
by Xantan
force udg_Chetz=null in globals should work [thats called delcaring a variable... lol]
(note correct spelling and capitalization)

Posted: June 16th, 2007, 2:16 pm
by Bartimaeus²
Xantan wrote:force udg_Chetz=null in globals should work [thats called delcaring a variable... lol]
(note correct spelling and capitalization)



Alright, thanks ;p

Hey, in World Editor, does

//===========================================

Means that anything after this wall is under Function Main?

Posted: June 16th, 2007, 2:19 pm
by Xantan
actually you'd need to define it then (in something like InitGlobals), use this instead:
force udg_Chetz=CreateForce()


Edit:
Baertaemias wrote:
Alright, thanks ;p

Hey, in World Editor, does

//===========================================

Means that anything after this wall is under Function Main?


uhm, nope not really (could be anything)... if you ever make a map in world editor then extract it with mpqmaster + use jasscraft, you'll see all the //========= (comments) that the world editor automatically puts all over...

also thats a great way to learn how to define variables etc! =]

Posted: June 16th, 2007, 2:26 pm
by Bartimaeus²
Xantan wrote:actually you'd need to define it then, use this:
force udg_Chetz=CreateForce()


Edit:
Baertaemias wrote:
Alright, thanks ;p

Hey, in World Editor, does

//===========================================

Means that anything after this wall is under Function Main?


uhm, nope not really (could be anything)... if you ever make a map in world editor then extract it with mpqmaster + use jasscraft, you'll see all the //========= (comments) that the world editor automatically puts all over...

also thats a great way to learn how to define variables etc! =]


Than what do I do with the stuff below the Wall of Lines?

Also, I did declare "udg_trg_gold" and "udg_trg_wood" I was suppose to do that, right?

Posted: June 16th, 2007, 2:35 pm
by Xantan
I'm not sure as I don't see your map in front of me, and don't really want to either.

IF you needed to declare a variable it would say so, so, yeah, probably.

I'd honestly just use jasscraft... lol

Posted: June 16th, 2007, 2:38 pm
by Bartimaeus²
Xantan wrote:I'm not sure as I don't see your map in front of me, and don't really want to either.

IF you needed to declare a variable it would say so, so, yeah, probably.

I'd honestly just use jasscraft... lol


I am, lol, I did the trigger in GUI in Warcraft III, than I changed it into JASS, than I put it into Green TD .j file.

So... what do I do with the stuff below those lines? Because I don't know what it is or what it does ;\

And, gg_trg_gold
gg_trg_wood are the right variables right?

Posted: June 16th, 2007, 2:47 pm
by Xantan
if you get no syntax errors then sure! they are good.

The lines mean NOTHING.

delete them and put them all under function main.

you'll still need something to call your trigger though in function main... ie
call InitTrig_gg_gold( )
call InitTrig_gg_wood( )
(or their correct names -- I didn't look)
( may need to leave off trg_ not sure, just test it )

Posted: June 16th, 2007, 2:51 pm
by Bartimaeus²
Xantan wrote:if you get no syntax errors then sure! they are good.

The lines mean NOTHING.

delete them and put them all under function main.

you'll still need something to call your trigger though in function main... ie
call InitTrig_gg_gold( )
call InitTrig_gg_wood( )
(or their correct names -- I didn't look)
( may need to leave off trg_ not sure, just test it )



..uhm, re-say that, because you said "Delete the lines and put them under function main" ...btw, I get Syntax errors when I put the lines under function main 0_0

Posted: June 16th, 2007, 2:54 pm
by Xantan
DON'T put anything you converted to function main.

Converting a trigger does not bring up ANY globals or function main, only the below globals and above function main... (I call it functions, lol)

You take the stuff it converted and remove ALL comments (//=========) then put it below endglobals after delcaring it in globals, then use as I said above call InitTrig etc in function main...

I'm somewhat tired of answering questions... lol