Code array

Akolyt0r

New Member
Reaction score
33
No, there was a workaround using return bugs ...but that doesnt work anymore for multiplayer... and wont work for whole warcraft with patch 1.24
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
JASS:
struct Code
code whatever
endstruct


JASS:
globals
Code array codes[SIZE]
endglobals


JASS:
function Whatever [...]
set codes[1] = Code.create()
set codes[2] = Code.create()
set codes[1].whatever = someCode
set codes[2].whatever = someOtherCode
endfunction


That is sort of like a code array, but not exactly.
 

Artificial

Without Intelligence
Reaction score
326
vJass' function interfaces are a good alternative.

JASS:
library Loller
    
    function interface Callable takes nothing returns nothing

    globals
        private Callable array Funcs
        private integer N = 0
    endglobals
    
    function AddFunctionToCall takes Callable c returns nothing
        set Funcs[N] = c
        set N = N + 1
    endfunction
    
    function CallAll takes nothing returns nothing
        local integer i = 0
        
        loop
            exitwhen i == N
            call Funcs<i>.evaluate()
            set i = i + 1
        endloop
    endfunction
    
endlibrary

scope TestLoller initializer Init 
    
    private function A takes nothing returns nothing
        call BJDebugMsg(&quot;A&quot;)
    endfunction
    
    private function B takes nothing returns nothing
        call BJDebugMsg(&quot;B&quot;)
    endfunction
    
    private function C takes nothing returns nothing
        call BJDebugMsg(&quot;C&quot;)
    endfunction
    
    private function Init takes nothing returns nothing
        call AddFunctionToCall(A)
        call AddFunctionToCall(B)
        call AddFunctionToCall(C)
        
        call CallAll()
    endfunction
    
endscope
</i>


Or you could also use boolexprs if that fits your case better.

@trb92
You can't use codes as non-static struct members, as those compile to normal arrays.
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
Artificial said:
@trb92
You can't use codes as non-static struct members, as those compile to normal arrays.
Oh... Stupid me.
 

Jesus4Lyf

Good Idea™
Reaction score
397
You may want to study TT first, and then study KT2 itself. I would be very surprised if someone ever produces a timed effect + attachment system that is faster than KT2 in firing speed. XD

And storing code is certainly not the way to do it, heh. ;)

I did actually see your attempt, as you'd know by now. But I only just got back to this post. :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top