|
|
#2161 | ||
|
User
Join Date: Apr 2008
Posts: 189
|
Quote:
the first part when someone said that array globals do not need to be allocated was wrong! why? coz that struct does not extend array... second example was correct and you dont need to allocate them since they extend array... which means there is no .create or .destroy methodes... thats coz array structs are usefull when it comes for player id works or simply if you need your own indexing system implemented. and so its true that in array structs like u said! each element is allocated by you when you use it! no need for .create or anything like that since extending array means that it is automatically allocated when you insert specific index... Quote:
would u mind sending that line here? Last edited by Dark_Dragon : 07-27-2009 at 12:58 PM. |
||
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#2162 | |
|
User
Join Date: Jan 2006
Posts: 118
|
Quote:
Will anyone ever create a shape? No. They'll create circles or squares, but never ever shapes. Therefor, shapes should not be structs. It's as simple as that. |
|
|
|
|
|
|
#2163 | |
|
retired coder | real ilfe
|
Quote:
Please stop this arguments, we are here to talk about vJass, not about a Shape system. And thx to dragoon for showing me delegate =D Last edited by Flame_Phoenix : 07-27-2009 at 02:24 PM. |
|
|
|
|
|
|
#2164 | |
|
User
Join Date: Apr 2008
Posts: 189
|
Quote:
you are welcome ;) |
|
|
|
|
|
|
#2165 |
|
User
Join Date: Jan 2009
Posts: 28
|
Thanks Dragon.
|
|
|
|
|
|
#2166 | ||
|
User
Join Date: Apr 2008
Posts: 189
|
Quote:
np and btw just one thing i forgot! JASS:struct test extends array real x real y real z endstruct function testfunc takes nothing returns nothing local test t set test[1].x = 3. set test[1].y = 4. set test[1].z = 5. set test[2].x = 6. set test[2].y = 7. set test[2].z = 8 // insted of that long stuff u can do this: set t = test(1) set t.x = 3. set t.y = 4. set t.z = 5. set t = test(integer(t) + 1) set t.x = 6. set t.y = 7. set t.z = 8. // will do same as array accessing! but its lesser to write :D // so pick one u like more endfunction Greets! ~DD EDIT: Quote:
hmm well to say the truth! both of you are correct! shape is real and is not... ofc it can be only one of this but from point of you two guys are looking... the result is that both of u are correct. you are looking at shape as an "in programming" object which can be line, circle... which would be "real" coz we know what line or circle is and therefore we can know what shape would be... any of this ofc! since you look at it that way it would be real. from point Eleandor is looking is well! shape is not known what it is at beginning... line, circle... so he is looking at them as we look at re+im or (x+yi)! well x would be real like line or circle and yi would be shape... well we can write yi! or y*sqrt(-1) but we cant immagine what it is other then that its on second dimension... so we can say that for shape we know it but we dont! i cant explain this to good but i understand what both of ur are talking about... so yeah from my point of view both of u are correct since every one of u sees it different! Last edited by Dark_Dragon : 07-27-2009 at 07:33 PM. |
||
|
|
|
|
|
#2167 | |
|
It feels good
Join Date: Mar 2006
Posts: 1,305
![]() ![]()
|
Quote:
Alright, for the record, scopes and libraries can't be nested, so ditch that. Also, I don't know if this is a bug or a deliberate design behaviour but I find it odd: it seems structs within libraries get their static members declared after global variables in goddamned scopes. COme the fuck on. Case in point JASS:library UnitIds private keyword KR_Units struct KalimdorRaiders static KR_Units Units endstruct private struct KR_Units static constant integer KOBOLD_MINER = 'kru0' static constant integer KODO_WAGON = 'kru1' static constant integer KODO_OFFSPRING = 'kru2' static constant integer KODO_OFFSPRING2 = 'krm2' static constant integer CENTAUR_DRUDGE = 'kru3' static constant integer CENTAUR_ARCHER = 'kru4' static constant integer OGRE_CRUSHER = 'kru5' static constant integer OGRE_CRUSHER2 = 'krm5' static constant integer HARPY_SCOUT = 'kru6' static constant integer HARPY_WITCH = 'kru7' static constant integer OGRE_CRUSHER_SIEGE = 'kru8' static constant integer OGRE_CRUSHER_SIEGE2 = 'krm8' endstruct endlibrary scope Marionette initializer Init globals private constant integer CASTER_ID = KalimdorRaiders.Units.HARPY_WITCH endglobals endscope It tells me KalimdorRaiders is an undeclared variable. |
|
|
|
|
|
|
#2168 |
|
Free Software Terrorist
Technical Director
|
variables from structs are added after other global variables. No matter if it is a library or a scope or whatever. My solution? Assign the global post- globals init ...
__________________I don't think there is a way to change this rule any time soon, as long as structs are compiled in a separate phase, it won't. |
|
|
|
|
|
#2169 |
|
User
Join Date: Jan 2009
Posts: 28
|
thanks again dragon. one more question about that if you don't mine.
What if the extended struct contains another struct? is it also allocated? JASS:struct name1 extends array integer a integer b endstruct struct name2 extends array name1 real x real y endstruct function bla takes nothing returns nothing set name2[1].x = 5. set name2[2].y = 6. set name2[1].name1[1].a = 5 etc... endfunction |
|
|
|
|
|
#2170 | |
|
User
Join Date: Apr 2008
Posts: 189
|
Quote:
yes you can have struct inside the struct but this: JASS:struct name2 extends array name1 real x real y endstruct function bla takes nothing returns nothing set name2[1].x = 5. set name2[2].y = 6. set name2[1].name1[1].a = 5 etc... endfunction should be: JASS:struct name2 extends array name1 n1 real x real y endstruct function bla takes nothing returns nothing set name2[1].x = 5. set name2[2].y = 6. set name2[1].n1 = name1(1) set name2[1].n1.a = 5 etc... endfunction Last edited by Dark_Dragon : 07-28-2009 at 05:06 PM. |
|
|
|
|
|
|
#2171 | |
|
User
Join Date: Apr 2008
Posts: 189
|
Quote:
then how are static variables sorted? if i wrote one in library and one in scope will that one in library be declared before that one in scope? or are they randomly added after globals? btw static variables should be really like they are now coz if they get messed with globals many of constants might not be accessable... and from view we are looking at structs in c++ or some other OOP language constant static variables should be allowed to always be assigned with other global constants... btw structs here are more like classes in c++! so when i am saying structs i mean classes in c++... Last edited by Dark_Dragon : 07-29-2009 at 10:12 AM. |
|
|
|
|
|
|
#2172 |
|
User
Join Date: Mar 2009
Posts: 147
|
Just a little problem with the syntax checker. If you do something like this:
JASS:struct MyStruct local integer i = //syntax error endstruct JassHelper doesn't notice this; it throws up a syntax error in the generated allocator function, rather than saying there's an error in the struct. When this happened to me it took me about 10 minutes to work out what I did wrong. Please fix it. EDIT: I have a request - please make the newline character ("\n") be considered in textmacros, so for example, I could do something like this: JASS://! textmacro MyTextmacro takes NAME, VARS struct $NAME$ $VARS$ endstruct //! endtextmacro //! runtextmacro MyTextmacro ("Data", "real x\nreal y\nunit u") JASS:struct Data real x real y unit u endstruct Last edited by Element of Water : 07-29-2009 at 06:18 PM. |
|
|
|
|
|
#2173 | |
|
User
Join Date: May 2006
Posts: 159
|
Quote:
Btw. I can not assign some constant variables as array member size like bj_MAX_PLAYERS. A better global variable treatment would be useful. |
|
|
|
|
|
|
#2174 | ||
|
User
Join Date: Apr 2008
Posts: 189
|
Quote:
i see... well i knew that classes are private (by default) and structs not! however can structs have methodes? in school we used structs only for group of variables. no methodes. anyway ty. Quote:
well that might be true, well its just since i never needed it so i did not think to much about it. however for some people yeah could need some more work :P |
||
|
|
|
|
|
#2175 |
|
It feels good
Join Date: Mar 2006
Posts: 1,305
![]() ![]()
|
STructs in c++ can have methods.
__________________Anyway, sucks to hear that Vex :( Oh well, time to redesign then :/ |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |