| 01-04-2009, 07:00 PM | #1 |
I need to know if there is some way to detect difference between Child1.findInstance() and Child2.findInstance() ( if there is any ) Im trying to do something like this: JASS:struct Parent static method findInstance takes unit h returns Parent local Parent this=0 if GetWidgetLife(h) > 0.405 then if HaveStoredInteger(Cache, < child structs name >, I2S(H2I(h))) == true then set this=GetStoredInteger(Cache, < child structs name >, I2S(H2I(h))) endif endif return this endmethod // some stuff endstruct struct Child1 extends Parent // some stuff endstruct struct Child2 extends Parent // some stuff endstruct function test takes unit h returns nothing local Child1 a=Child1.findInstance(h) local Child2 b=Child2.findInstance(h) endfunction So, is there any way to do something like this? |
| 01-04-2009, 07:13 PM | #2 | |
This is from the JassHelper manual, it might help: Quote:
You'd need an interface to use getType and the static struct type. Also, there might be something on this in another part of the manual more suited to what you want. |
| 01-04-2009, 07:26 PM | #3 |
I am using .getType() and it works fine with normal methods, but it doesnt work with static methods. I kinda need to know structs typeid before I Get it from gamecache. |
| 01-04-2009, 08:14 PM | #4 |
A static method behaves exactly like a function, which is what Vexorian used. If you want to do what Vexorian did, just call it a static method instead of a function... Perhaps use some kind of attachment system with the right typeId if the static method is a code callback of some sort? (you didn't specify whether you could pass arguments to the method or not) |
| 01-04-2009, 08:39 PM | #5 |
If it can't be done then that's likely because you're doing it wrong. Why do you even need a different missionkey for each child anyway? |
| 01-05-2009, 10:05 AM | #6 |
I guess it doesnt matter. I can just use key string directly. Well, thanks for help. |
