Need to define a list in the top of script


How do I define a list, within the ‘… attributes.add( …’ section in the top. At your example, one can read how to:
this.entities = [];

// update code called every frame
EntityCreator.prototype.update = function(dt) {
// Spawn new cubes if there are less than maxCubes
while (this.entities.length < this.maxCubes) {

// Loop through Entities and delete them when their time is up
for (i = 0; i < this.entities.length; i++) {
    this.entities[i].timer -= dt;
    if (this.entities[i].timer < 0) {

… etc

But that structure seem to rely on ‘.entities’ being a built-in referral to the used list.
I need to construct and use a list that has a not-built-in script-scope.
Such as (more like):
MyScript.attributes.add(‘useFulScopeList’,{ type: ‘list’, default: [ofNumber type?]});


ok, solved in a sense (did make it work within defining at initialize-level as well myself … ‘entities’ not being built-in)


Did you mean that you want the list to be globally accessible for the entire app rather than on a specific script?


Well actually; in your tutorial you minutely explain how types are defined in the top of a script (asset, number etc…

var EntityCreator = pc.createScript(‘entityCreator’);

EntityCreator.attributes.add(‘material’, {
type: ‘asset’,
assetType: ‘material’

EntityCreator.attributes.add(‘boxDimensions’, {
type: ‘number’,
default: 10

EntityCreator.attributes.add(‘lifetime’, {
type: ‘number’,
default: 5

EntityCreator.attributes.add(‘maxCubes’, {
type: ‘number’,
default: 10

// initialize code called once per entity
EntityCreator.prototype.initialize = function() {
this.entities = [];

  • and in other places boolean).

It could be very useful with a complete list of all workable in-top type-declarations within PlayCanvas (I am not sure that a link to common Javascript applies for me (?) … PlayCanvas is still a subset )

{I want to declare
MyScript.attributes.add(‘useFulScopeList’,{ type: ‘list’, default: [ofNumber type?]});
in the top alongside, eventually, all the other workable/useable declarations types, and not only lists like
this.entities = [];
declared in script body below