| 09-08-2007, 04:04 PM | #1 |
okay, im not sure about a few things, but, do struct values have to be initialized, eg, can i do this: JASS:struct Something private real VarA private int VarB private boolean isTrue endstruct Is there any limit to how many methods can exist in a struct, actually, before that, can methods be put in a struct? IE; JASS:struct Something private real VarA private int VarB private boolean isTrue method CheckisTrue takes nothing returns boolean if (this.VarA > this.VarB) then return true else return false endmethod method SetVarA takes real n returns nothing set this.VarA = n endmethod method SetVarB takes integer n returns nothing set this.VarB = n endmethod endstruct |
| 09-08-2007, 04:11 PM | #2 |
yes an entire system can be on 1 struct, but who would do that, struct is for making things seperated so u can keep better control. Methods are functions in jass that takes the struct itself and other parameters. so u can have as many methods as u want yes. And ur first example is legal, just i dont know wat u mean by initialized... |
| 09-08-2007, 04:14 PM | #3 |
i mean by initialized that they start with a value ie: private real vara = 10 And im making a system that is one struct, it is a new object type that is called projectiles and contains a whole bunch of methods that enact just on them, I just wasnt sure if it was legal becasue i havent tested it with vJASS parser test yet. |
| 09-08-2007, 04:24 PM | #4 |
yes, it's legal all that you've posted, but I think it's more flexible and readable a library with structs than a single struct with a bunch of data. |
| 09-08-2007, 06:10 PM | #5 |
Struct values don't need to be initialised. In fact, referencing them while uninitialised won't cause the thread to even crash, I believe (due to them being on arrays). |
