[HELP]Passing Values Around

hellmonja27

Member
Reaction score
16
i've been GUI triggering for more than 2 years now and i think it's time to move to JASS. as of now i'm still very new to the stuff. I've been trying to convert a bunch of my spells from GUI to Jass to make them MUI, at least that's my goal for now.

so as a nooby, here's my problem:

function Flight takes nothing returns nothing
call SetUnitFlyHeightBJ( GetEnumUnit(), 0.00, I2R(udg_HS_SeismicSlide) )
endfunction

function Slide_Check takes nothing returns boolean
if ( not ( udg_HS_SeismicSlide >= 1400 ) ) then
return false
endif
return true
endfunction

function Group_Func takes nothing returns nothing
call UnitAddAbilityBJ( 'Amrf', GetEnumUnit() )
call UnitRemoveAbilityBJ( 'Amrf', GetEnumUnit() )
call SetUnitFlyHeightBJ( GetEnumUnit(), 400.00, I2R(udg_HS_SeismicSlide) )
endfunction

function Switcher takes nothing returns boolean
return ( udg_HS_SeismicSlide <= 0 )
endfunction

function Toggle takes nothing returns boolean
if ( not ( udg_HS_SeismicDownSlide == false ) ) then
return false
endif
return true
endfunction

function Main takes nothing returns nothing
if ( Toggle() ) then
set udg_HS_SeismicSlide = ( udg_HS_SeismicSlide - 100 )
call ForGroupBJ( udg_HS_SeismicGroup, function Group_Func )
if ( Switcher() ) then
set udg_HS_SeismicDownSlide = true
else
call DoNothing( )
endif
else
set udg_HS_SeismicSlide = ( udg_HS_SeismicSlide + 70 )
call ForGroupBJ( udg_HS_SeismicGroup, function Flight )
if ( Slide_Check() ) then
call DestroyGroup (udg_HS_SeismicGroup)
call DisableTrigger( GetTriggeringTrigger() )
else
endif
endif
endfunction

//===========================================================================
function InitTrig_Seismic_Vert_Slide takes nothing returns nothing
set gg_trg_Seismic_Vert_Slide = CreateTrigger( )
call DisableTrigger( gg_trg_Seismic_Vert_Slide )
call TriggerRegisterTimerEventPeriodic( gg_trg_Seismic_Vert_Slide, 0.03 )
call TriggerAddAction( gg_trg_Seismic_Vert_Slide, function Main )
endfunction

this is a directly converted from my GUI Trigger and i'm trying to do away with global variables. i'm having problems with the integer variable "udg_HS_SeismicSlide", on how i should pass it's value around. what i understand in JASS is you can't pass values of local variables between functions. udg_HS_SeismicSlide's value is set on function "Main" and is used on functions "Group_Func" as a global it's no problem. but it's not MUI so how do i make it into a local? i tried using Kattana's handles but it seem to only work with timers...
 

hellmonja27

Member
Reaction score
16
will it still be MUI with a global? what struct? those "struct members" i've been seeing around?...
 

Hatebreeder

So many apples
Reaction score
381
As long as it is one-shot style. it is still MUI.

One shot, what?
He just shouldn't have timers in his code, or waits, so that it executes instantly.

But, other than that, you can combine structs with hashtables.
locally create a struct, attach it to the trigger or timer and retrieve the information you've saved.
That way, it all stays MUI, even if you have timers or waits or w/e.

Also, please indent your code ;)

EDIT: You meanie ! You just converted GUI Code into jass and renamed everything >_> I suggest you take a look at the begginer's tutorials here.
 

hellmonja27

Member
Reaction score
16
that i did. as i said before i'm converting all my GUI spells to JASS MUI spells. this is how i do it for now coz i haven't memorized all the syntax yet. anyway, thanks for the tip. at least i know now i need to learn structs and that it's possible...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      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