Struct questions/errors

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
I've recently started getting into structs, and I have a few questions.

1. What's the best way to create types during initialization? I plan on using it for the entire duration of the map.

2. What does this error mean and how do I fix it: "is not of a type that allows . syntax".
 

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
1. How would I go about doing that?
2. It turns out I got this error from trying to incorrectly initialize the types. I fixed it. :)
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
    module VarsInitModule
        private static method onInit takes nothing returns nothing
            <Init vars code here.>
        endmethod
    endmodule
    private struct VarsInit extends array
         implement VarsInitModule
    endstruct
 

tooltiperror

Super Moderator
Reaction score
231
Why don't you just initialize in OnInit in the struct? I think he means creating his own type.

JASS:

//
 library Stuff
   globals
       Data SomeData
   endglobals
   struct Data
       static method OnInit takes nothing returns nothing
           set SomeData=thistype.create(...)
       endmethod
   endstruct
 endlibrary
 

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
Why don't you just initialize in OnInit in the struct? I think he means creating his own type.

JASS:

//
 library Stuff
   globals
       Data SomeData
   endglobals
   struct Data
       static method OnInit takes nothing returns nothing
           set SomeData=thistype.create(...)
       endmethod
   endstruct
 endlibrary

I was going to do this at first, but it gives me an error if I save it.
 

tooltiperror

Super Moderator
Reaction score
231
And what if the OnInit method in the struct affects how the thattype is created?
 

Bribe

vJass errors are legion
Reaction score
67
a struct by the common name 'data' should always be a private struct. Imagine if the Init function everyone loves to use weren't able to be private, you'd have a storm of conflicts.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top