Giving structs initial value on creation?

GoGo-Boy

You can change this now in User CP
Reaction score
40
Hey there,
just a quick question. I didn't code for a long time and wondered how to create a struct and give it members certain values.

Like a 2D struct with x and y and then you do something like

local 2D d=2D.create(2,5)
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
*Bumb*

Am still not getting it work.

JASS:
private struct Vector
    real x
    real y
    static method oreate takes real x, real y returns thistype
        set .x=x
        set .y=y
    endmethod
// later on
private function Actions takes nothing returns nothing
    local integer index=0
    local Vector vec=Vector.create(1,2)


What am I missing?
 

luorax

Invasion in Duskwood
Reaction score
67
What's the problem with it?

Also, you have to fix a typo:

static method create takes real x, real y returns thistype

Oh, and:

JASS:
    static method create takes real x, real y returns thistype
        set .x=x
        set .y=y
    endmethod


Should be:

JASS:
    static method create takes real x, real y returns thistype
        local thistype this = .allocate()

        set .x=x
        set .y=y

        return this
    endmethod
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Oh boy, what a stupid typo >.<

That was the problem :/

Thank you!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top