Transfer locals between functions

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
is there anyway to transfer locals beetwen functions without using global variables?
 

Sim

Forum Administrator
Staff member
Reaction score
534
Yup, but it's easy to use :p

And it makes spells and stuff MUI, as opposed to globals.
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
well it's cofusing care to explain it in a simple way?
i just need to transfer 1 point with array and 1 integer
 

Sim

Forum Administrator
Staff member
Reaction score
534
Read a tutorial about using the Handle vars, located on the same site.
 
I

IKilledKEnny

Guest
There is other way. Function may take things. For example

function Doom_Angle_Rock takes unit u reutrns integer
GetUnitUserData(u)
endfunction

function Main_Doom_Angle_Rock takes nothing returns nothing
local unit my_unit=GetTriggerUnit()
local integer my_integer=Doom_Angle_Rock(my_unit)
endfunction

Edit: Look at Daelin's Advanced Tips last (5th) chapter.
 
Reaction score
333
There are other ways, better than the handle vars system I hear. It might be worth looking them up on wc3sear.
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
this is so confusing.............
look i simply use a ForForce inside a loop now i need to enter to the function which contain the player's actions to simply take the loop integer and a point with array (the array is uses the integer i need)

isn't there anyway to take them and return an action?

Edit: k i think im on to something but im not sure
i made this things:
Code:
function ForceActions takes location point2 returns nothing
    call CreateFogModifierRadiusLocBJ(true,GetEnumPlayer(),ConvertFogState(4),point2,500)
    call PanCameraToTimedLocForPlayer(GetEnumPlayer(),point2,0.80)
endfunction
Code:
        call ForForce(GetPlayersAll(),function ForceActions(point2[A])
after i found it out the only thing i needed is to take the point.
now there's only 1 problem: i get an error with messege: "Expected ' " in the ForForce
 
I

IKilledKEnny

Guest
> call ForForce(GetPlayersAll(),function ForceActions(point2[A])

do:

call ForForce(GetPlayersAll(),ForceActions(point2[A]))
 

Tom Jones

N/A
Reaction score
437
Impossible... You can't use a function with parameters (A function that takes a handle) inside ForGroup, or ForForce.
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
thx but it's still showing the same.
if i remove this (point2[A]) completly it works but then im back to the start cuz i still need the location

Edit: for TomJones is there anyway i can take my point and use it in the other function?
 

Tom Jones

N/A
Reaction score
437
Use custom value of a unit, or if no unit is present, and the function runs really fast, change the name of the player to your integer value, and then change it back after you set the integer value to a local in the next function.

*Edit*
What are you trying to do?
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
What are you trying to do?
that should explain:
look i simply use a ForForce inside a loop now i need to enter to the function which contain the player's actions to simply take the loop integer and a point with array (the array is uses the integer i need)

isn't there anyway to take them and return an action?
but i relized i only need the point itself in the end so i just need a way to transfer it throught this ForForce
 

Tom Jones

N/A
Reaction score
437
Allright, we can't transfer the location from one function to another without handle vars, so create a global variable, and set it to your location, and get it in the callback function.

Code:
function Bla_ForceActions takes nothing returns nothing
    local location loc = udg_TempLoc

    ...
    call RemoveLocation(loc)
 
    set loc = null
endfunction

function Bla takes nothing returns nothing
    local force f = CreateForce()
    
    set udg_TempLoc = *SomeLoc*
    call ForForce(f,function Bla_ForceActions)
    call ForceClear(f)
    call DestroyForce(f)

set f = null    
endfunction
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
k if that's the only way i will use globals....
anyway thx for any1 for helping or trying to help +Rep to All :D (im in a good mood)

Btw: Tom u forgot to remove the Temp Point ;)
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
k i made it and it all works fine except:
the rest of the actions in the loop after the ForForce are not being activated as in skipped is that supposed to happen?
here's my loop:
Code:
      loop
        exitwhen (A > End)
        call CreateDestructableLoc('OTsp',point2[A],facing[A],0.80,0)
        set d = GetLastCreatedDestructable()
        call CreateUnitAtLoc(Player(14),'nstw',point2[A],facing[A])
        set udg_Dinosaur[A] = GetLastCreatedUnit()
        call SetUnitPathing(udg_Dinosaur[A],false)
        call SetUnitAcquireRange( udg_Dinosaur[A],0)
        set point3[A] = PolarProjectionBJ(point2[A],250,AngleBetweenPoints(point2[A],point))
        set udg_Temp_Point = point2[A]
        call ForForce(GetPlayersAll(),function ForceActions)
//   Being skipped for some reason from this point....
        call IssuePointOrderLoc( udg_Dinosaur[A], "move", point3[A] )
        call TriggerSleepAction(0.8)
        call KillDestructable(d)
        call SetUnitTimeScale(udg_Dinosaur[A],0)
        call PauseUnit(udg_Dinosaur[A],true)
        call DestroyFogModifier(GetLastCreatedFogModifier())
        set A = A+1        
      endloop
any reason why it won't work?

Edit: after a second check i figured it doesn't skip but yet a few stuff here doesn't work:
Order,Pause unit and unit animation,Unit acquire range and more.......

also another question on the way:
call SetTimeOfDayScalePercentBJ(0)
care to explain how it works?
it moves my time like crazy when i used "call SetTimeOfDayScale(0)" and i when i used the above action it still moves while it's supposed to be stopped......
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
k here it is:
Code:
function ForceActions takes nothing returns nothing
    local location point2 = udg_Temp_Point
    call CreateFogModifierRadiusLocBJ(true,GetEnumPlayer(),ConvertFogState(4),point2,500)
    call PanCameraToTimedLocForPlayer(GetEnumPlayer(),point2,0.80)
    call RemoveLocation(udg_Temp_Point)
    call RemoveLocation(point2)
    set point2 = null
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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