• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[vJASS] Textmacro Problems

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
JASS:
    struct attribute
        choice array choices[MAX_CHOICES]
        string name
        integer max_choice
        static method RegisterChoice takes choice c returns nothing
            set .max_choice = .max_choice + 1
            set .choices[.max_choice] = c
        endmethod
        
        static method create takes string name returns attribute
            local attribute r = attribute.allocate()
            set r.name = name
            return attribute
        endmethod
    endstruct
    
    struct choice
        string cname
        //! textmacro SetType takes TYPE
        $TYPE$ data
        static method create takes string name, $TYPE$ a returns choice
            local choice r = choice.allocate()
            set .cname = name
            set .data = a
            return choice
        endmethod
        //! endtextmacro
    endstruct
    
    //! runtextmacro SetType("string")
    function tempint takes nothing returns nothing
        local attribute r = attribute.create("Hair Color")
        call r.RegisterChoice(choice.create("Black", ""))
    endfunction

I keep getting the error: Constructor requires no arguments

Any Ideas why? Keep in mind this is the first time ever messing with textmacros.
 
The way it should look like:

JASS:
struct attribute
    choice array choices[MAX_CHOICES]
    string name
    integer max_choice
    static method RegisterChoice takes choice c returns nothing
        set .max_choice = .max_choice + 1
        set .choices[.max_choice] = c
    endmethod
    
    static method create takes string name returns attribute
        local attribute r = attribute.allocate()
        set r.name = name
        return attribute
    endmethod
endstruct

//! textmacro SetType takes TYPE
    $TYPE$ data
    static method create takes string name, $TYPE$ a returns choice
        local choice r = choice.allocate()
        set .cname = name
        set .data = a
        return choice
    endmethod
    //! endtextmacro

struct choice
    string cname
    //! runtextmacro SetType("string")
endstruct

function tempint takes nothing returns nothing
    local attribute r = attribute.create("Hair Color")
    call r.RegisterChoice(choice.create("Black", ""))
endfunction
 
Alright that worked, now I added more macros and it isn't working anymore:

JASS:
   struct attribute
    choice array choices[MAX_CHOICES]
    string name
    integer max_choice
    static method RegisterChoice takes choice c returns nothing
        set .max_choice = .max_choice + 1
        set .choices[.max_choice] = c
    endmethod
    
    static method create takes string name returns attribute
        local attribute r = attribute.allocate()
        set r.name = name
        return attribute
    endmethod
endstruct

    //! textmacro SetType takes TYPE
    $TYPE$ data$TYPE$
    static method create$TYPE$ takes string name, $TYPE$ a returns choice
        local choice r = choice.allocate()
        set .cname = name
        set .data$TYPE$ = a
        return choice
    endmethod
    //! endtextmacro

struct choice
    string cname
    //! runtextmacro SetType("string")
    //! runtextmacro SetType("real")
    //! runtextmacro SetType("integer")
endstruct

function tempint takes nothing returns nothing
    local attribute r = attribute.create("Hair Color")
    call r.RegisterChoice(choice.createstring("Black", ""))
endfunction
 
It should be return r. You wan't to return the fresh instance, not the data type.
This one looks better tho':

JASS:
static method create$TYPE$ takes string name, $TYPE$ a returns thistype
    local thistype this=thistype.allocate()
    set this.cname=name
    set this.data$TYPE$=a
    return this
endmethod

Also, you should check the next tutorial: https://www.hiveworkshop.com/forums...83/jpag-jass-proper-application-guide-204383/
 
I know how to JASS properly, I was just practicing with textmacros, I've never used them before, so I'm using an old system and try applying it to it.

Thanks for the help, I got it working now. I just never realized where you put the //! runtextmacro goes is where the code is copied to.
 
Status
Not open for further replies.
Back
Top