Combining Converted GUI Triggers

garion992

TH.net Regular
Reaction score
17
Little Question

I have made a Function, just converted, but there seems something unlogical in it.
JASS:

function TrigUnitName takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetEnteringUnit()) == 'hfoo' ) ) then
        return false
    endif
    return true
endfunction


is this not better:

JASS:

function TrigUnitName takes nothing returns boolean
    if ( GetUnitTypeId(GetEnteringUnit()) == 'hfoo' ) then
        return true
    endif
    return false
endfunction


thx, garion992
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
> is this not better:

Yes, Blizzard love making things more complicated than they should, your way is better. However Orc_Tamer's way is even better, use it.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Blizzard love making things more complicated than they should

Not really.
The GUI Editor is supposed to get a usable result. No matter what!
As such, it must be as general as possible.
And, actually, they made a terrific job there.

Of course, once you start down the dark path... :p
 

garion992

TH.net Regular
Reaction score
17
Uberplayer, i dont see any difference with your trigger and that one of Orc_Tamer. But it doesnt matters :p

But something else. Is it possible if you convert 2 gui triggers to jass to combine them? Cause if i add the action and the event, it already starts if i came in first region, thats only ment to say wich units enters. So what i want it to do is, if unit enters RegGiveName - it gives the name of the unit and if it enters RegCloneUnit - it clones the unit.

JASS:
function Trig_TrigCloneUnit_Actions takes nothing returns nothing
    call ShowUnitHide( GetEnteringUnit() )
    call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetEnteringUnit())), ( ( "Now cloning " + GetUnitName(GetEnteringUnit()) ) + ". Please wait...." ) )
    call TriggerSleepAction( 5.00 )
    call SetUnitPositionLocFacingBJ( GetEnteringUnit(), GetRectCenter(gg_rct_RegSpawnOriginalUnit), 270.00 )
    call ShowUnitShow( GetEnteringUnit() )
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnteringUnit()), GetOwningPlayer(GetEnteringUnit()), GetRectCenter(gg_rct_RegSpawnClone), 270.00 )
endfunction

//===========================================================================
function InitTrig_TrigCloneUnit takes nothing returns nothing
    set gg_trg_TrigCloneUnit = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_TrigCloneUnit, gg_rct_RegCloneUnit )
    call TriggerAddAction( gg_trg_TrigCloneUnit, function Trig_TrigCloneUnit_Actions )
endfunction

and
JASS:
function GiveUnitName takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), ( "Entering Unit: " + GetUnitName(GetEnteringUnit()) + ". Please notice that all Items carried will be lost!" ) )
endfunction

//===========================================================================
function InitTrig_TrigUnitName takes nothing returns nothing
    set gg_trg_TrigUnitName = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_TrigUnitName, gg_rct_RegGiveName )
    call TriggerAddAction( gg_trg_TrigUnitName, function GiveUnitName )
endfunction


EDIT: srry uberplayer, i see it now
 
Reaction score
456
>You're somewhat late...
Get glasses :cool:, you be not seeing the point. My function has GetTriggerUnit() instead of entering..:p
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
JASS:

function GiveUnitName takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), ( "Entering Unit: " + GetUnitName(GetEnteringUnit()) + ". Please notice that all Items carried will be lost!" ) )
endfunction

function Trig_TrigCloneUnit_Actions takes nothing returns nothing
local trigger OneTrigger
set OneTrigger = CreateTrigger()
call TriggerRegisterEnterRectSimple( OneTrigger, gg_rct_RegGiveName )
call TriggerAddAction( OneTrigger, function GiveUnitName )  
call ShowUnitHide( GetEnteringUnit() )  
call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetEnteringUnit())), ( ( "Now cloning " + GetUnitName(GetEnteringUnit()) ) + ". Please wait...." ) ) 
call TriggerSleepAction( 5.00 )  
call SetUnitPositionLocFacingBJ( GetEnteringUnit(), GetRectCenter(gg_rct_RegSpawnOriginalUnit), 270.00 ) 
call ShowUnitShow( GetEnteringUnit() )  
call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnteringUnit()), GetOwningPlayer(GetEnteringUnit()), GetRectCenter(gg_rct_RegSpawnClone), 270.00 )
set OneTrigger = null
 endfunction 
//===========================================================================
 function InitTrig_TrigCloneUnit takes nothing returns nothing  
set gg_trg_TrigCloneUnit = CreateTrigger( )  
call TriggerRegisterEnterRectSimple( gg_trg_TrigCloneUnit, gg_rct_RegCloneUnit )  
call TriggerAddAction( gg_trg_TrigCloneUnit, function Trig_TrigCloneUnit_Actions ) 
endfunction


Edit...Sorry...the copy system in TH arent that good...i fixed the code
 

garion992

TH.net Regular
Reaction score
17
it gives an error message...
line 36: expected end of line
did i copied it wrong or is it in the trigger
expected end of line means that: you forgot a ")"??

JASS:
GetForceOfPlayer(GetOwningPlayer(GetEnteringUnit())), ( ( "Now cloning " + GetUnitName(GetEnteringUnit()) ) + ". Please wait...." ) )  call TriggerSleepAction( 5.00 )  call SetUnitPositionLocFacingBJ( GetEnteringUnit(), GetRectCenter(gg_rct_RegSpawnOriginalUnit), 270.00 )  call ShowUnitShow( GetEnteringUnit() )


WE gives an error on this line. It says:
Expected end of Line.
 

garion992

TH.net Regular
Reaction score
17
hello,
I tried to combine 2 gui triggers into one jass. However it didn't worked.

The Trigger Combined
JASS:
function GiveUnitName takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), ( "Entering Unit: " + GetUnitName(GetEnteringUnit()) + ". Please notice that all Items carried will be lost!" ) )
endfunction

function Trig_TrigCloneUnit_Actions takes nothing returns nothing
    local trigger OneTrigger
    call TriggerRegisterEnterRectSimple( OneTrigger, gg_rct_RegGiveName )
    call TriggerAddAction( OneTrigger, function GiveUnitName )  
    call ShowUnitHide( GetEnteringUnit() )  
    call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetEnteringUnit())), ( ( "Now cloning " + GetUnitName(GetEnteringUnit()) ) + ". Please wait...." ) )
    call TriggerSleepAction( 5.00 )
    call SetUnitPositionLocFacingBJ( GetEnteringUnit(), GetRectCenter(gg_rct_RegSpawnOriginalUnit), 270.00 )
    call ShowUnitShow( GetEnteringUnit() )
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnteringUnit()), GetOwningPlayer(GetEnteringUnit()), GetRectCenter(gg_rct_RegSpawnClone), 270.00 )
    set OneTrigger = null
 endfunction 
 
//===========================================================================
 function InitTrig_TrigCloneUnit takes nothing returns nothing  
set gg_trg_TrigCloneUnit = CreateTrigger( )  
call TriggerRegisterEnterRectSimple( gg_trg_TrigCloneUnit, gg_rct_RegCloneUnit )  
call TriggerAddAction( gg_trg_TrigCloneUnit, function Trig_TrigCloneUnit_Actions ) 
endfunction


Does anyone knows what is wrong with it?
 

N-a-z-g-u-l

New Member
Reaction score
30
hello,
I tried to combine 2 gui triggers into one jass. However it didn't worked.

The Trigger Combined
JASS:
function GiveUnitName takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), ( "Entering Unit: " + GetUnitName(GetEnteringUnit()) + ". Please notice that all Items carried will be lost!" ) )
endfunction

function Trig_TrigCloneUnit_Actions takes nothing returns nothing
    local trigger OneTrigger
    call TriggerRegisterEnterRectSimple( OneTrigger, gg_rct_RegGiveName )
    call TriggerAddAction( OneTrigger, function GiveUnitName )  
    call ShowUnitHide( GetEnteringUnit() )  
    call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetEnteringUnit())), ( ( "Now cloning " + GetUnitName(GetEnteringUnit()) ) + ". Please wait...." ) )
    call TriggerSleepAction( 5.00 )
    call SetUnitPositionLocFacingBJ( GetEnteringUnit(), GetRectCenter(gg_rct_RegSpawnOriginalUnit), 270.00 )
    call ShowUnitShow( GetEnteringUnit() )
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnteringUnit()), GetOwningPlayer(GetEnteringUnit()), GetRectCenter(gg_rct_RegSpawnClone), 270.00 )
    set OneTrigger = null
 endfunction 
 
//===========================================================================
 function InitTrig_TrigCloneUnit takes nothing returns nothing  
set gg_trg_TrigCloneUnit = CreateTrigger( )  
call TriggerRegisterEnterRectSimple( gg_trg_TrigCloneUnit, gg_rct_RegCloneUnit )  
call TriggerAddAction( gg_trg_TrigCloneUnit, function Trig_TrigCloneUnit_Actions ) 
endfunction


Does anyone knows what is wrong with it?

you create a trigger everytime the unit enters... do you want to do that?

if you say combine, i would say that should be right:

JASS:
function GiveUnitName takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), ( "Entering Unit: " + GetUnitName(GetEnteringUnit()) + ". Please notice that all Items carried will be lost!" ) )
endfunction

function Trig_TrigCloneUnit_Actions takes nothing returns nothing
    call ShowUnitHide( GetEnteringUnit() )  
    call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetEnteringUnit())), ( ( "Now cloning " + GetUnitName(GetEnteringUnit()) ) + ". Please wait...." ) )
    call TriggerSleepAction( 5.00 )
    call SetUnitPositionLocFacingBJ( GetEnteringUnit(), GetRectCenter(gg_rct_RegSpawnOriginalUnit), 270.00 )
    call ShowUnitShow( GetEnteringUnit() )
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnteringUnit()), GetOwningPlayer(GetEnteringUnit()), GetRectCenter(gg_rct_RegSpawnClone), 270.00 )
    set OneTrigger = null
 endfunction 
 
//===========================================================================
function InitTrig_TrigCloneUnit takes nothing returns nothing
    local trigger OneTrigger = CreateTrigger( )  
    call TriggerRegisterEnterRectSimple( OneTrigger, gg_rct_RegGiveName )
    call TriggerAddAction( OneTrigger, function GiveUnitName )  
    set gg_trg_TrigCloneUnit = CreateTrigger( )  
    call TriggerRegisterEnterRectSimple( gg_trg_TrigCloneUnit,gg_rct_RegCloneUnit )  
    call TriggerAddAction( gg_trg_TrigCloneUnit, function Trig_TrigCloneUnit_Actions ) 
endfunction


if this is not what you wanted... then at least set the local variable to CreateTrigger( )

JASS:
local trigger OneTrigger = CreateTrigger( )


this way...
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Well...my appologies...I fixed..refer back to 11th post
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
why you double posted....and i admit i am noob...

My mistake and my appologise
 

N-a-z-g-u-l

New Member
Reaction score
30
the trigger can also be created in the local variable declaration...

and i did not make that double post, these were two threads once, and i answered into those... but thats offtopic...
 

garion992

TH.net Regular
Reaction score
17
if I dubble posted srry for that. and also for teh late reply.
And thx for all the help. I shall look at it when i have time.
maybe tomorrow XD
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top