objet is not a function.

When I run this code I get objet is not a function if the code go to the default switch.
Any idea why% thanks.

Code:
var tint=$dataMap.meta.tint;
switch(tint) {
case "night": $gameScreen.startTint([-102,-85,0,170], 1); break;
case "morning": $gameScreen.startTint([-34,-17,10,68], 1); break;
case "day": $gameScreen.startTint([0,0,0,0], 1); break;
case "evening": $gameScreen.startTint([17,-34,-68,17], 1); break;
case undefined: break;
default:
var t=tint.split(',').map(Number);
$gameScreen.startTint([t(0),t(1),t(2),t(3)], 1);
}
no, you don't - you have a typo there somewhere (object or objet? that is a big difference).
Which is why we always ask for screenshots of the error messages, simply because without we have to guess if the typo was in retyping the error message here, or because the original error was a typo in the original code.
no, you don't - you have a typo there somewhere (object or objet? that is a big difference).
Which is why we always ask for screenshots of the error messages, simply because without we have to guess if the typo was in retyping the error message here, or because the original error was a typo in the original code.
object
okay so the problem of the codes here? its kinda hard to help with out any context of your problem. telling us the error code and what you are trying to achieve is invaluable when it comes to debugging code. A screen shot of the console (press F8) is also very helpful. but lets look at this default block in the switch statement in the code you posted above.

Code:
var t=tint.split(',').map(Number);
$gameScreen.startTint([t(0),t(1),t(2),t(3)], 1);

this code makes little sense without any context as I jsut said, but there's a couple of things fundamentally wrong here.
I'm going to focus on that first line before tackling the second.
now I'm going to assume that tint is a String Object and that you know that String.split() returns an Array of strings.
Array.map(callbackFunction) returns a new array with the function applied to each element. putting Number converts the strings into numbers. so now we have an Array of Numbers.

Now the second line you call $gameScreen.startTint which takes a four element array( a Tone has four elements , red blue green and gray). you've also seem to be trying to call the array as a function like this:
Code:
t(0)

This is undoubtedly the cause of your error. An array cannot be called like a function. I think what you were trying to do was get the elements of that array. when doing this you want to use square brackets [ ], not regular brackets ( ),
getting array elements is done like this.

Code:
var myArray = [255,255,255]
var secondElement = myArray[1] //gets second element of array

Hope it helps
You got it right, I made the mistake to put () instead of
[].
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/objet-is-not-a-function.74996/