Strange behavior of .match() function..

Status
Not open for further replies.

Xyonel

Indie Developer, All-in-one artist.
Veteran
Joined
Jul 22, 2018
Messages
183
Reaction score
37
First Language
Italian
Primarily Uses
RMMV
hey I'm here again asking for infos:

this is the first common event script call that works well:

function makeid(length) {
var result = '';
var characters = 'LETTERS';
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
word = makeid(Math.randomInt(2)+50);
$gameVariables.setValue(29, word);

then i call a conditional branch: ($gameVariables.value(29).match(/text/g) || []).length > 0



THEN, in another common event:

$gameVariables.value(28).push($gameActors.actor(18).name().toUpperCase())

conditional call: ($gameVariables.value(28).match(/text/g) || []).length > 0


how can the first common call event works and the second no?
in the first call event page maybe the big script interact in some way that I don't understand?

I'm really confused..

this is the error message:" $gameVariables.value(...).match is not a function"
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,237
Reaction score
1,228
First Language
Spanish
Primarily Uses
RMVXA
$gameVariables.value(28) results to be an array, because of .push(val)

by retrieving value(28), you're returning an array, not a string.

print index 28 and double check it.... if it's a string, double check the regex... if not, there's your answer.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,763
Reaction score
5,202
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

mlogan wrote on alltheyuriz's profile.
Please be aware that our Status rules ask members not to make more than 2 status updates in 24 hours.
rux
Just 80% of my motivation on game making lmao, anyone got tips on how to not be unmotivated?
I've signed up for a job training program for people with Asperger's Syndrome. I went to a "test run" today so they could see how well I did with simple jobs, and I amazed them. Most new people do it in 30+ minutes, while I finished in a mere 15 minutes. Gives me time to work on a screenplay for Studio MDHR...
People,I have seen that Someone from China/Chile and London is doing a Vaccine Against COVID-19.

Forum statistics

Threads
105,467
Messages
1,013,917
Members
137,108
Latest member
maxmach
Top