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

[JASS] Confused about protecting members

Status
Not open for further replies.
Hey all. Basicly I want to make struct instances of a struct inside another.
Here is the example:

JASS:
struct Child
    // The members
    unit example
    real x = 0.
    real y = 0.

    public method run takes nothing returns nothing
         call SetUnitX(example, x)
         call SetUnitY(example, y)
    endmethod 
endstruct

struct Parent
    // The members
    real x = 0.
    real y = 0.


    Child array childrens[8191]
    integer index = 0

    public method run takes nothing returns nothing
         local integer i = 0
         
         loop
            exitwhen i > this.index
            call this.childrens[i].run()
            set i = i + 1
         endloop
    endmethod 

endstruct

So, what x and y coordinates are used in the run function of the childrens?
And, what do I need to use the parents member?

So they can be called inside the children?
Protected?

I want to access to the parents value.

Thanks in advance.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
JASS:
struct Child
    // The members
    unit example
    real x = 0.
    real y = 0.
endstruct
 
struct Parent
    // The members
    real x = 0.
    real y = 0.
 
 
    Child array childrens[8191]
    integer index = 0
 
    public method run takes nothing returns nothing
         local integer i = 0
 
         loop
            exitwhen i > this.index
            call SetUnitX(this.childrens[i].example,this.x)
            call SetUnitY(this.childrens[i].example,this.y)
            set i = i + 1
         endloop
    endmethod 
 
endstruct


But you cant make an array of 8191 within a struct, the struct itself has a maximum of 8191, you know,,
 
Level 11
Joined
Apr 6, 2008
Messages
760
he can have 8191 u he can only have 1 instance of the struct running (i think thou). I think like struct arrays that works like this, lets say we have a array with size 200. So max number of structs will be 8191/200 = 40 instances. Correct me if im wrong

EDIT:

i tried some stuff out and jasshelper have me an error when it was > 12000
 
Level 8
Joined
Aug 6, 2008
Messages
451
You can make your struct have more instances:

JASS:
struct BigMac[40000] // KINGSIZE


endstruct

Anyways, I dont really know when you actually need all 8000+ instances. Very rarely I would say. ( Spells need usually 12, sometimes more, Projectile systems and knockbacks few hundred ( more would lagg to bad ) )

edit. oh yea, the question.
( Omg , my brain is not working )

What you are looking for is interface. Read JassHelper manual.
 
Status
Not open for further replies.
Top