Talk:Struct Reference

From the Fallout4 CreationKit Wiki
Revision as of 07:19, 9 August 2017 by imported>Pediawikia2 (Created page with "== Initializing an array of structs == After initializing an arrry of structs, the structs in that array won't be initialized as well (i.e. they are still 'none'). Before you...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Initializing an array of structs

After initializing an arrry of structs, the structs in that array won't be initialized as well (i.e. they are still 'none'). Before you can access them, you have to initialize them separately.

Example:

struct Point
  float X
  float Y
endStruct

Point[] myPoints = new Point[5]

myPoints[1].X = 0.3456

This does not work. It does compile but the last line throws a 'cannot access a member of a none struct' error on the log. To make it work, initialize the struct before you access it, like so for example:

myPoints[1] = new Point
myPoints[1].X = 0.3456