Difference between revisions of "MPUZ: Object Variables"

From Mario Fan Games Galaxy Wiki
m (mrf)
m
 
Line 3: Line 3:
 
===Variables and Object Structure===
 
===Variables and Object Structure===
 
Note: the values of these variables are examples only.
 
Note: the values of these variables are examples only.
<nowiki>object = {
+
<source lang="lua" enclose="div">object = {
    sysid = 1,
 
 
     objid = "MP_OBJECT",
 
     objid = "MP_OBJECT",
 
     linkid = 0,
 
     linkid = 0,
Line 10: Line 9:
 
     x = 0,
 
     x = 0,
 
     y = 0,
 
     y = 0,
     xleft = 0,
+
     z = 0,
     xright = 0,
+
     width = nil,  -- *
     ytop = 0,
+
    height = nil, -- *
     ybottom = 0,
+
    left = nil,  -- *, **
     xscale = 0,
+
    right = nil,  -- *, **
     yscale = 0,
+
     top = nil,    -- *, **
 +
     bottom = nil, -- *, **
 +
     xscale = 1,
 +
     yscale = 1,
 
     angle = 0,
 
     angle = 0,
    direction = 0,
+
     alpha = 1,
     alpha = 0,
+
     property = { },
    prop1 = "",
 
    prop2 = "",
 
    prop3 = "",
 
    prop4 = "",
 
     prop5 = "",
 
 
     sys = { },
 
     sys = { },
 
     cust = { },
 
     cust = { },
 +
    group = { },
 
     plugin = { },
 
     plugin = { },
 
}
 
}
</nowiki>
+
-- *: these values are not stored explicitly; instead, they are generated on-the-fly when their fields are accessed
 +
-- **: returns multiple values, not a table
 +
</source>
  
 
These are not the only variables which the engine may store in an object, but these are so-called "standard" variables which all objects will have.
 
These are not the only variables which the engine may store in an object, but these are so-called "standard" variables which all objects will have.
Line 35: Line 35:
 
===Events===
 
===Events===
 
''Triggered''
 
''Triggered''
*'''onCreate( ''OBJECT'' caller )''': called after the object is first created. For any object, this is the first event ever to be called. '''caller''' is a reference to the object that called this event, or a reference to the [[MPUZ: Null Object|Null Object]] if something other than another object called the event.
+
*'''onCreate( ''INSTANCE'' self, ''INSTANCE'' caller )''': called after the object is first created. For any object, this is the first event ever to be called. '''caller''' is a reference to the object that called this event, or a reference (<tt>null</tt>) to the [[MPUZ: Null Object|Null Object]] if something other than another object called the event.
*'''onDestroy( ''OBJECT'' caller )''': called before the object is destroyed. This is always the last event called for objects. '''caller''' is, again, the calling object, or the Null Object.
+
*'''onDestroy( ''INSTANCE'' self, ''INSTANCE'' caller )''': called before the object is destroyed. This is generally the last event called for objects, provided onDestroy does not call any other events itself. '''caller''' is, again, the calling object, or the Null Object.
 
''Continuous''
 
''Continuous''

Latest revision as of 07:40, 4 March 2010

This information is subject to change.
MPUZ
Mpuz logo.png
Development Main Page
Basics
Intermediate
Advanced
  • none
Reference
[Edit]


Objects in MPUZ have a list of variables that are used to store various information. Following is a list of those variables, which are generally accessed like selector.sysid:

Variables and Object Structure

Note: the values of these variables are examples only.

object = {
    objid = "MP_OBJECT",
    linkid = 0,
    --
    x = 0,
    y = 0,
    z = 0,
    width = nil,  -- *
    height = nil, -- *
    left = nil,   -- *, **
    right = nil,  -- *, **
    top = nil,    -- *, **
    bottom = nil, -- *, **
    xscale = 1,
    yscale = 1,
    angle = 0,
    alpha = 1,
    property = { },
    sys = { },
    cust = { },
    group = { },
    plugin = { },
}
-- *: these values are not stored explicitly; instead, they are generated on-the-fly when their fields are accessed
-- **: returns multiple values, not a table

These are not the only variables which the engine may store in an object, but these are so-called "standard" variables which all objects will have.

Within these tutorials, a subtable cust will be used to store custom variables that are unique to a single object, such as me.cust.health. MPUZ itself may store various other variables in the sys subtable; which variables these are depends upon certain aspects of the object code (such as variables used by plugins). Attached plugins are stored as keys in the plugin subtable, with their current status as their value.

Events

Triggered

  • onCreate( INSTANCE self, INSTANCE caller ): called after the object is first created. For any object, this is the first event ever to be called. caller is a reference to the object that called this event, or a reference (null) to the Null Object if something other than another object called the event.
  • onDestroy( INSTANCE self, INSTANCE caller ): called before the object is destroyed. This is generally the last event called for objects, provided onDestroy does not call any other events itself. caller is, again, the calling object, or the Null Object.

Continuous