Talk:Struct Reference

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search

Initializing an array of structs[edit source]

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:[edit source]

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


Changed Example[edit source]

Thanks for pointing out a way to make the struct page better. I made the example more thorough. Dont forget to sign your talks by typing ~ 4 times at the end of your posts. Scrivener07 (talk) 2017-08-10T19:20:12 (EDT)