how to create an local group variable

Ashlebede

New Member
Reaction score
43
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!
Reaction score
69
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
Reaction score
231
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!
Reaction score
69
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
Reaction score
231
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!
Reaction score
69
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
Reaction score
231
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!
Reaction score
69
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
Reaction score
231
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!
Reaction score
69
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
Reaction score
231
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.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top