- Joined
- Jun 30, 2006
- Messages
- 230
I was curious of a few things regarding the two.
Lately I've been going through my triggers and recreating any of them that can be done in GUI. I learned triggers by jumping straight into JASS, but now I want to make them GUI if possible to allow others to easily use them and understand them as well.
Take my Clock as an example:
GUI converted to JASS:
Created only in JASS:
Aside from setting p = null (how do you do this in GUI? I can't find it...), there isn't much difference aside from getting rid of useless BJ's and such. And getting rid of the pointless return true/false function.
My Questions:
1. How do you set a variable equal to null in GUI? Or do you just have to call a custom script to do it?
2. What would be the speed difference in Gameplay? This happens every second, and there are a lot of things happening on this map anyways. Performance is key.
3. When Blizzard adds udg_ in front of a variable, doesn't that mean it is global? Can I not create local variables in GUI? The only way I know to create variables using the GUI is to click on Edit > Variables.
My GUI, for your information:
Also, I wasn't entirely sure if this would go in GUI or JASS, I ask some GUI specific questions, but the code comparison is JASS, so I just guessed...
Lately I've been going through my triggers and recreating any of them that can be done in GUI. I learned triggers by jumping straight into JASS, but now I want to make them GUI if possible to allow others to easily use them and understand them as well.
Take my Clock as an example:
GUI converted to JASS:
JASS:
function Trig_Clock_Func001Func004C takes nothing returns boolean
if ( not ( udg_f < 59 ) ) then
return false
endif
return true
endfunction
function Trig_Clock_Func001A takes nothing returns nothing
set udg_p = GetEnumPlayer()
set udg_f = GetPlayerState(udg_p, PLAYER_STATE_RESOURCE_FOOD_USED)
set udg_l = GetPlayerState(udg_p, PLAYER_STATE_RESOURCE_LUMBER)
if ( Trig_Clock_Func001Func004C() ) then
set udg_f = ( udg_f + 1 )
call SetPlayerStateBJ( udg_p, PLAYER_STATE_RESOURCE_FOOD_USED, udg_f )
else
call SetPlayerStateBJ( udg_p, PLAYER_STATE_RESOURCE_FOOD_USED, 0 )
set udg_l = ( udg_l + 1 )
call SetPlayerStateBJ( udg_p, PLAYER_STATE_RESOURCE_LUMBER, udg_l )
endif
endfunction
function Trig_Clock_Actions takes nothing returns nothing
call ForForce( GetPlayersAll(), function Trig_Clock_Func001A )
endfunction
//===========================================================================
function InitTrig_Clock takes nothing returns nothing
set gg_trg_Clock = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Clock, 1.00 )
call TriggerAddAction( gg_trg_Clock, function Trig_Clock_Actions )
endfunction
Created only in JASS:
JASS:
function ClockTick takes nothing returns nothing
local player p = GetEnumPlayer()
local integer f = GetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED )
local integer l = GetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER )
if f<59 then
set f = f + 1
call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED, f )
else
call SetPlayerState( p, PLAYER_STATE_RESOURCE_FOOD_USED, 0 )
set l = l + 1
call SetPlayerState( p, PLAYER_STATE_RESOURCE_LUMBER, l )
endif
set p = null
endfunction
function ClockActions takes nothing returns nothing
call ForForce( bj_FORCE_ALL_PLAYERS, function ClockTick )
endfunction
//===========================================================================
function InitTrig_Clock takes nothing returns nothing
set gg_trg_Clock = CreateTrigger()
call TriggerRegisterTimerEvent( gg_trg_Clock, 1.00, true )
call TriggerAddAction( gg_trg_Clock, function ClockActions )
endfunction
Aside from setting p = null (how do you do this in GUI? I can't find it...), there isn't much difference aside from getting rid of useless BJ's and such. And getting rid of the pointless return true/false function.
My Questions:
1. How do you set a variable equal to null in GUI? Or do you just have to call a custom script to do it?
2. What would be the speed difference in Gameplay? This happens every second, and there are a lot of things happening on this map anyways. Performance is key.
3. When Blizzard adds udg_ in front of a variable, doesn't that mean it is global? Can I not create local variables in GUI? The only way I know to create variables using the GUI is to click on Edit > Variables.
My GUI, for your information:
-
Clock
-
Events
- Time - Every 1.00 seconds of game time
- Conditions
-
Actions
-
Player Group - Pick every player in (All players) and do (Actions)
-
Loop - Actions
- Set p = (Picked player)
- Set f = (p Food used)
- Set l = (p Current lumber)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- f Less than 59
-
Then - Actions
- Set f = (f + 1)
- Player - Set p Food used to f
-
Else - Actions
- Player - Set p Food used to 0
- Set l = (l + 1)
- Player - Set p Current lumber to l
-
If - Conditions
-
Loop - Actions
-
Player Group - Pick every player in (All players) and do (Actions)
-
Events
Also, I wasn't entirely sure if this would go in GUI or JASS, I ask some GUI specific questions, but the code comparison is JASS, so I just guessed...