MZ Script to show equipment icon on screen (MZ)

Hello, I'm trying to make actor 1's equipment icons appear on the screen as a hud, if actor 1 changes equipment the icon on the screen must be updated, i tried this script below, it shows the icons from index 0 to 5 on the screen but there is a sudden drop in fps, I put this script in a parallel process so the icons do not disappear when changing maps.
Script:

var actor = $gameParty.members()[0]; for (var i = 0; i <= 5; i++) { var equiphud = actor.equips()[i]; var iconIndex = equiphud ? equiphud.iconIndex : 0; if (iconIndex !== 0) { var bitmap = ImageManager.loadSystem("IconSet"); bitmap.addLoadListener(function() { var sprite = new Sprite(bitmap); sprite.setFrame(iconIndex % 16 * 32, Math.floor(iconIndex / 16) * 32, 32, 32); sprite.x = 150 + i * 50; sprite.y = 50; SceneManager._scene.addChild(sprite); }); } else { // } }
I put this script in a parallel process so the icons do not disappear when changing maps.
That would be my presumption of why you have lag. If you're telling the game to load 6 sprites 60 times a second, that creates a processor load.

It seems like it would be much more efficient to just load images when triggered by a change, then attach the sprite to get updated when the player moves.
How about it is only triggered afyer you leave the equipment menu. And in event where euipment is changed if you have any.

Once the icons are there, the script doesnt have to run untill the equipment changes, right?
That would be my presumption of why you have lag. If you're telling the game to load 6 sprites 60 times a second, that creates a processor load.

It seems like it would be much more efficient to just load images when triggered by a change, then attach the sprite to get updated when the player moves.
How can I do this? sorry I'm a layman when it comes to codes
How about it is only triggered afyer you leave the equipment menu. And in event where euipment is changed if you have any.

Once the icons are there, the script doesnt have to run untill the equipment changes, right?
Yes, I want to do exactly that, but I don't know how, so I need help.
If you accept plugins, then I recommend HUD Maker Ultra. It's super-easy to use.
If you accept plugins, then I recommend HUD Maker Ultra. It's super-easy to use.
Yes, I'm open to plugins, in fact I also tried to do this with the hud maker ultra bad plugin but I couldn't get any results, what I tried was this:
Screenshot_2.png

But obviously I'm using it wrong right? since the result has not changed, can you tell me the correct way to do this?
Moved to: Plugin Support

Your parallel process event probably would have worked, but you should have put a Wait 10 Frames as the very first command. You're also creating a new sprite every time and not disposing them. You don't need a load listener, because the iconset is loaded before you ever see anything, and remains loaded for the entire game.

I think it would work if you make your parallel process a common event, then in the event on your starting map when you turn on the switch to start it running, first create your 5 sprites, then in the common event redraw those same 5 sprites rather than creating new ones. And add the 10 Frame wait at the start.
Got it working, thanks to everyone who tried to help me, ATT_Turan, JohnDoeNews, fizzly and Shaz. 👍
I managed to make it work through the CoreEngine plugin from visustella, I used the plugin command called "Picture: Show Icon" to show an icon on the screen as an image, for my happiness the command accepts javascript, so I put the following script inside the window to put the index of the icon:

$gameParty.members()[0].equips()[0] ? $gameParty.members()[0].equips()[0].iconIndex : 0

Screenshot_1.png

And I did this five more times to show the icons of the other equipment, all this within a common parallel event, apparently it's working very well.

Original thread: https://forums.rpgmakerweb.com/threads/script-to-show-equipment-icon-on-screen-mz.156677/