cannot read property split of undefined

Status
Not open for further replies.

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
446
Reaction score
17
First Language
French
Primarily Uses
i got error cannot read property split of undefined while trying to execute this code:

Code:
var tint=$dataMap.meta.tint; t=tint.split(',').map(Number);

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: $gameScreen.startTint([t(0),t(1),t(2),t(3)], 1);

}
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Split is a function of strings. You'd have to convert $dataMap's tint to a string before using split on it.

Edit: Didn't realise tint was a string, I'm guessing you added it yourself. Hmm, where is it set?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
where did you execute that code?
All "undefined" errors mean that you tried to access something that does not exist.
In this case, it is your titn that does not exist - which is no wonder because the meta command doesn't work that way.

Please give screenshots of where you placed those lines, of the editor window that contains the notebox you want to access and the notetag you want to access.
 

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
446
Reaction score
17
First Language
French
Primarily Uses
PLease note that this kind of codee worked before so i gguess is a small mistake. It<s a code i recreating after got data lost problem.
I realize that the code fail when tint was not set.... I need to find a way to check that first then...
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);

}
This code is better and avoid the error...
Now I just need to post another thread for my other error lol.
 
Last edited:
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,062
Members
137,575
Latest member
akekaphol101
Top