Version: beta
FUNCTION | |
---|---|
collectionfactory.get_status() | Get collection factory status |
collectionfactory.unload() | Unload resources previously loaded using collectionfactory.load |
collectionfactory.load() | Load resources of a collection factory prototype. |
collectionfactory.create() | Spawn a new instance of a collection into the existing collection. |
CONSTANT | |
---|---|
collectionfactory.STATUS_UNLOADED | unloaded |
collectionfactory.STATUS_LOADING | loading |
collectionfactory.STATUS_LOADED | loaded |
collectionfactory.get_status([url])
PARAMETERS
[url] |
the collection factory component to get status from |
RETURNS
status |
status of the collection factory component
|
collectionfactory.unload([url])
PARAMETERS
[url] |
the collection factory component to unload |
EXAMPLES
How to unload resources of a collection factory prototype loaded with collectionfactory.loadcollectionfactory.unload("#factory")
collectionfactory.load([url],[complete_function])
PARAMETERS
[url] |
the collection factory component to load |
[complete_function] |
function to call when resources are loaded.
|
EXAMPLES
How to load resources of a collection factory prototype.collectionfactory.load("#factory", function(self, url, result) end)
collectionfactory.create(url,[position],[rotation],[properties],[scale])
PARAMETERS
url |
the collection factory component to be used |
[position] |
position to assign to the newly spawned collection |
[rotation] |
rotation to assign to the newly spawned collection |
[properties] |
table of script properties to propagate to any new game object instances |
[scale] |
uniform scaling to apply to the newly spawned collection (must be greater than 0). |
RETURNS
ids |
a table mapping the id:s from the collection to the new instance id:s |
EXAMPLES
How to spawn a collection of game objects:function init(self) -- Spawn a small group of enemies. local pos = vmath.vector3(100, 12.5, 0) local rot = vmath.quat_rotation_z(math.pi / 2) local scale = 0.5 local props = {} props[hash("/enemy_leader")] = { health = 1000.0 } props[hash("/enemy_1")] = { health = 200.0 } props[hash("/enemy_2")] = { health = 400.0, color = hash("green") } local self.enemy_ids = collectionfactory.create("#enemyfactory", pos, rot, props, scale) -- enemy_ids now map to the spawned instance ids: -- -- pprint(self.enemy_ids) -- -- DEBUG:SCRIPT: -- { -- hash: [/enemy_leader] = hash: [/collection0/enemy_leader], -- hash: [/enemy_1] = hash: [/collection0/enemy_1], -- hash: [/enemy_2] = hash: [/collection0/enemy_2] -- } -- Send "attack" message to the leader. First look up its instance id. local leader_id = self.enemy_ids[hash("/enemy_leader")] msg.post(leader_id, "attack") end
go.delete(self.enemy_ids)
unloaded
unloaded
loading
loading
loaded
loaded