| 04-19-2007, 10:34 AM | #1 |
im wondering if its possible to do: [jass]struct B endstruct struct A extends B endstruct[jass] and if possible, will A have all methods B have? ---- Also another problem with NewJassGen v3, it worked fine in version 2: JASS:if (OOMS_MotionObjects[Mi]>-1) then where OOMS_MotionObjects[Mi] is a struct. But a struct is only an integer number, so how come i get error in compiling: Relation comparrission between special type and native type... How do i convert a struct type to integer then, without making an integer variable and set that to the struct: JASS:local integer IntM ... set IntM = OOMS_MotionObjects[Mi] if (IntM>-1) then |
| 04-19-2007, 01:05 PM | #2 |
1. interfaces, but methods are not recycled. -- if ( integer(OOMS_MotionObjects[Mi]) >-1) then But why compare with -1? You should compare with zero struct (aka 0) it is legal to use > with 0 and an struct. |
| 04-19-2007, 01:48 PM | #3 |
because i want to make sure, everything is under control. cus when i destroy, i set OOMS_MotionObjects[Mi] = -1 But doesnt matter, i can just use integer then. And about the interface.... Well what i wanted to do with that is to do this: JASS:struct A method Create takes integer id returns nothing endmethod method Create takes unit u returns nothing endmethod ... bunch of methods endstruct dunno if u know what i mean. But i want that struct A to have overloaded methods, so it call the right method depends on the parameter (like overloaded functions in C++). And no matter what Create function it calls, the struct A must have all the other methods with it. I want this to make it so in my system, you only need to call A.Create('hfoo') - to create a particle from unit type footman A.Create(unit) - to create a particle from an existing unit. Also call same method name. Atm i have A.Create('hfoo') and A.CreateFrom(unit) But i want same name. Just i cant figure out how to do it. -------- Also another question: Is it possible to overload operator + and - ? or is it only possible to overload [], < and > |
| 04-19-2007, 01:50 PM | #4 |
you can just set to 0 instead of -1 ... |
| 04-19-2007, 05:01 PM | #5 |
ye problem is i dont know why should i set to 0... But can u answer the operator question? can i overload operators + and -? |
| 04-19-2007, 05:12 PM | #6 |
No. And for starters -1 is not an struct, so if you ever had local structtype s=-1 this will cause syntax errors when type safety is implemented. You could just use 0, I don't see how it changes the logic there. |
| 04-19-2007, 06:25 PM | #7 |
it is just to keep things under control. The -1 value is controlled by my own arrays, so it wont effect the truct arrays. Therefore it doesnt matter. it gets the job done :P Btw i cant use 0, cus when a struct is destroyed it isnt saved to my array as 0. But: local object a = object.create() call a.destroy() a == 0 ? - will a be 0 now? |
| 04-19-2007, 10:51 PM | #8 |
why would it be 0 ? struct variables are references it will still point to something. But if you already take the effort to set the variable to -1 you may as well just set it to 0. Either way if you insist on using -1, use correct typecast operators unless you want your system to fail with the jasshelper version that includes type safety. |
| 04-20-2007, 07:38 AM | #9 |
Well as long as u dont make it imposible to set an integer = struct type then everything will be fine |
| 04-20-2007, 12:54 PM | #10 |
That's what I am saying , it will be impossible to do that. instead: set integervar = integer(structtypevar) |
| 04-20-2007, 04:34 PM | #11 |
... why are u so mean. Then i wont update >( i dont quite understand how to typecast yet... in c++ its just like this: Int(something) what about here |
| 04-20-2007, 07:32 PM | #12 |
In C++ it is just like static_cast<unsigned integer>(pointer) kind of worse. What you said Int(something) is exactly what the typecast is in vJass ... |
| 04-20-2007, 08:17 PM | #13 |
but as i read documentation.... u needed to make a struct called wek in order to call wek(W)... i dont wanna make new struct just for typecast. or am i understanding wrong. can u give better example? |
| 04-20-2007, 08:37 PM | #14 |
You are missunderstanding terribly |
| 04-20-2007, 09:12 PM | #15 |
thwn can u explain? |
