• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] struct allocation...

Status
Not open for further replies.
Level 8
Joined
Aug 4, 2006
Messages
357
Hey guys I need some vJass experts to help me out here. I am stumped. So, basically I have the following code in one trigger:
JASS:
library test
    //! textmacro Pair takes type, listType
    struct $listType$Pair
        $type$ a
        $type$ b
    endstruct
    //! endtextmacro
    
    //! runtextmacro Pair("integer", "Integer")
    //! runtextmacro Pair("real", "Real")
endlibrary
and I have another library that I want to be able to use different types of "Pair"s:
JASS:
library test2 requires test
    
    struct twoPairs
        private IntegerPair p1 = IntegerPair.create()
        private RealPair p2 = RealPair.create()
    endstruct
    
endlibrary
However when I save the map, I get compile errors saying that it can't find the RealPair allocate function. For some reason, it creates the IntegerPair allocate/destroy functions before the twoPairs allocate/destroy functions before the RealPair allocate/destroy functions. It's completely ignoring the requirements of the libraries and just placing the struct allocate functions in random order. See the attached screenshot.
 

Attachments

  • struct allocation.JPG
    struct allocation.JPG
    162.3 KB · Views: 104
Level 8
Joined
Aug 4, 2006
Messages
357
Well that's pretty lame...
So would this be the solution?
JASS:
library test2 requires test
    
    struct twoPairs
        IntegerPair p1
        RealPair p2
    
        static method create takes nothing returns thistype
            local thistype tp = thistype.allocate()
            set tp.p1 = IntegerPair.create()
            set tp.p2 = RealPair.create()
            return tp
        endmethod
    endstruct
endlibrary
 
Status
Not open for further replies.
Top