JavaScript questions that don't deserve their own thread

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
23,084
Reaction score
12,642
First Language
English
Primarily Uses
RMMZ
If not, do some error-checking on the value stored in variable 13
This seems to be the issue.
I had the sprite face left (direction 4) before using the item which effects the transfer. The variable is set on the transfer in to the map. However, when I opened F9 on that map to see what value it had, it had 6 (direction right) which is what is then applied for the transfer back.

Variable (13) is only ever used for this set of commands. It is in use nowhere else, so I'm at a loss as to where that 6 has come from.

EDIT
I tried setting v(13) to zero before setting all the variables for the transfer. After the transfer in F9 still showed 6.
The game's Search function shows that this variable is used nowhere else, so it's not carrying forward a value from elsewhere.
I tried changing the variable to v(301) in case somehow (13) was in use in a plugin. Made no difference, still set to 6 (right)

I suspect this is now not a JS question.
 
Last edited:

Manjini

Dummy
Veteran
Joined
Jan 6, 2019
Messages
39
Reaction score
31
First Language
German
Primarily Uses
RMMV
Hello all! I hope I can find some help for my issue. I would like to make a script in which there is a quick check if the player character is X Tiles / Steps away from a certain Region tile specified, similar to a check in which the player is X Tiles / Steps away from an event.

What I got so far and what it does:

if($gameMap.regionId($gamePlayer.x, $gamePlayer.y) < 105)
{
DO SOMETHING HERE LIKE SHOW A MESSAGE OR WHATEVER ELSE.
}
else if($gameMap.regionId($gamePlayer.x, $gamePlayer.y) >= 105)
{
DO NOTHING HERE OR MAYBE BLOCK MOVEMENT OR DISABLE SOMETHING
}

If the player x and y coordinates are on any region below 105 it is supposed to allow whatever action

''Else if'' works ONLY IF the player steps on any Region tile with the number 105 or above. However I want something where the script (or coordinates) easily check if the Player is 1 or more Tiles / Steps away from specified Regions in both x and y directions as well as diagonal if possible!

So why I wish to do this? To have more freedom with certain Skills I do for my game using Chrono Engine.

It also would come in handy making a Skill in which you use the ''through'' option where the player can walk through everything. So to prevent the player walking through specified Regions, I need this check before the player is actually on top of that Region already!

I hope my English isn't too terrible! Anyways thanks in advance.

EDIT: Made my own thread for this! Thanks for the help tho.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
I would like to make a script in which there is a quick check if the player character is X Tiles / Steps away from a certain Region tile specified
If you already know the coordinates of the tile you're checking, you can just use the distance() method:

If you're trying to do something like scan around the player to find the nearest instance of a given region ID, you'll have to write a function for that. If that's what you want but you don't know how to do that, you should start a new thread for assistance.
 

Terrannus

Warper
Member
Joined
Sep 30, 2022
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMMV
I don't really understand your description of what you're trying to do. Are you trying to edit images within RPG Maker?

If you're saying you've edited the image while the game is open and you want to refresh that...I'm not super knowledgeable about how the caching system works, but you could try changing the bitmap using the same filename to reload it. But I suspect there are better ways to go about whatever it is (like using a screenshot for the game as a lower layer in your image editor).


Thanks for getting back to me! Yeah that's pretty much it. I'm using a plugin to edit the bitmap I take from a file and am trying to work with just that bitmap so I can still reference the original file I need later untouched.

I can add the new bitmap to a Sprite_Picture but I haven't found any way of actually adding it to a Game_Picture which is what has the functionality I need
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
Thanks for getting back to me! Yeah that's pretty much it. I'm using a plugin to edit the bitmap I take from a file and am trying to work with just that bitmap so I can still reference the original file I need later untouched.

I can add the new bitmap to a Sprite_Picture but I haven't found any way of actually adding it to a Game_Picture which is what has the functionality I need
I think you should start your own thread, this solution is going to be more complex than a single function call.

Good luck!
 

FrozenFacade

Veteran
Veteran
Joined
May 24, 2020
Messages
30
Reaction score
9
First Language
English
Primarily Uses
RMMV
I found a thread describing the script in VX for offset animation but I can't seem to find a script to do that in MV, anyone know what it is?

Untitled.png

^ This but for MV.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
I found a thread describing the script in VX for offset animation but I can't seem to find a script to do that in MV, anyone know what it is?

View attachment 242003

^ This but for MV.
That isn't a default VX function. It's a script Shaz wrote, and you'll find the entirety of it in the Spoiler tags in that post. The bit you quoted does nothing by itself, and as it didn't come with VX there's also no MV equivalent.

You should make a post in Plugin Requests with more detail on how you want this to work and see if anyone can suggest an existing plugin or write a quick one for you.
 

FrozenFacade

Veteran
Veteran
Joined
May 24, 2020
Messages
30
Reaction score
9
First Language
English
Primarily Uses
RMMV
That isn't a default VX function. It's a script Shaz wrote, and you'll find the entirety of it in the Spoiler tags in that post. The bit you quoted does nothing by itself, and as it didn't come with VX there's also no MV equivalent.

You should make a post in Plugin Requests with more detail on how you want this to work and see if anyone can suggest an existing plugin or write a quick one for you.
Thanks, yeah I saw the rest of it and just posted that bit to not fill up my post with an entire other post.
 

Zakko

Villager
Member
Joined
Aug 19, 2022
Messages
11
Reaction score
8
First Language
Danish
Primarily Uses
RMMZ
Hello!

Writing a little plugin that is by no means good code haha, but just wanted a little help.

I've created window that makes use of Scene_MenuBase and that's all find and dandy as it works just great, but does anyone know how to disable the blur & darken effect that happens when you push the scene? The same effect that happens when you open the default menu, just to be clear.

I mean specifically remove it for the custom scene/window I've made, without touching or changing anything else (like disabling the effect for everything, which I don't want).

RMMZ 1.5.0
 

jkweath

Goes Fast
Veteran
Joined
Sep 21, 2016
Messages
439
Reaction score
644
First Language
English
Primarily Uses
RMMV
I have a dumb JS question - it involves a custom plugin I wrote for MZ, but I'm not sure it deserves its own thread.

Basically I have a small script that modifies the menu to show an actor and an objective, sort of like a dialogue box in the menu:

1665837507590.png

It's a bit janky (the "objective" is reading off an item description set by a variable), but it works. Except for when the game first loads, or upon entering a new map...
1665837492100.png

The face won't load. It will load normally after the 2nd time opening the menu, but never the first time.

I've tried using this code before the menu opens:

Code:
ImageManager.loadFace('faces');

But it doesn't help. I've had this issue persist across multiple games using the same script and I've never been able to figure out how to make the faces load properly.

Is there a line of code that'll solve the problem, or something deeper I need to look into?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
I've had this issue persist across multiple games using the same script and I've never been able to figure out how to make the faces load properly.
Where's the actual code you have now for creating that objective window? I only see in-game screenshots.
 

jkweath

Goes Fast
Veteran
Joined
Sep 21, 2016
Messages
439
Reaction score
644
First Language
English
Primarily Uses
RMMV
Where's the actual code you have now for creating that objective window? I only see in-game screenshots.
Here's the block of code that draws the face and text:

Code:
Window_Objective.prototype.refresh = function() {
    this.contents.clear();
    this.updateHelp();
    var x = this.itemPadding();
    var width = this.contents.width - this.itemPadding() * 2;
    var actor = $gameActors.actor($gameVariables.value(1));
    ImageManager.loadFace(actor.faceName());
    this.drawActorFace(actor, actor.faceIndex(), 0, 128, 128);
    this.changeTextColor(ColorManager.textColor(6));
    this.drawText(actor.name() + ":", this.itemPadding() + 150, 6, width);
    //this.drawText("Current Objective:", this.itemPadding() + 160, 0, width, 'left');
    this.resetTextColor();
    this.drawTextEx(this._text, this.itemPadding() + 150, this.lineHeight() + 6);
};
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
Here's the block of code that draws the face and text:
So you're misusing loadFace - you're just calling it, but that doesn't do anything. If you look at the function in the code, it returns the actual face image.

Additionally, it's not necessary there because - again, doing a search for it - it's already being called as a part of drawActorFace (it's how it gets the image to draw).

So that line isn't doing anything, and you definitely don't need to call it more times/in different places.

I think your problem is you're calling drawActorFace incorrectly. Looking it up in the code, the arguments it's expecting are "actor, x, y, width, height." Then, inside of it, it's referencing the actor.faceIndex().

But you're passing the faceIndex() as the x coordinate to draw it at - so I think it is trying to draw, but the x coordinate is, like, the top pixel of your screen where it doesn't fit and you can't see it.

Try changing that to a number near the bottom of your screen.
 

jkweath

Goes Fast
Veteran
Joined
Sep 21, 2016
Messages
439
Reaction score
644
First Language
English
Primarily Uses
RMMV
Yeah, I was fiddling around with that line and must've misread what's supposed to go there. I changed it back to the original:

Code:
this.drawActorFace(actor, 5, 0, 128, 128);

Still doesn't work. Just to clarify, upon opening the menu a second time in the same map, the face will load correctly and in the correct spot. It's only the first time that the face won't load.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
Still doesn't work.
You should probably start a thread about it. I remember a plugin that had similar issues and someone identified the fix, but I don't recall which plugin it was to look up the thread.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,432
Reaction score
5,119
First Language
English
Primarily Uses
RMMZ
Yeah, I was fiddling around with that line and must've misread what's supposed to go there. I changed it back to the original:

Code:
this.drawActorFace(actor, 5, 0, 128, 128);

Still doesn't work. Just to clarify, upon opening the menu a second time in the same map, the face will load correctly and in the correct spot. It's only the first time that the face won't load.
What class does Window_Objective use as its prototype? Because if it's not a Window_StatusBase, the face images won't be preloaded. If you look at the initialisation code for Window_StatusBase, it preloads party face graphics by calling ImageManager.loadFace for each member of the party, so that in status menus the faces will be visible immediately when you open them.

What you can do alternatively, though, is add a load listener to the graphic so that it only draws after it loads.

JavaScript:
const bmp = ImageManager.loadFace(actor.faceName());
bmp.addLoadListener(() => this.drawActorFace(actor, 5, 0, 128, 128));
 

jkweath

Goes Fast
Veteran
Joined
Sep 21, 2016
Messages
439
Reaction score
644
First Language
English
Primarily Uses
RMMV
What class does Window_Objective use as its prototype? Because if it's not a Window_StatusBase, the face images won't be preloaded. If you look at the initialisation code for Window_StatusBase, it preloads party face graphics by calling ImageManager.loadFace for each member of the party, so that in status menus the faces will be visible immediately when you open them.

What you can do alternatively, though, is add a load listener to the graphic so that it only draws after it loads.

JavaScript:
const bmp = ImageManager.loadFace(actor.faceName());
bmp.addLoadListener(() => this.drawActorFace(actor, 5, 0, 128, 128));
Thank you very much Trihan! This solved the problem, and I feel like I've learned a little more about how images load. :kaojoy:
 

Dustin2022

Warper
Member
Joined
Oct 16, 2022
Messages
2
Reaction score
0
First Language
German
Primarily Uses
RMMZ
Hello,
not sure if i'm in the right thread, but i have a little question.
i used this to my events (no trigger):


if $gameParty.lastItem().itemId() == 2
Control Variable 0003 xy = 1

but when i use the Item with ID 2 the Variable is sill on 0 (query about \V[1])
what am I doing wrong ?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
23,084
Reaction score
12,642
First Language
English
Primarily Uses
RMMZ
@Dustin2022 Never use the leading zeros with a switch number. It should be plain 3, not 0003.
Is this a one off or do you intend to increase the variable by one each time that item is used? At the moment you are setting it to one.

Try something like this
Code:
$gameVariables.setValue(3, 1)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,432
Reaction score
5,119
First Language
English
Primarily Uses
RMMZ
@Dustin2022 Never use the leading zeros with a switch number. It should be plain 3, not 0003.
Is this a one off or do you intend to increase the variable by one each time that item is used? At the moment you are setting it to one.

Try something like this
Code:
$gameVariables.setValue(3, 1)
I think he was copying from the event command list rather than doing it as a script. In the event itself it shows leading zeroes (which is usually why people get so confused about it when referencing them in code).

@Dustin2022 You say you're setting variable 3 but using \v[1] in your message, which would show the value of variable 1. Could that be why it's showing a 0?

What's your aim in setting variable 3 to the value 1 if the player used item 2 anyway?
 

Latest Threads

Latest Profile Posts

KDS
Hey guys! Iam currently updating my free digital art shop , let me know if you need anything done :) https://forums.rpgmakerweb.com/index.php?threads/kds-free-open-digital-art-shop.17097/
Hello! I’d like to ask where is a good place to start logging about my game dev progress as production of my game goes forth
In one of our campus classrooms was a bag full of stuff people forgot there... my bag. That I forgot there xD
You know your room is too tiny for how much stuff you have when it gives you literal insomnia. I just cleared a bunch of stuff out and man it feels good!
1670381555475.png
Meet the Kernel. You encounter him in cyberspace. He's important!

Forum statistics

Threads
127,098
Messages
1,183,965
Members
167,028
Latest member
Edujandro
Top