HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[vJass] get a method of a struct in code ?

05-22-2008, 05:00 PM#1
Troll-Brain
i know my question must be hard to understand :p

So, i will give an example

Collapse JASS:
scope MyScope

   globals
      code C
   endglobals

   struct MyStruct
      
      static method MyMethod takes nothing returns nothing
      endmethod

   endstruct

   function test takes nothing returns nothing
      set C= MyScope.MyStruct.MyMethod.code // it would be great for me
   endfunction

endscope

Do you think it's a good idea or is it useless ?
05-22-2008, 05:37 PM#2
TheDamien
I asked the same question a while back and got:

Collapse JASS:
function structname.methodnaname
05-22-2008, 06:01 PM#3
grim001
Collapse JASS:
 
  function test takes nothing returns nothing
      set C= MyStruct.MyMethod
   endfunction
05-22-2008, 06:27 PM#4
Anitarf
Ya, that should work. I have used methods as timer callbacks before (like in the hero contest for example).
05-22-2008, 06:48 PM#5
Toadcop
it's static... so crap.
no it's not possible to allocate code arrays in jass. you can only mess with h2i/i2code ... so store code in integer arrays.

Collapse JASS:
function i2code_res takes integer i returns code
    return i
    return null
endfunction

function i2code takes integer i returns code
     return i2code_res(i)
endfunction

maybe it will not work properly.
05-22-2008, 07:25 PM#6
Troll-Brain
thx
05-22-2008, 07:53 PM#7
Vexorian
Quote:
store code in integer arrays.
Why would anybody with dignity need even a code variable?

You need a trigger to execute/evaluate it anyway.
05-22-2008, 10:11 PM#8
Toadcop
or a timer... =) or ForGroup for example and destruct, item shit enumerators =)
05-22-2008, 10:17 PM#9
Vexorian
I can't think of a good idea for timers, and the rest like ForGroup don't sound that important. I just hope nobody is using code values for things that require them to mak a trigger...