Local variables

Sui-cookie

You can change this now in User CP.
Reaction score
49
If you have too many global, pre-defined, variables in a map, trigger's stop working. Are local variables counted into this?

if i have 15 max arrayed local variables, would my triggers cease to work? :confused:
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
I can imagine a situation, where the initialization trigger tries to initialize too many arrays, resulting in reaching operations limit.

Can you post your initialization triggers and a more precise problem description besides "it doesn't work"?
 

Bribe

vJass errors are legion
Reaction score
67
I'm curious what benefits would be had by maximizing an array of local variables :O

As a programmer's curiosity, I wonder if local arrays are deallocated after the endfunction line...
 

Sui-cookie

You can change this now in User CP.
Reaction score
49
i have no triggers =p i was just curious if by usuing as many local variables as i can, instead of globals, if i could get away with a few thousand more variables :p

Since globals have a limit before they get'cha in the ear when your not looking D: Was wondering if locals counted toward that :]
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
What kind of a limit are you talking about? There is no limit to the number of declared variables. At least, you'll never reach it...

If you're talking about array index limit, then the last safe index is 8190, starting from 0.
 

Sui-cookie

You can change this now in User CP.
Reaction score
49
Yes, look:
Its a map that has:
Trigger:
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Explode Footman 0001 <gen>

As it's only trigger.
However, it has five global arrays of maximum size.
The trigger doesn't work unless you get rid of some of them.
 

Attachments

  • blub.w3x
    16 KB · Views: 157

Flare

Stops copies me!
Reaction score
662
I don't have World Editor at the moment, but did you toggle the Initial Value (or Set Default, something along those lines) checkbox when creating those variables? If so, the initialization of all those variables is likely to result in the operations limit being hit, which will prevent the initialization of anything that's being initialized after those variables.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Or, maybe if you set the Maximum Size of those arrays to something bigger than the actual limit, as the limit is 8191 (8192) so have you set it to something bigger than that ?
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
You are actually crashing the "main" thread.

JASS:
globals
    // User-defined
    integer array           udg_p
    boolean array           udg_a_B
    texttag array           udg_f
    damagetype array        udg_mmmhm
    integer array           udg_jfj

    // Generated
    trigger                 gg_trg_Untitled_Trigger_001 = null
    unit                    gg_unit_hfoo_0001          = null
    trigger                 gg_trg_Untitled_Trigger_002 = null
endglobals

function InitGlobals takes nothing returns nothing
    local integer i = 0
    set i = 0
    loop
        exitwhen (i > 8192)
        set udg_a_B<i> = false # this is not required at all booleans are false by deafult
        set i = i + 1
    endloop

    set i = 0
    loop
        exitwhen (i &gt; 8192)
        set udg_jfj<i> = 0 # this is not required at all integers == 0 by deafult
        set i = i + 1
    endloop

endfunction</i></i>


JASS:

function main takes nothing returns nothing
    .
    .
    .
    call InitGlobals(  )
    call InitCustomTriggers(  )
endfunction


InitCustomTriggers was never executed because the InitGlobals crashed the thread.

ExecuteFunc is your friend in such scenarios that require a lot of processing.
 

Ashlebede

New Member
Reaction score
43
There can be only one global block per map, no exceptions, unless you use vJASS... which will place your triggers' globals at the top of the map, so... yeah. Globals can't be declared after a function / in different blocks.
 

Sui-cookie

You can change this now in User CP.
Reaction score
49
That sucks.

But back to my main point, being as the global variable's problem is loading them all at once, local variables shouldn't have to abide by this at all, would they?

to a degree, of course. I doubt 50,000 local variables running in very close intervals is going to do Warcraft much good >.<
 

Ashlebede

New Member
Reaction score
43
Local variables are created upon function call and removed when the function ends... I think, for the removal. Anyhow, they are less trouble upon startup but will make your function with locals take a little more time to execute, especially when it is, say, a group variable and you want to create a new group everytime, whereas with a global you could just directly add units to your group, if you're going to re-use it. It depends on the number of times your triggers will fire, since globals increase loading time. u_u
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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