• 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.

Is it nessesary to defined all elemenets of array?

Status
Not open for further replies.
Level 2
Joined
Sep 17, 2014
Messages
11
Hey guys! I am new to Jass but bofore codding in C++ so i think that understand jass code enough for modify my map because there are not difficult modifications at all that i want.

First question: I have array and i put value to him not successively. I mean that i fill up him depending on situations, so i can set his element with index 5 (or differenent) but not set elements before him(1,2,3,4). Is it bad or memmory leaks or something? By the way i need to do this that way because i need to get value by key and in C++ i would use map but here i chose indexes of array. I think now u understand why i need this and what elements can be chaotically located at the array. Therefore i ask about leaks and else.

Second question(not necessery): Now i write my code in JassCraft with editing war3map.j file after extraction from map via MPQMaster. But how can i write jass code in worl editor? Because i tired to put war3map.j back to map and then launch wc3(if already launched also ensure that game not started or selected in map list with modified map) when i want to test my changes. That's why i want to write jass code in world editor and just press one button when i want to look my changes.
 
It would be easier if you show us how you are doing it. This link will show you how to post. http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/

It sounds like you are trying something like this though.

JASS:
// IntegerArray[0] // Never set
// IntegerArray[1] // Never set
// IntegerArray[2] // Never set
// IntegerArray[3] // Never set
// IntegerArray[4] // Never set
set IntegerArray[5] = 5 // set this to value.

If you mean the above where index 5 is set but the others are not then no you do not have to initialize the other indexes to a value. It does not cause a leak.

A leak is when something in memory is lost and can't be retrieved to be disposed of.

You should take a look at my 2 tutorials to get a good basis of efficient GUI coding. ( a lot of it will relate to jass) Then look at how to code efficient jass through my GUI to efficient jass tutorial.
Links are below in my sig.
 
Level 2
Joined
Sep 17, 2014
Messages
11
Thx.
You should take a look at my 2 tutorials to get a good basis of efficient GUI coding. ( a lot of it will relate to jass) Then look at how to code efficient jass through my GUI to efficient jass tutorial.
Links are below in my sig.
Now i havn't enough time and just do fast modify on other map. But i hate to code like this when i don't know language at a good level or at least some basics. So i agree with u and i hope that later do this because have plans for 2-3 maps.
 
Ok and good luck. I'll give you some down and dirty better coding advises.

Get rid of the BJs. Blizzard functions / red text.
If you can reduce the amount of nested loops / ITEs / unit groups / anything else nested.
Anything used twice or more should be stored in a variable. Triggering unit and stuff like that. Makes coding faster, easier to read, easier to edit.
Local and Globals that are not used need to be destroyed. Example: call DestroyGroup() (this is for a unit group.)
Local and Global variables need to be nulled after they are destroyed ( if they can be destroyed). Only ones to not null are reals, integers, players, strings.

I believe I hit on most of the coding that should try to be done.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
1. Does not matter. Arrays in Wc3 are always from 0 to 8k. They are initialized with the default value, 0 in case of integer. Though it may be better to keep track what indexes you are using. Maps may be better realized via hashtable.

2. In the trigger editor of the World Editor you work in pages listed on the left side. The root at the top contains a header and the other pages each form an entry for the .wtg/.wct files. To convert a page to jass, go >Edit >Convert to custom text. When you save, all trigger pages, the header and additional generated stuff is merged to build the new war3map.j.
 
Status
Not open for further replies.
Top