HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

struct help

12-19-2009, 04:45 PM#1
Tastingo
Hey was wondering if anyone think they could lend me a hand with this. I recently had a struct that was local. It came up with no errors, but when I made it global it had a lot of errors. How exactly would I go from making a local struct a global struct? I also do not initialize the global within the globals section. I couldn't seem to understand the whole static thing, if that's what is needed.
12-19-2009, 05:00 PM#2
TriggerHappy
Collapse JASS:
private keyword yourstructname
globals
    private yourstructname abc
endglobals
12-20-2009, 05:56 PM#3
Tastingo
Okay, I haven't had a chance to test it yet. But since it's global now, would it need static or something? Or what is the keyword doing for it?
12-20-2009, 06:00 PM#4
TriggerHappy
erm. no.
12-20-2009, 08:47 PM#5
Zerzax
A struct is always global. A struct instance can be whatever you want it to be, local or global. A struct can be private, so exclusively in its specific library or scope, or public, which is an inherent property so "public struct" definitions aren't necessary.

Collapse JASS:

private keyword Stuff

globals
    private Stuff YourGlobalReference
endglobals


struct Stuff

    integer blah

endstruct

function DoStuff takes nothing returns nothing
    local Stuff this = Stuff.create()

    set YourGlobalReference = this
    set this.blah = 299


endfunction




12-21-2009, 04:04 AM#6
Tastingo
Well I am just learning VJASS and was practicing a bit with it :). But basicly what I was doing was creating a game where the structs need to reference each other. So I wanted to make them global. In case a player leaves or something I can just delete his struct as well. I haven't messed with scopes or anything yet. But the game has different levels so I don't create the struct till the level, and it is deleted once the level is over.

So basicly...

Struct is a level
Needs to be able to reference the other structs of same type
Decided to make it global without scopes yet.

So what would the best approach be for this then? And what exactly is keyword doing?