Type rect Field x,y,w,h Field area Function Create:rect(sx,sy,sw,sh) Local r:rect=New rect r.x = sx r.y = sy r.w = sw r.h = sh r.area = sw*sh Return r EndFunction EndType Global block:rect=block.Create(10,10,250,120)
You can have a Create function that initialises the fields. You just need to make sure you're accessing them correctly.
Basically, Functions allow you to access all instances of a Type, for example when updating them or drawing them all. And Methods allow you to alter one particular instance.
EDIT: Ok, beaten to it!