showPicture crash

Hi
I'm using showPicture to draw series of rectangles to form an area the player can move. And this works well first with map size of 30x30 but when I switch to 50x50 the RM crashes every time I run this code:


Code:
$gameScreen.showPicture(id, "Move", 0, xPos * tileSize, yPos * tileSize, 100, 100, this.selectionAlpha, 0);

if I comment that out it doesn't crash anymore.

This is what it looks like when its working:
des.jpg



anyone know what could be wrong?

thx!
anyone know what could be wrong?
errors are rarely in a single line unless they are syntax errors.
we need more information about what is happening, like a screenshot of the console with the error message as well as the context in which that code line is executed or called.
errors are rarely in a single line unless they are syntax errors.
we need more information about what is happening, like a screenshot of the console with the error message as well as the context in which that code line is executed or called.

that's the thing there is no error messages the RM just completely crashes
then we still need the context as that line alone is useless, it uses several variables that are nowhere defined in it.
and where and how is that code executed? how do you change the maps? and so on.
then we still need the context as that line alone is useless, it uses several variables that are nowhere defined in it.
and where and how is that code executed? how do you change the maps? and so on.

here's the whole function that gets called when it's time to move player character

Code:
TacticalBattle.startMoveMode = function ()
 {
   $tacticalMode = TacticalModes.Move;

   var moveMaxReach = 14;

   let reached = this.getGridReach(moveMaxReach, 5);

   this.gridImages = [];

   this.validMoveTiles = [];
 
   for(let i = 0; i < reached.length; i++)
   {
       let xPos = reached[i][0] + this.curPartyActorStartPos.x;
       let yPos = reached[i][1] + this.curPartyActorStartPos.y;

       if(!$gameMap.isValid(xPos, yPos)) continue;


       if(!this.canOccupyTile(xPos,yPos,this.isFlying)) continue;

       let id = 1 + this.gridImages.length;

       $gameScreen.showPicture(id, "Move", 0, xPos * tileSize, yPos * tileSize, 100, 100, this.selectionAlpha, 0);

    // Disabled for now
    //   this.setTilePicLayer(id,'below_characters');

       this.gridImages.push(id);

       this.validMoveTiles.push({x:xPos,y:yPos});

   }

   console.log("Move tile images " + this.gridImages.length);

 }

i checked by debugging that variables passed to showPicture are valid

not sure what else can I show?


The function it self exits succesfully but immediately after that RM crashes
The function it self exits succesfully but immediately after that RM crashes
that means that the problem is most likely NOT in the function but in the way the function is called - something that you still haven't told despite me asking for that info: where and when is the code executed and called?
can we see the event how it is called in both the working map and crash map?
also, I dont see the variable "tileSize" in that function as well.
that means that the problem is most likely NOT in the function but in the way the function is called - something that you still haven't told despite me asking for that info: where and when is the code executed and called?

but it wont crash if I comment out call to showPicture. so in that sense its in the function

the function is called on OK key press which calls onActionButton() and that calls startMoveMode()

◆If:Button [OK] is pressed down
◆If:IsActionPressed is OFF
◆Control Switches:#0002 IsActionPressed = ON
◆Script:TacticalBattle.onActionButton();
◆
:End
◆
:Else
◆If:IsActionPressed is ON
◆Control Switches:#0002 IsActionPressed = OFF
◆
:End
◆
:End
can we see the event how it is called in both the working map and crash map?
also, I dont see the variable "tileSize" in that function as well.

just posted the code in common event
tileSize is defined
Hmm, strange. Did u exactly need the picture to be place like that? Just askin.
Because a pictures just needs a same size as your game screen size whether it's for android/PC games
can we see the event how it is called in both the working map and crash map?

I use same map, all I do is change its size
yes, but again that doesn't answer our question.

Where and how is that common event itself triggered?
SCREENSHOT THE EVENT, DAMMIT.
an event is more than the code it contains.

and where and how is the tileSize defined?
but it wont crash if I comment out call to showPicture. so in that sense its in the function
any form of crash inside show picture would be a soft crash, and soft crashes give an error trace on the console.
if you crash without an error message, then there are only three possibilities at all:
1) you messed up and disabled the entire internal error handling.
2) it is not a crash but an external shutdown by your antivirus or a similar program
3) it is a hard crash that overrode the internal error handler.

in all three cases the show picture is only the trigger but not the cause of the crash.

I use same map, all I do is change its size
and how do you do THAT?
because if it works without changing the size, then you did something wrong when changing the size.
and by your own logic alone the error has to be in the size change, because if you don't change size it won't crash, same as it won't crash if you comment out that line....
Where and how is that common event itself triggered?
SCREENSHOT THE EVENT, DAMMIT.
an event is more than the code it contains.
ti.jpg

and how do you do THAT?

right click on the map's name and edit its size

and where and how is the tileSize defined?

at the top of my plugin file . before the
(function() {
thing

const tileSize = 48;
checking the code, I dont see tileSize (jus once), on the other partss, I see "this" with
a function behind that isn't defined, running that code should throw an error as it cannot
read that function, so there is more to the code you given us as well it is probably a plugin
than an common event code you run.

so you tell more than we dont know.

small edit:
if 30x30 works and not 50x50, can you try "odd numbers"? 31x31 and 51x51, 45x45?
right click on the map's name and edit its size
If you change the mapsize in the editor, then
1) how exactly do you start the game? playtes - new game, or loading save or how?
2) do you start on the map you changed in size or do you start on a different map?
3) are you completeing the map befoe starting, or do let the empty tiles remain empty?
4) is that map the map with ID 1 or an added map (yes, there is a difference)


As for the common event:
please add at least a wait(10) at the bottom of the event if you haven't done so already.
your toggle for the button presses is a good idea but it is not enough on itself if the common event loops sixty times per second. That would still create timing problems.
as a tiny adjustment that Andar mentioned, as parallel, you can remove that parallel
and use a "buttonCommonEvent" plugin to change that like YEP_ButtonCommonEvent
and bound it to the button, so the parallel dont have to be used.

Eliaquim has 1 too, which makes the progress better, alternative, you can add this
button to your plugin as well instead of running a common event to toggle it, or
bound it to the common event so you dont have to use the parallel process.
checking the code, I dont see tileSize (jus once), on the other partss, I see "this" with
a function behind that isn't defined, running that code should throw an error as it cannot
read that function, so there is more to the code you given us as well it is probably a plugin
than an common event code you run.

yes there is a lot of code in my plugin where this variable points at. all the code I posted works just fine with small map, its just the big ones that cause crash. I tried with size 31x31 but that was fine (45x45 crashes as well)
1) how exactly do you start the game? playtes - new game, or loading save or how?
2) do you start on the map you changed in size or do you start on a different map?
3) are you completeing the map befoe starting, or do let the empty tiles remain empty?
4) is that map the map with ID 1 or an added map (yes, there is a difference)

1) Play test, new game
2) start on the test map
3) tried both there's no difference
4) it's ID 008
2) start on the test map
please try it with starting on a different map and transfering to the test map, both with a working and a not working map, and tell any difference in behaviour.

I tried with size 31x31 but that was fine (45x45 crashes as well)
A hard crash on that means most likely the data initialization went wrong, and then the computer has no longer enough RAM available to load the probably larger picture in the show picture command.

which basically prooves that the error is elsewhere and only triggered by that show pictures demand for resources.
That is also the reason why the console on a regular crash gives out the error trace instead of just the line where the error is triggered, so that someone bughunting can trace the error to the true cause.

and which is why we now need the full plugin code to have a chance to find out where your data initialization went wrong.

Oh - and what exactly is that move picture you're trying to show? can you attach that?
Oh - and what exactly is that move picture you're trying to show? can you attach that?
move.png

Original thread: https://forums.rpgmakerweb.com/threads/showpicture-crash.162857/