MV Fix Uncaught TypeError JS Plugin

Hey, so I'm new here and I've been struggling with some plugin errors.
I'm trying to insert a Tetris miniGame in my game using plugins of course- It works perfectly.
It shows up on just the right time and it's also playable
but there are some errors showing up on the screen and I don't know why.
Why showing errors when it's working perfectly?

This is the Error and the line it mentions. The number changes with each block.
index.php


(┬┬﹏┬┬)
How do i fix this? there's a time limit and i have to fix it as soon as possible. I'll be so thankful if someone helps me with it):
how is this made? by AI or your own?
if your own, I think the array might be the problem, you can try to set them
on it's own first for the value.

but do you have even anything if it's above a certain height to be game over?

how is that done? as just that snippet doesn't say anything as we don't know
the entire code.

if made by AI, your on your own as well.
the base was a ready made code i searched for on github.



1.i didn't know how to use html along with java script as plugins for rpg maker and searching didn't help. i don't know a lot about programming and its languages and i came to it for a school project, so i asked AI to help me. tho i tried to learn js a bit and changed some stuff myself. i also tried to change the array but it just made it worse-

2.yes there is and i also attached the entire code if it's needed...

if there are other ways to make a plugin with html included i'd be happy to know.

thanks a lot for replying🙂

(i also don't know if it's ok to use AI for such thing since i'm new. if it's not, like it's not to make some kind of arts with it, please tell me. )
how is this made? by AI or your own?
if your own, I think the array might be the problem, you can try to set them
on it's own first for the value.

but do you have even anything if it's above a certain height to be game over?

how is that done? as just that snippet doesn't say anything as we don't know
the entire code.

if made by AI, your on your own as well.
first of all: "e.which" is one that shouldn't be used, so use "e.code" instead.
there are other stuff that seems weird, specially game over, why not the original
game over scene.

I need to test the plugin how it plays out.

even this line looks incorrect (never tried it, as switches are booleans (true/false)

if (!$gameSwitches || typeof $gameSwitches.value !== "function") { }

but if you check github, there are issues that was left in INTENTIONALLY.
so many things could be altered.

there is a tetris game made for MV though, works differently , but same principle
as the one you made with colors instead.

requestAnimationFrame might not work either for all browsers, and there are things
missing like score that I don't see, as those can be made in the way they want too.

so you need more research to make this fully functions for MV.

here is the link to the tetris that was made.
1 - When you have errors, the Sources tab is not useful to use - show a screenshot of the full Console tab.

2 - Please don't post several hundred lines of code directly into your post. If you must put it there, put spoiler tags around it - or just attach the file itself.

3 - This is not great practice, trying to shoehorn code not written for RPG Maker into your project. At first glance, it's making its own input handlers which are going to either overwrite or conflict with RPG Maker's built-in input mappers. If all you want is this Tetris game and it's already written, there's no need to shove it into RPG Maker.

(i also don't know if it's ok to use AI for such thing since i'm new. if it's not, like it's not to make some kind of arts with it, please tell me. )
It's not "not ok" with code like it is for art in terms of having concerns about plagiarizing from people.

But it's also not a very smart idea - AI makes things up, it doesn't write code with educated knowledge that it's doing the right thing. That's pretty common knowledge, from all the articles and memes about how AI can't answer grade school math question correctly, gives you food recipes including gasoline, has conversations where it tells people to die, etc.

I've never seen AI-generated code of any complexity that actually worked correctly.

And it is against forum rules to ask for help with fixing AI-generated code.
first of all: "e.which" is one that shouldn't be used, so use "e.code" instead.
there are other stuff that seems weird, specially game over, why not the original
game over scene.

I need to test the plugin how it plays out.

even this line looks incorrect (never tried it, as switches are booleans (true/false)

if (!$gameSwitches || typeof $gameSwitches.value !== "function") { }

but if you check github, there are issues that was left in INTENTIONALLY.
so many things could be altered.

there is a tetris game made for MV though, works differently , but same principle
as the one you made with colors instead.

requestAnimationFrame might not work either for all browsers, and there are things
missing like score that I don't see, as those can be made in the way they want too.

so you need more research to make this fully functions for MV.

here is the link to the tetris that was made.
thank you for replying again(i can't help but say thanks in every repliy when people are trying to help me.)(●'◡'●)

1.so i said that it gives me errors even tho it's playable, but when i changed 'which' to 'code', the control over the blocks was gone. they just fell down without us being able to move them

2.the line that seems off wasn't there before, but i wanted to use switch conditions for the game and it kept giving me the 'Uncaught TypeError: Cannot read property 'value' of null'
one of my guesses was that maybe some rpg maker functions weren't working properly yet,(at the very beginning of the game, before loading the game)
so i tried my hardest to search and add something to fix it
and it did work...

the types of errors (the value and the one i need help with now) are the same, am i right?
but i couldn't do ANYTHING to fix this one. this one is 'Uncaught TypeError: Cannot read property 'x' of undefined' (x as numbers)
in the value error, the condition wasn't actually working. but in this one it works!
it just seems like something extra.. a wrong error only covering the screen.. but that's not really possible.

3.also for the Harold tetris game, i'll try to see what i can do with that, but i doubt it's going to be what i wanted.

thank
1 - When you have errors, the Sources tab is not useful to use - show a screenshot of the full Console tab.

2 - Please don't post several hundred lines of code directly into your post. If you must put it there, put spoiler tags around it - or just attach the file itself.

3 - This is not great practice, trying to shoehorn code not written for RPG Maker into your project. At first glance, it's making its own input handlers which are going to either overwrite or conflict with RPG Maker's built-in input mappers. If all you want is this Tetris game and it's already written, there's no need to shove it into RPG Maker.


It's not "not ok" with code like it is for art in terms of having concerns about plagiarizing from people.

But it's also not a very smart idea - AI makes things up, it doesn't write code with educated knowledge that it's doing the right thing. That's pretty common knowledge, from all the articles and memes about how AI can't answer grade school math question correctly, gives you food recipes including gasoline, has conversations where it tells people to die, etc.

I've never seen AI-generated code of any complexity that actually worked correctly.

And it is against forum rules to ask for help with fixing AI-generated code.
1.these are actually helpful thanks!

2.i want to add the tetris game to the game i'm trying to make in rpg maker as a miniGame in between, so i think i need to somehow add it as a plugin or link it. if that's what you meant tho-

3. thank you for telling me that. i'll keep them in mind! '◡'
e.code searches for keyL keyA etc which personally is better.
as "which" is deprecated is some browsers and shouldn't be used.
code or keyCode is a better approach as I switch to e.code instead
as its supported for all browsers.

but I would go to the RPG maker code like ATT_Turan said, as input is available,
and overwriting it might break more things with other plugins which you don't
want either.

if your new to RPG Maker and its plugin, than learn the engine first before
making plugins, unless you know JS as you can learn the engine maybe
a bit faster to write plugins for it.
If you're under time pressure, I'd recommend against trying to get this to work. There's a good chance you won't succeed in doing so, especially with transitioning back to the regular RM game. Put your time into making things you know you can do.

Why showing errors when it's working perfectly?
I'm not sure why you're surprised by this. It does indeed work until the point when it stops working, as do most things. Those errors are not unrelated - they tell you that the code is not working anymore.

For this particular error, seems like modifying the conditional on line 88 could fix it:
JavaScript:
if (matrix[row][col] && (
          // outside the game bounds
          cellCol + col < 0 ||
          cellRow + row < 0 ||
          cellCol + col >= playfield[0].length ||
          cellRow + row >= playfield.length ||
          // collides with another piece
          playfield[cellRow + row][cellCol + col])
        ) {
        return false;
      }

But once again, I'd highly recommend to play with that only after you've finished everything else and have a good project that will work even without the minigame.
It is playable despite there're errors because it runs on its own so MV's error handler doesn't stop it from playing. requestAnimationFrame is called before the error so it always runs.

Original thread: https://forums.rpgmakerweb.com/threads/fix-uncaught-typeerror-js-plugin.173784/