• 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.

[vJASS] Why doesn't this library see my struct?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

I've got two libraries. The first uses a textmacro to generate variations of a struct. The second then uses of those variations in some code.

I have the second library require the first, but even so jasshelper complains that the struct doesn't exist at all.

JASS:
library Structs

//! textmacro takes Type
struct $Type$Struct
  integer i = 0
  static method create takes nothing returns thistype
    set thistype this = thistype.allocate()
    return this
  endmethod
endstruct
//! endtextmacro

//! runtextmacro("A")
endlibrary

Now my second library

JASS:
library Test requires Structs

function foo takes nothing returns nothing
  local AStruct s = AStruct.create() //complains about this line
  set s.i = 5 //complains here too
endfunction

endlibrary

I searched the generated map script and it didn't seem to even generate my AStruct code at all. Why is this not working?
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Why is this not working?

Because your library Structs itself is already full of errors:

JASS:
library Structs

// textmacros must have a name
//! textmacro takes Type
struct $Type$Struct
  integer i = 0
  static method create takes nothing returns thistype
    // what is "this"? you have to declare it first before you can set it
    set thistype this = thistype.allocate()
    return this
  endmethod
endstruct
//! endtextmacro

// Running a textmacro requires its name
//! runtextmacro("A")
endlibrary

->

JASS:
library Structs
	//! textmacro MY_MACRO takes Type
	struct $Type$Struct
		integer i = 0
		static method create takes nothing returns thistype
			local thistype this = thistype.allocate()
			return this
		endmethod
	endstruct
	//! endtextmacro

	//! runtextmacro MY_MACRO("A")
endlibrary

library Test requires Structs
	function foo takes nothing returns nothing
		local AStruct s = AStruct.create() // Works now
		set s.i = 5
	endfunction
endlibrary
 
Status
Not open for further replies.
Top