[SOLVED] Script attributes error

Hi,

I’m getting an error with displaying script attributes.

Script in question:

var SteeringWheels = pc.createScript('steeringWheels');

SteeringWheels.attributes.add('rotationMult', {type:'number', defaut:1});
SteeringWheels.attributes.add('rotationOffset', {type:'number'});

SteeringWheels.prototype.update = function(dt) {    
    this.entity.setLocalEulerAngles(0, (AutoGlobals.steering * this.rotationMult)+this.rotationOffset, 0);    
};```

AutoGlobals.steering is defined somewhere else and works, other scripts work in the same way and for them the attributes work.

I save the script and click compile in the editor. The attributes pop up for a fraction of a second and dissappear again.

Editor log:

TypeError: Cannot read property ‘type’ of null
at EntitiesScriptsIndex._isNewDefaultValueRequired (editor.js:33350)
at EntitiesScriptsIndex._setNewDefaultAttributeValueIfNeeded (editor.js:33465)
at EntitiesScriptsIndex._onSetAssetField (editor.js:33637)
at Observer. (editor.js:33338)
at Observer.Events.emit (events.js:57)
at Observer._prepare (editor.js:755)
at Observer.set (editor.js:835)
at ObserverSync.write (editor.js:1946)
at Editor. (editor.js:43129)
at Editor.Events.emit (events.js:57)
at Doc. (editor.js:42827)
at emitTwo (editor.js:21433)
at Doc.emit (editor.js:21504)
at Doc._otApply (editor.js:24866)
at Doc._rollback (editor.js:25186)
at Doc._handleOp (editor.js:24601)
at Connection.handleMessage (editor.js:23978)
at socket.onmessage (editor.js:23860)
at WebSocket.connection.socket.onmessage (editor.js:25582)

Well, that was stupid :smiley:

typo:

SteeringWheels.attributes.add('rotationMult', {type:'number', defaut:1});
SteeringWheels.attributes.add('rotationMult', {type:'number', default:1}); // <= the l in default

I think this can be deleted…

2 Likes