Hi everyone,
i am new to Jass and still have problem going from the mess GUI is doing to trigger, to the nice orderly struct of VJass.
i have Converted some GUI trigger to Jass and i simplified a bit the name but the struct is all disassembled in many trigger...
i am not sure on how to make it into a nice compact and readable efficient Jass.
(the start trigger can be replaced by a custom text in GUI "call nameoffunction" i think, this one should be easy)
[Jass=Start]
function Trig_Start_Actions takes nothing returns nothing
call ConditionalTriggerExecute( gg_trg_PickUpTree )
endfunction
//===========================================================================
function InitTrig_Start takes nothing returns nothing
set gg_trg_Start = CreateTrigger( )
call TriggerAddAction( gg_trg_Start, function Trig_Start_Actions )
endfunction[/code]
(the trigger is picking all destructible at map ini and check if picked destructible is the correct type, then it add the destructible to the next trigger event "destructible die")
because in GUI the event destructible die need a specifique destructible and not a destructible type.
[Jass=PickUpTree]
function Trig_PickUpTree_003 takes nothing returns boolean
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'NTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'B002' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'B001' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'B003' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'B004' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'ZTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'FTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'BTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'ATtr' ) ) then
return true
endif
return false
endfunction
function Trig_PickUpTree_002 takes nothing returns boolean
if ( not Trig_PickUpTree_003() ) then
return false
endif
return true
endfunction
function Trig_PickUpTree_001 takes nothing returns nothing
if ( Trig_PickUpTree_002() ) then
call TriggerRegisterDeathEvent( gg_trg_TreeDropWood, GetEnumDestructable() )
else
endif
endfunction
function Trig_PickUpTree_Actions takes nothing returns nothing
call EnumDestructablesInRectAll( GetPlayableMapRect(), function Trig_PickUpTree_001 )
endfunction
//===========================================================================
function InitTrig_PickUpTree takes nothing returns nothing
set gg_trg_PickUpTree = CreateTrigger( )
call TriggerAddAction( gg_trg_PickUpTree, function Trig_PickUpTree_Actions )
endfunction[/code]
(then, the second trigger check the type of the added dying destructible and give an item upon death of destructible depending of type of destructible)
[Jass=TreeDropWood]
function Trig_TreeDropWood_004 takes nothing returns boolean
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'ZTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'FTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'BTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'ATtr' ) ) then
return true
endif
return false
endfunction
function Trig_TreeDropWood_005 takes nothing returns boolean
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'B002' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'B001' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'B003' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'B004' ) ) then
return true
endif
return false
endfunction
function Trig_TreeDropWood_003 takes nothing returns boolean
if ( not Trig_TreeDropWood_005() ) then
return false
endif
return true
endfunction
function Trig_TreeDropWood_002 takes nothing returns boolean
if ( not ( GetDestructableTypeId(GetDyingDestructable()) == 'NTtw' ) ) then
return false
endif
return true
endfunction
function Trig_TreeDropWood_001 takes nothing returns boolean
if ( not Trig_TreeDropWood_004() ) then
return false
endif
return true
endfunction
function Trig_TreeDropWood_Actions takes nothing returns nothing
set integer S = ( S + 1 )
if ( Trig_TreeDropWood_001() ) then
set udg_DeadTree[udg_S] = GetDyingDestructable()
set udg_Loc = GetDestructableLoc(GetDyingDestructable())
call CreateItemLoc( 'I011', udg_Loc )
call SetItemUserData( GetLastCreatedItem(), 99 )
call RemoveLocation(udg_Loc)
call RemoveDestructable( udg_DeadTree[udg_S] )
else
if ( Trig_TreeDropWood_002() ) then
set udg_DeadTree[udg_S] = GetDyingDestructable()
set udg_Loc = GetDestructableLoc(GetDyingDestructable())
call CreateItemLoc( 'I06A', udg_Loc )
call SetItemUserData( GetLastCreatedItem(), 99 )
call RemoveLocation(udg_Loc)
call RemoveDestructable( udg_DeadTree[udg_S] )
else
if ( Trig_TreeDropWood_003() ) then
set udg_DeadTree[udg_S] = GetDyingDestructable()
set udg_Loc = GetDestructableLoc(GetDyingDestructable())
call CreateItemLoc( 'I012', udg_Loc )
call SetItemUserData( GetLastCreatedItem(), 99 )
call RemoveLocation(udg_Loc)
call RemoveDestructable( udg_DeadTree[udg_S] )
else
endif
endif
endif
call EnableTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_TreeDropWood takes nothing returns nothing
set gg_trg_TreeDropWood = CreateTrigger( )
call TriggerAddAction( gg_trg_TreeDropWood, function Trig_TreeDropWood_Actions )
endfunction[/code]
Should i use 2 triggers or is it possible to merge it, also about the call what should i write exactly. the GUI use globals, but maybe it would be better to use local, make the code simplier..?
thanks for your time and help ^^
i am new to Jass and still have problem going from the mess GUI is doing to trigger, to the nice orderly struct of VJass.
i have Converted some GUI trigger to Jass and i simplified a bit the name but the struct is all disassembled in many trigger...
i am not sure on how to make it into a nice compact and readable efficient Jass.
(the start trigger can be replaced by a custom text in GUI "call nameoffunction" i think, this one should be easy)
[Jass=Start]
function Trig_Start_Actions takes nothing returns nothing
call ConditionalTriggerExecute( gg_trg_PickUpTree )
endfunction
//===========================================================================
function InitTrig_Start takes nothing returns nothing
set gg_trg_Start = CreateTrigger( )
call TriggerAddAction( gg_trg_Start, function Trig_Start_Actions )
endfunction[/code]
(the trigger is picking all destructible at map ini and check if picked destructible is the correct type, then it add the destructible to the next trigger event "destructible die")
because in GUI the event destructible die need a specifique destructible and not a destructible type.
[Jass=PickUpTree]
function Trig_PickUpTree_003 takes nothing returns boolean
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'NTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'B002' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'B001' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'B003' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'B004' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'ZTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'FTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'BTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetEnumDestructable()) == 'ATtr' ) ) then
return true
endif
return false
endfunction
function Trig_PickUpTree_002 takes nothing returns boolean
if ( not Trig_PickUpTree_003() ) then
return false
endif
return true
endfunction
function Trig_PickUpTree_001 takes nothing returns nothing
if ( Trig_PickUpTree_002() ) then
call TriggerRegisterDeathEvent( gg_trg_TreeDropWood, GetEnumDestructable() )
else
endif
endfunction
function Trig_PickUpTree_Actions takes nothing returns nothing
call EnumDestructablesInRectAll( GetPlayableMapRect(), function Trig_PickUpTree_001 )
endfunction
//===========================================================================
function InitTrig_PickUpTree takes nothing returns nothing
set gg_trg_PickUpTree = CreateTrigger( )
call TriggerAddAction( gg_trg_PickUpTree, function Trig_PickUpTree_Actions )
endfunction[/code]
(then, the second trigger check the type of the added dying destructible and give an item upon death of destructible depending of type of destructible)
[Jass=TreeDropWood]
function Trig_TreeDropWood_004 takes nothing returns boolean
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'ZTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'FTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'BTtw' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'ATtr' ) ) then
return true
endif
return false
endfunction
function Trig_TreeDropWood_005 takes nothing returns boolean
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'B002' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'B001' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'B003' ) ) then
return true
endif
if ( ( GetDestructableTypeId(GetDyingDestructable()) == 'B004' ) ) then
return true
endif
return false
endfunction
function Trig_TreeDropWood_003 takes nothing returns boolean
if ( not Trig_TreeDropWood_005() ) then
return false
endif
return true
endfunction
function Trig_TreeDropWood_002 takes nothing returns boolean
if ( not ( GetDestructableTypeId(GetDyingDestructable()) == 'NTtw' ) ) then
return false
endif
return true
endfunction
function Trig_TreeDropWood_001 takes nothing returns boolean
if ( not Trig_TreeDropWood_004() ) then
return false
endif
return true
endfunction
function Trig_TreeDropWood_Actions takes nothing returns nothing
set integer S = ( S + 1 )
if ( Trig_TreeDropWood_001() ) then
set udg_DeadTree[udg_S] = GetDyingDestructable()
set udg_Loc = GetDestructableLoc(GetDyingDestructable())
call CreateItemLoc( 'I011', udg_Loc )
call SetItemUserData( GetLastCreatedItem(), 99 )
call RemoveLocation(udg_Loc)
call RemoveDestructable( udg_DeadTree[udg_S] )
else
if ( Trig_TreeDropWood_002() ) then
set udg_DeadTree[udg_S] = GetDyingDestructable()
set udg_Loc = GetDestructableLoc(GetDyingDestructable())
call CreateItemLoc( 'I06A', udg_Loc )
call SetItemUserData( GetLastCreatedItem(), 99 )
call RemoveLocation(udg_Loc)
call RemoveDestructable( udg_DeadTree[udg_S] )
else
if ( Trig_TreeDropWood_003() ) then
set udg_DeadTree[udg_S] = GetDyingDestructable()
set udg_Loc = GetDestructableLoc(GetDyingDestructable())
call CreateItemLoc( 'I012', udg_Loc )
call SetItemUserData( GetLastCreatedItem(), 99 )
call RemoveLocation(udg_Loc)
call RemoveDestructable( udg_DeadTree[udg_S] )
else
endif
endif
endif
call EnableTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_TreeDropWood takes nothing returns nothing
set gg_trg_TreeDropWood = CreateTrigger( )
call TriggerAddAction( gg_trg_TreeDropWood, function Trig_TreeDropWood_Actions )
endfunction[/code]
Should i use 2 triggers or is it possible to merge it, also about the call what should i write exactly. the GUI use globals, but maybe it would be better to use local, make the code simplier..?
thanks for your time and help ^^