how to create an local group variable

Ashlebede

New Member
In JASS :

JASS:
local group myGroup


In GUI, you have to create a variable normally (CTRL+B), then you can create a local using Custom Script, with the same name as your variable pre-declared with CTRL+B. The local will have priority over the global when you use it :

Trigger:
  • Custom Script : local group udg_myGroupsName


Don't forget to place [ljass]udg_[/ljass] before your variable's name.

Note : it will not exist in your whole trigger, but only in the trigger's main function. It might not work as intended.
 

RangerX

I am justice!
well i know that but [this is my bad didn't put it straight] i need an variable in a jass spell :|

JASS:

function Trig_PA_GetG_II_Func003002002 takes nothing returns boolean
    return ( UnitHasBuffBJ(GetFilterUnit(), 'B007') == true )
endfunction

function Actions takes nothing returns nothing
    local group g
    local unit tu = GetEnumUnit()
    local location pos
    local location offpos
    set g = udg_Pulse_A
    set pos = GetUnitLoc(GetEnumUnit())
    set offpos = PolarProjectionBJ(pos, 150.00, ( 180.00 + GetUnitFacing(tu) ))
    call SetUnitPositionLoc( GetEnumUnit(), offpos )
    call RemoveLocation(pos)
    call RemoveLocation(offpos)
    call UnitRemoveAbility( tu, 'B007' )
    call GroupRemoveUnit( g,tu)
    call DestroyGroup (udg_Pulse_A)
endfunction

function Trig_PA_GetG_II_Actions takes nothing returns nothing
    local group g
    call TriggerSleepAction( 0.50 )
    set g = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_PA_GetG_II_Func003002002))
    call ForGroup( g, function Actions )
    call TriggerSleepAction( 0.10 )
    call DestroyGroup (g)
    set udg_Pulse_A = g
endfunction

//===========================================================================
function InitTrig_PA_GetG_II takes nothing returns nothing
    set gg_trg_PA_GetG_II = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_PA_GetG_II, 0.03 )
    call TriggerAddAction( gg_trg_PA_GetG_II, function Trig_PA_GetG_II_Actions )
endfunction


i need to get rid of that "udg_Pulse_A" thingy so i can be sure is mui :p
 

tooltiperror

Super Moderator
Despite what many coders think, boolexpr variables created through Condition or Filter do not leak any more than a string would, as they are recycled. When a boolexpr is first created, it is placed in the memory.
Actually, as the quote explains, [LJASS]boolexpr[/LJASS]'s are not created everytime you use [LJASS]Condition[/LJASS] or [LJASS]Filter[/LJASS], however they are created for the following functions.

JASS:

And(...,...)
Or(...,...)
Not(...)


You can also use [LJASS]null[/LJASS] in a boolexpr without leaking.
 

RangerX

I am justice!
is this the right way of doing this ?
JASS:

function filter takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(),'B007')>0
endfunction
function Main_Actions takes nothing returns nothing 
    local unit tu = GetEnumUnit()
    local location pos
    local location offpos
    local real angle
  if GetUnitAbilityLevel(tu,'B007')>0 then 
    set pos = GetUnitLoc(GetEnumUnit())
    set angle = AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetUnitLoc(tu)) 
    set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
    call SetUnitPositionLoc( GetEnumUnit(), offpos )
    call RemoveLocation(pos)
    call RemoveLocation(offpos)
    call UnitRemoveAbility( tu, 'B007' )
  endif
endfunction

function Actions takes nothing returns nothing
    local group g = CreateGroup()
    local boolexpr be = Condition(function filter)
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea,be)
    call DestroyBoolExpr(be)
    call TriggerSleepAction(0.05)
    call ForGroup( g, function Main_Actions )
    call DestroyGroup (g)
endfunction



//===========================================================================
function InitTrig_PA_GetG_II takes nothing returns nothing
    set gg_trg_PA_GetG_II = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_PA_GetG_II, 0.03 )
    call TriggerAddAction( gg_trg_PA_GetG_II, function Actions )
endfunction
 

tooltiperror

Super Moderator
There are a few problems.

  • [LJASS]TriggerAddAction[/LJASS] is slower than [LJASS]TriggerAddCondition[/LJASS].
  • You make use of a few BJ's.
  • The Boolexpr doesn't need to be leak cleared like that, it's fine.
  • You are using leaking groups.
  • You don't need the filter function.
  • This should be in a scope/library.
 

RangerX

I am justice!
could you help me get this right I'm tring to learn jass
[without the BJ i know how to fix them but they are my last problem ]
 

tooltiperror

Super Moderator
JASS:
//warning: untested
 library Periodic initializer OnInit
   globals
       group GROUP=CreateGroup()
   endglobals
   private function filter takes nothing returns boolean
       local unit e = GetEnumUnit()
       local location pos
       local location offpos
       local real angle
       if GetUnitAbilityLevel(tu,'B007')>0 then 
           set pos = GetUnitLoc(GetEnumUnit())
           set angle = AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetUnitLoc(tu)) 
           set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
           call SetUnitPositionLoc( GetEnumUnit(), offpos )
           call UnitRemoveAbility( tu, 'B007' )
       endif
       call RemoveLocation(pos)
       call RemoveLocation(offpos)
       set pos=null
       set offpos=null
       set e=null
       return false
   endfunction
   private function Actions takes nothing returns boolean
       call GroupEnumUnitsInRect(GROUP,bj_mapInitialPlayableArea,Filter(function filter))
       return false
   endfunction
   private function OnInit takes nothing returns nothing
       call TimerStart(CreateTimer(),0.05,true,function Actions)
   endfunction
 endlibrary


Completely untested, but it should work. Just remove the BJ's. I hope you know using a low frequency like this may cause lag.
 

RangerX

I am justice!
k testing :) i know but i use that just because the spell is an auto-attack spell [searing arrows] and i need it so the target go be pushed back [without using any slide cuz only in this is used knowkback :p let's see :p
 

tooltiperror

Super Moderator
If you just base your ability off of an existing one and use this library you can actually register the event.
 

RangerX

I am justice!
with the old trigger ? yes with this one they get the buff but it seems that the buff is not removed or instamove 150point backward
 

tooltiperror

Super Moderator
JASS:
//warning: untested
 library Periodic initializer OnInit
   globals
       group GROUP=CreateGroup()
   endglobals
   private function filter takes nothing returns boolean
       local unit e = GetEnumUnit()
       local location pos
       local location offpos
       local real angle
       if GetUnitAbilityLevel(tu,'B007')>0 then 
           set pos = GetUnitLoc(e)
           set angle = GetUnitFacing(e)+180
           set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
           call SetUnitPositionLoc( GetEnumUnit(), offpos )
           call UnitRemoveAbility( tu, 'B007' )
       endif
       call RemoveLocation(pos)
       call RemoveLocation(offpos)
       set pos=null
       set offpos=null
       set e=null
       return false
   endfunction
   private function Actions takes nothing returns boolean
       call GroupEnumUnitsInRect(GROUP,bj_mapInitialPlayableArea,Filter(function filter))
       return false
   endfunction
   private function OnInit takes nothing returns nothing
       call TimerStart(CreateTimer(),0.05,true,function Actions)
   endfunction
 endlibrary


Should work now, I forgot that I separated the functions and didn't carry over a variable.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • tom_mai78101 tom_mai78101:
    I have a GIF though
  • tom_mai78101 tom_mai78101:
    In the GIF, I've configured it so the lower the "Main Value" is, the better. I had to compress it pretty far down though.
  • tom_mai78101 tom_mai78101:
    And this is the thread with the video that shows the wall clip. https://tasvideos.org/Forum/Topics/23453
    +2
  • tom_mai78101 tom_mai78101:
    Hmm, about the Headline News, I noticed threads are being moved into the subforum (Health News, Environmental News, etc.). When that happens, the TH Forum Home page loses the articles, and instead would show old articles posted 1 or 2 weeks ago.
  • tom_mai78101 tom_mai78101:
    What do we do with the Home page?
  • Ghan Ghan:
    I added those forums to the filter for that widget.
  • tom_mai78101 tom_mai78101:
    Oh nice. They're back. Thanks.
  • tom_mai78101 tom_mai78101:
    Now I think it makes more sense for me to put news in their own subforums, without worry.
  • The Helper The Helper:
    Awesome Ghan thanks! I was purposely not moving the first 15 news articles in Headline news to the different subforums but I guess I don't have to do that now?
  • tom_mai78101 tom_mai78101:
    Question: Is there a way to remove thread redirects? It creates a copy of the moved thread and takes up space, and I am leaning towards wanting to remove them in the Headline News. But if they have an expiration date, I guess I'm fine with it.
  • The Helper The Helper:
    If you move a thread please leave a permanent redirect. You can delete any redirects after 6 months. The redirects are left to help Search Engines find the moved content.
  • tom_mai78101 tom_mai78101:
    What if you move the permanent redirect, not the thread?
  • The Helper The Helper:
    I think that works but I have not messed with it. You can delete redirects though if you have to that will not delete the original thread
  • The Helper The Helper:
    if a redirect ends up in the same forum as the post it goes to though I think the redirect drops or fails or something but they are not bugged out and when you are working on an indirect the original post is safe.
  • The Helper The Helper:
    Happy Early Friday :)
    +1
  • V-SNES V-SNES:
    Happy Friday :)
  • tom_mai78101 tom_mai78101:
    Fun Friday for me
  • tom_mai78101 tom_mai78101:
    Happy Fun Friday to all.
    +2
  • The Helper The Helper:
    Happy Sunday everyone!!!
  • V-SNES V-SNES:
    Happy Sunday!!!
    +1
  • jonas jonas:
    Happy monday :p
  • jonas jonas:
    Everyone hates mondays?
    +1
  • The Helper The Helper:
    Happy Tuesday!
  • jonas jonas:
    Happy belated tuesday

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top