• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Can't add more variables

Status
Not open for further replies.
Level 7
Joined
Mar 24, 2008
Messages
184
Hi,
i had started a thread on the 3rd party tools because i thought i had a problem with Newgenpack, just today i realized the problem wasn't newgen but i've discovered the problem relies on the fact i can't add more variables, if i do, it screws up triggers and they don't work anymore, here i'm posting the relevant parts of that thread, i hope someone can solve my problem...I mean, what i want to know is if there's a limit to variables or there's something not working on my map.
The most important part is the last part, in case you want to download the map and check yourself, you can donwload it from the thread http://www.hiveworkshop.com/forums/f277/jassnewgenpack-triggers-not-working-anymore-108780/ (delete the "Timers" and "Availabletimers" array to make it work, and try adding a new array to the map, at this point it doesn't work anymore)

Hi,
Not sure if i'm posting in the right place but...
I was working on a map (writing stuff in a non active trigger actually) with newgenpack when i wanted to test the map for something else. So, when i clicked on test War3 started loading the map but just before it completed loading it crashed with the usual error "memory couldn't be on read etc...", then, after several attempts to discover what happened, i decided to make a copy of the map, delete all the Jass and vJass stuff, and open it with the normal world editor.
This time the map loaded, but no trigger was working (most of the map i'm working at is in GUI, there were just 3 triggers in Jass and 1 in vJass). I checked the triggers with the normal world editor, and they were still there, just not working wthen he map is loaded...
Now, what could've caused the problem? (the vJass script already existed, though it was disabled, the only thing i added was a library in the "Custom Script" part of the trigger editor) how can i fix that? In a Fast and Painless way if possible :)


when i open it through the normal World editor, the map loads but no trigger works (though they are visible on the map editor). The problem is not war3 or Newgenpack itself, but the fact Newgen screwed up this map in some way i don't understand and i want to fix it (that's why i said maybe i wrote in the wrong section).
Maybe it would be easier if i post the maps so you can see the error by yourself

EDIT:

So, i ran the map with newgen disabling war3err and Start war3 with Grimoire. Atm i have 2 maps, one with vJass triggers (disabled) and a copy of that map without. If i run thoose maps with war3err and Grimoire they don't work, if i run without, they start but no trigger works (not even GUI ones)


just today i was thinking what else i could've done other than writing Vjass code, and i reminded i made 2 global arrays. Tried deleting them and the map works again!
I made several tests and it went out that i cannot make more arrays...is there any limit to the number of variables you can do in a map? I have (with the working map) 79 variables and 3 arrays, at least global ones. If i make other variables it's all fine, but as soon as i make an array, triggers stop working...
 
Last edited:
Level 18
Joined
Aug 23, 2008
Messages
2,319
First of all: There is a trigger and a variable limit, but I've checked your map and you not even close to that limit. I don't know what the limit is, but it's somewhere in the thousands and you don't even have a hundred of each, so your problem is not there. I don't know what could cause your problems.
 
Level 7
Joined
Mar 24, 2008
Messages
184
let me supposed this... are u using "Integer A" and "Integer B" in a lot of loops?

if so.. replace those for some other integer variable and use that one instead of Integer A and B all the time

Yeah i've used Integer A (not B) for some loops (this is my first map and also the map where i've started learning making triggers), but they are a few (can't check now) and i would like to have an explaination of how this could interfere with new variables i'm making
 
Level 11
Joined
Dec 31, 2007
Messages
780
not with the new variables... but

integer A is a variable if you use it a lot the info stored on it will be replaced... the more triggers you use that on the worse it will work... i recommend you to use 1 different integer variable for each trigger... try that and tell me later
 
Level 7
Joined
Mar 24, 2008
Messages
184
not with the new variables... but

integer A is a variable if you use it a lot the info stored on it will be replaced... the more triggers you use that on the worse it will work... i recommend you to use 1 different integer variable for each trigger... try that and tell me later

sure, thanks for the tip (actually i'm going to turn everything in JASS so i'll use local variables) but i don't see what this has to do with my problem, expecially since i can't use triggers as soon as the map is loaded, not after using a trigger or something. Anyway i've done that, and it didn't work (i can add single variables but not arrays). Only "Single use" loops used Integer A anyway so it's not like two triggers could use it at the same time
 
Level 7
Joined
Mar 24, 2008
Messages
184
why you cant?

Good question (Hint: try reading the thread)

EDIT: I've discovered that i can make arrays with the tool from the world editor, but if i make it bigger than 6143. I do know that for each array the world editor also creates a loop, is it possible that this is what creates the problem?

EDIT 2: with that array some triggers didn't work yet (i don't think it's a case thoose were the last triggers i put...just simple "Play animation" on map init for some unit) when i deleted that array every trigger went back to work
 
Last edited:
Level 18
Joined
Aug 23, 2008
Messages
2,319
It can be a code. And no, that's not sarcastic. You can for example have Unit[162], which means unit 62 of player 1. Or take Unit[803] which is unit 3 of player 8. It'll get you very high. If you got max 8 players with max 192 units, you can have an exact array of 8192 xD
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
What a waste of array space...

You could just as easily have 1024 array indices for 8 players... Just multiply the player number with 1024 to get your starting index

e.g.
array[0 (player 1) * 1024] = array[0]
array[1 (player 2) * 1024] = array[1024]
array[2 (player 3) * 1024] = array[2048]

etc.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Yes, but I meant it's a code. So it's easy to group them. For example 172 is player 1, 7th group (for example Chaos damage), 2nd unit. If you got something organised like that and you need a random Chaos damage unit from player 1, just set RANDOM = Random number between 170 and 179 and use Unit[RANDOM]. Very easy if you ever need something like that ^^
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
OPT limate.
The thread that sets up the variable indexes exceeds the opt limate and so kills the thread. It results in a hell of a lot being left not done so most things do not work.

To avoid, do not set up arrays with 1000 of indexs using GUI. Remember that arrays enlarge as you use them automatically. All you need to do is store a value in the largest index you will ever use and the array will be set up, no need to loop or anything.

Yup that definatly is your problem as you preform over 24000 set opperations in one function. To fix do not use GUI's crap way of initilizing variables and instead just set the largest index you will use to any value and it will automatically initialize all the array indexes to no value, letting you set up only the ones that must have a value.
 
Level 7
Joined
Mar 24, 2008
Messages
184
thanks!
I see what's the problem now, less or more (see below), i've already started turning all my triggers in vJass from GUI (and i'll declare arrays with the globals vJass function) it'll be a long work but someone must do it.
Just a question, for curiosity, what does OPT mean?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
No clue.

Anyway, converting everything to vJASS just for globals is not vital, you can simply set the array size to 1 and manipulate it like normal. Keep in mind that all the indexes but 1 will have no value so they need to be asigned a value before use otherwise they might cause a thread crash if used incorrectly..
 
Level 7
Joined
Mar 24, 2008
Messages
184
No clue.

Anyway, converting everything to vJASS just for globals is not vital, you can simply set the array size to 1 and manipulate it like normal. Keep in mind that all the indexes but 1 will have no value so they need to be asigned a value before use otherwise they might cause a thread crash if used incorrectly..

oh i had just 1 array with 8192 items to set and it was an units array that needed to be filled later (i just set it to no unit), i just reset its value so now it doesn't do any loop, but i'm going to change the whole code of my map now
 
Status
Not open for further replies.
Top