Is there a pixi.js equivalent for this script call?
$gameScreen.picture(n)._name = 'name';
In other words - if I want a sprite on the map scene to use a different image, but retain all its other properties (x, y, scale, anchor, etc..), how would you go about it?
What I'm currently doing is deleting the sprite via removeChild(), creating the new one, setting all the properties again, and adding the new sprite as a child. However I'm sure there's a more efficient way to do that I just haven't figured out yet.
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
Is it possible to set animations to two frames only through code or otherwise?
-
Animations are as many frames as you define them to be in the Animations tab.Is it possible to set animations to two frames only through code or otherwise?
Do you possibly mean sprite motions, as defined in Help -> Contents -> Documentation -> Side-view Character Standards?
If yes, you could either:
- Just paste one of the existing cels over one of the others, and you'll see only two frames
or
- You could look at Sprite_Actor.updateFrame(). Changing instances of 3 to 2 would probably do what you want, but I haven't carefully examined each line and its math. If you only want to affect battle and not, say, the characters walking on the map, you might need to copy contents from that into Sprite_Battler.updateFrame(), which is currently empty. -
First of all, thanks. I want 2 frame animations both in battles and otherwise (characters walking on the map).Animations are as many frames as you define them to be in the Animations tab.
Do you possibly mean sprite motions, as defined in Help -> Contents -> Documentation -> Side-view Character Standards?
If yes, you could either:
- Just paste one of the existing cels over one of the others, and you'll see only two frames
or
- You could look at Sprite_Actor.updateFrame(). Changing instances of 3 to 2 would probably do what you want, but I haven't carefully examined each line and its math. If you only want to affect battle and not, say, the characters walking on the map, you might need to copy contents from that into Sprite_Battler.updateFrame(), which is currently empty.
Something like this: https://ibb.co/5cSzxy9
Reason being I am a decent artist, but lousy animator. It also fits perfectly with my game, and I like 2 frame animations. Plus, for combat abilities and such, I am drawing unique sprites and messing with camera and other juicy options, but that is probably too much information you are not interested on. Anyways, I will be looking into your suggestions in a bit, thanks again. -
Code:
var min = 600; //10 minutes var max = 900; //15 minutes var frames = Math.random() * (max + 1 - min) + min; this.wait(frames * 60);
Hi guys. I have the above as a common parallel event. The goal is for the game to wait for 10-15 minutes before respawning an event.
(Resolved) Could you help me out please with these two questions:
- Does this wait get reset every time the game is loaded? - Answer: no
- What about every time a player transfers maps? - Answer: yes
Code:.$gameSystem.playtime() -
SoDoes this wait get reset every time the game is loaded?
What about every time a player transfers maps?this.wait()is exactly what the Wait event command calls (I understand you're using a variable for the argument).
That does reset when changing maps. I did a simple test and it does not reset when the game is loaded. -
Thank you so much, Turan!That does reset when changing maps.
Aaaaaah, no wonder the event did not respawn while I test played going from one map to the next.;_;
Edit: @Arthann, would not have thought to use game time. That's genius! Thank you!!! -
"Yes" to the second question. For the third question, that is an option, as long as you don't mind the timer pausing during battle and when the menu is open. However, with that method, the timer would lose a bit of accuracy every time the player changes maps, so I'd recommend using even smaller increments than seconds to minimize the accuracy loss.Code:
var min = 600; //10 minutes var max = 900; //15 minutes var frames = Math.random() * (max + 1 - min) + min; this.wait(frames * 60);
Hi guys. I have the above as a common parallel event. The goal is for the game to wait for 10-15 minutes before respawning an event.
Could you help me out please with these two questions:
- Does this wait get reset every time the game is loaded?
- What about every time a player transfers maps?
Personally, I'd probably save$gameSystem.playtime()to a variable as soon as the event despawns, and then periodically subtract that value from the current value of$gameSystem.playtime()to determine whether or not enough time has passed in order for the respawn to occur.
That way, there is no accuracy loss, and the time spent in battles and in the menu will count. Depending on exactly what you're trying to do, it also could enable you to bypass the need for a parallel common event, since you'd only really need to check the time when it's relevant to do so (i.e. once you're actually on the map where the event is supposed to respawn). -
I've been scouring for hours and can't find a way to actually remove the actor graphic from the cache to force an update. I'm trying to make a character customization plugin that saves to a character sheet, but I have to reboot the game to get the new graphic to load and that doesn't work for a character creator. I've tried clearing the cache, manually loading the bitmap, refreshing the actor, manually setting the image, using the image manager to load the url, everything I can think of. There's no reason the game shouldn't be able to reload one graphic after the initial load if I do something, given that it loaded it in the first place, but I don't know what that something is.
-
Starting from the simple - can you show us what your code looks like at this stage? It's not possible to trouble shoot something that no one has seen.
-
It's somewhat truncated because the statements reading pngs into an array or creating windows aren't relevant to the question and make the code a lot longer. This all works just how I want it except the refresh at the end where everything is commented out.
CodeJavaScript:/* @command specific * @text Open Character Creator For Actor * @desc Opens the character creator for a specific actor. * Enter the actor's ID. * @arg actor * @type number * @text Actor ID * @desc The ID of the actor you want to call. */ PluginManager.registerCommand(pluginName, "specific", args => { characterBeingEdited = args.actor; filename = $gameActors.actor(characterBeingEdited).characterName(); SceneManager.push(ShowCharacterCreator); }); //ShowCharacterCreator calls imageOverlay with an array of character parts pngs. async function imageOverlay(characterArray) { //Reading array of images to layer let imageOne = await Jimp.read(characterArray[1]); let imageTwo = await Jimp.read(characterArray[2]); let imageThree = await Jimp.read(characterArray[3]); let imageFour = await Jimp.read(characterArray[4]); let imageFive = await Jimp.read(characterArray[5]); //Reading base image const imageZero = await Jimp.read(characterArray[0]); //Layering the images using Jimp node library imageOne = await imageOne imageZero.composite(imageOne, 0, 0, { mode: Jimp.BLEND_SOURCE_OVER }) imageTwo = await imageTwo imageZero.composite(imageTwo, 0, 0, { mode: Jimp.BLEND_SOURCE_OVER }) imageThree = await imageThree imageZero.composite(imageThree, 0, 0, { mode: Jimp.BLEND_SOURCE_OVER }) imageFour = await imageFour imageZero.composite(imageFour, 0, 0, { mode: Jimp.BLEND_SOURCE_OVER }) imageFive = await imageFive imageZero.composite(imageFive, 0, 0, { mode: Jimp.BLEND_SOURCE_OVER }) //Write to actor's existing spritesheet in img/characters/ url = "img/characters/" + filename + ".png"; await imageZero.writeAsync(url); //Figure out how to refresh player character at runtime without closing out of the window //user = $gameActors.actor(characterBeingEdited); //user.setCharacterImage(filename, 0); //user.refresh(); //$gameParty.leader().setCharacterImage(filename,0); //$gamePlayer.refresh(); //ImageManager.clear(); //PIXI.utils.TextureCache = {}; //user.characterName = Bitmap.load(url); //???????? } -
Assuming you're using MZ, you can remove a specific character sheet from cache like this:I've been scouring for hours and can't find a way to actually remove the actor graphic from the cache to force an update. I'm trying to make a character customization plugin that saves to a character sheet, but I have to reboot the game to get the new graphic to load and that doesn't work for a character creator. I've tried clearing the cache, manually loading the bitmap, refreshing the actor, manually setting the image, using the image manager to load the url, everything I can think of. There's no reason the game shouldn't be able to reload one graphic after the initial load if I do something, given that it loaded it in the first place, but I don't know what that something is.
JavaScript:Just replaceconst cache = ImageManager._cache; const url = "img/characters/" + Utils.encodeURI("Butt") + ".png"; if (cache[url]) { cache[url].destroy(); delete cache[url]; }Butt(on the second line) with the actual filename of the character sheet. -
Unfortunately, that still didn't update the actor's graphic. I don't really understand why it won't, because it seems like it should, but the actor's graphic remains the cached one even after the cache is cleared, even if I set it to something else and refresh it before clearing the cache.Assuming you're using MZ, you can remove a specific character sheet from cache like this:
JavaScript:Just replaceconst cache = ImageManager._cache; const url = "img/characters/" + Utils.encodeURI("Butt") + ".png"; if (cache[url]) { cache[url].destroy(); delete cache[url]; }Butt(on the second line) with the actual filename of the character sheet.
EDIT: Solved the rest of the problem--I had a window that was loading the actor's sprite and I guess saved it for re-caching somehow because as soon as I commented out that particular line of code, it started updating just fine. Thanks for the help! -
A typo has crept into a note tag I'm using to add splash damage to all enemies.
The note tag reads:
Code:<JS Post-Damage> for (let i=0; i<target.friendsUnit().aliveMembers().length; i++) { if (target.friendsUnit().aliveMembers()[i]!=target) { target.friendsUnit().aliveMembers()[i].gainHp(0-Math.round(value/10)); target.friendsUnit().aliveMembers()[i].startDamagePopup(); } } </JS Post-Damage>
The console error message reads
The typo is in line 2 where it reads
i<target.friendsUnit()
That < is wrong, but I can't work out what it should be. Can anyone help me?
Thanks. -
@Kes Are you sure you haven't added any other notetags or code or plugins? Changed a plugin parameter?
I don't see anything wrong in that code. -
@ATT_Turan If I take that note tag out, I don't get the error message.
I haven't added or changed anything else (apart from a few tiles) between my last playtest and the one which gave this error message.
EDIT
Would this achieve the same thing?
Code:<JS Post-Damage> $gameTroop.aliveMembers().forEach(enemy => if (enemy!=target) enemy.gainHp(0-Math.round(value/10))) $gameTroop.aliveMembers().startDamagePopup(); </JS Post-Damage> -
@Kes No, that's not correct syntax. I'll put it this way - I can paste that code (plus a line above to define target and value) into the console of MZ and it executes perfectly.
Are there any other notetags on that skill? -
@ATT_Turan Yes there is, it is to give a different sound effect if the attack lands a critical
Code:<JS Post-Damage> { if (target.result().critical) AudioManager.playSe({ name: '101-Attack13', volume: 20, pitch: 100 }); else AudioManager.playSe({ name: 'Slash', volume: 20, pitch: 100 }); } </JS Post-Damage>
This tag has been in for quite a while without problems.
EDIT
In case it makes a difference, this one is first in the note box, with the splash damage one second. -
@Kes That's why - you can't duplicate notetags.
I would've expected it to simply not function, rather than to produce an error, but yeah. Unless a plugin is explicitly designed for it, and says you can, you can't put the same notetag onto a database entry more than once. You just need to put all of that code into one Post-Damage. (and I would take the first and last braces out of that, they're not doing anything) -
@ATT_Turan Huge thank you for your time and trouble in sorting out the problem. Much appreciated.