HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to make a static array of a struct

03-02-2009, 12:32 PM#1
fX_
Unless I'm just making things up in my head, I have seen script like:

Collapse JASS:
struct A extends array
    endstruct

    //somewhere
    set A[0] = A.create()
    call A.whatever()
    //etc.

This is what I have:

Collapse JASS:
library Camera initializer Init requires Effect

    globals
        private constant integer MAX_QUEUED_CAMERAS = 10
    endglobals

    private struct PlayerCamera extends array

        private CameraTemplate array cam[MAX_QUEUED_CAMERAS]
        private integer intCountCamera = 0

    endstruct

    struct CameraTemplate extends Effect
    endstruct

    private function Init takes nothing returns nothing
    endfunction

endlibrary

but that won't compile. What's wrong? Also, if I can create an array of the struct, how do I limit it to 12 instances?
03-02-2009, 12:49 PM#2
akolyt0r
The snippet you saw somewhere is wrong.. array structs cant be allocated/created

you cant have array variables in a struct which extends array ...
and i dont think you can limit the instance count a struct which extends an array..


Collapse JASS:
private struct PlayerCamera[12]
        private CameraTemplate array cam[MAX_QUEUED_CAMERAS]
        private integer intCountCamera = 0
    endstruct
is that what you want ?
03-02-2009, 12:58 PM#3
fX_
That is what I have in mind as an alternative. Just wanted to check if the above is possible; guess I just made it up in my head.