JavaScript questions that don't deserve their own thread

yaginku

Warper
Member
Joined
May 20, 2021
Messages
2
Reaction score
0
First Language
Polish
Primarily Uses
RMMV
This seems like an easy enough question, but I can't find a definitive answer. I want to expand the existing JSON data files with additional fields, to hold additional information about attacks, skills, states, etc., however they are being overwritten immediately on the next save.
I do have an idea about creating additional "extension" databases and merging them on load, but it seems like a lot of hassle for something so basic. I feel like there should be a simpler answer for what I'm looking for. My current use case is adding additional message fields to States, so every player character gets a different message when they're hit with the same effect.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,442
Reaction score
15,228
First Language
English
Primarily Uses
RMMV
@yaginku you cannot add new fields to the "database" files (the ones that exist in the data folder already and that use the $data... names in code) for the very reason you have discovered.

If you want to add new stuff that gets created as the game is played, put it in the $game... objects instead.

If you want to create your own data that is unrelated to the data files, you'll need to create your own $data... objects and a corresponding json file that gets set up outside of the engine/editor, and you'll need to update the new game, load game and save game functions to include these.

If you want to add new data to the existing structures, like actors, classes, states, just use the note box for it, and make your plugin read the notes like many others do. Some databases, such as Tilesets, Animations and Systems, don't have note boxes though so you'll need to go with the previous method.


My current use case is adding additional message fields to States, so every player character gets a different message when they're hit with the same effect.
For this, I'd use either the Actor note box, or the States note box.
 

WaCrex

Villager
Member
Joined
Apr 28, 2020
Messages
6
Reaction score
1
First Language
Swedish
Primarily Uses
RMMV
This seems like an easy enough question, but I can't find a definitive answer. I want to expand the existing JSON data files with additional fields, to hold additional information about attacks, skills, states, etc., however they are being overwritten immediately on the next save.
I do have an idea about creating additional "extension" databases and merging them on load, but it seems like a lot of hassle for something so basic. I feel like there should be a simpler answer for what I'm looking for. My current use case is adding additional message fields to States, so every player character gets a different message when they're hit with the same effect.
Why not store it in a separate JSON file? you could have done something like:
JSON:
{
    "MAP001": {
      
    },
    "MAP002": {
      
    },
    "MAP003": {
      
    },
    ...
}
Simply store any plugin specific data between the brackets. As for the name of the JSON file, just give it the same name as the plugin to make it easier to identify.

Edit: Ah yes, you could probably also use notetags as well like yanfly.. I guess.
 

yaginku

Warper
Member
Joined
May 20, 2021
Messages
2
Reaction score
0
First Language
Polish
Primarily Uses
RMMV
If you want to add new data to the existing structures, like actors, classes, states, just use the note box for it, and make your plugin read the notes like many others do. Some databases, such as Tilesets, Animations and Systems, don't have note boxes though so you'll need to go with the previous method.
Okay, I've peeked at a different plugin and noticed the "meta" field. Thanks!
Why not store it in a separate JSON file?
I wanted to make a separate JSON file and then either reach into it and correlate data by ID, or merge both JSONs on load, but it seemed like a lot of work. I might still go for it and the project progresses, but for now the Notes box is sufficient.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,442
Reaction score
15,228
First Language
English
Primarily Uses
RMMV
I wanted to make a separate JSON file and then either reach into it and correlate data by ID, or merge both JSONs on load, but it seemed like a lot of work.
It really isn't much work. Just a few additions to the DataManager class.
 

Restart

Veteran
Veteran
Joined
Mar 15, 2019
Messages
848
Reaction score
707
First Language
English
Primarily Uses
RMMV
Is there any way to get the duration of an animation based on its ID in $dataAnimations using RMMZ?

In RMMV it was as simple as $dataAnimations[animationId].frames.length, but the information isn't as obvious in MZ.
 

WingedHares

Veteran
Veteran
Joined
Apr 19, 2021
Messages
46
Reaction score
123
First Language
Indo/Not Fluent
Primarily Uses
RMMZ
Hey, guys, I think this question goes here? Since it's just a yes or no question. I'm sorry if it's wrong in advance x'D

Anyways, I'm wondering if it's possible to make a plugin that allows the full use of non-pixelated tilesets? Not parallex mapping, but actual non-pixelated tilesets.

My main issue lies with the autotiles' size. They shouldn't be changed for it to work, yeah? So I thought if someone make a plugin that allows for this size change, it could work.

I have a programmer to do it for me now, but I want to make extra sure before asking them. They're quite new, after all. Gotta save them the headaches.

I'm still quite unsure whether I want to go with it too. Pixel art is charming and all. But yeah, knowing my options doesn't hurt.

Thank you : D
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,886
Reaction score
981
First Language
English
Primarily Uses
RMMV
There are already plugins (at least for MV, I don't follow MZ) that allow you to use different dimensions for your map tiles in the game.

It's a bit of work for you, because the editor can't be changed, so you need to have one version of every tileset at 48x48 to work with in the editor, then a second one at whatever dimensions you choose for display in the game, but it works.

You should Google it up and see if it works in MZ or has an equivalent before paying someone to code for you.
 

WingedHares

Veteran
Veteran
Joined
Apr 19, 2021
Messages
46
Reaction score
123
First Language
Indo/Not Fluent
Primarily Uses
RMMZ
There are already plugins (at least for MV, I don't follow MZ) that allow you to use different dimensions for your map tiles in the game.

It's a bit of work for you, because the editor can't be changed, so you need to have one version of every tileset at 48x48 to work with in the editor, then a second one at whatever dimensions you choose for display in the game, but it works.

You should Google it up and see if it works in MZ or has an equivalent before paying someone to code for you.
I see! Thank you. Good to know :D

Decided to go with pixels after all. But I'll keep it in mind for future reference ^w^)b
 

Rhino2691

Warper
Member
Joined
May 17, 2021
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Hello all, is there a way to seal skills pending on the type of weapon a character is wielding? I tried to use the conditional branches using all the axes to only have ax skills and want to have the swords being able to use only sword skills and so on. However when I play the game to test it, all the skills that are available at the character's level are visible. Any tips or tricks or pointing me into the right direction would be awesome. I also have no idea how to write a script.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,886
Reaction score
981
First Language
English
Primarily Uses
RMMV
Hello all, is there a way to seal skills pending on the type of weapon a character is wielding?
Are you posting in the correct thread? This is for JavaScript questions, but your profile says you use VX Ace, which is Ruby-based.

Regardless, this is built into the engine - when you're looking at a Skill in the database, on the bottom of the screen there are two drop-down boxes labeled "Required Weapon" - if a character is not wielding one of those weapon types, they can't select the skill to use.

If that's not what you mean, you should start a separate thread with more details.
 

binogamer

Warper
Member
Joined
Aug 28, 2015
Messages
2
Reaction score
0
First Language
Portugese
Primarily Uses
Hello i wanted to ask if its possible to detect if the user closes the game (by closing the exe etc), i tried the method onbeforeunload but it didnt work,
JavaScript:
window.addEventListener('beforeunload', function (e) {
  // Cancel the event
  e.preventDefault(); // If you prevent default behavior in Mozilla Firefox prompt will always be shown
  // Chrome requires returnValue to be set
  e.returnValue = '';
});

I am guessing the function dont works because its made for browsers and not exe but i dont really know if thats the case.

This is for security reasons i am developing a multiplayer mode and i want my database to know that the user is no more logged in (and for other values) via an ajax call, its all good if the user uses the logout function i created however i need to proof test in case the user uses other methods to exit the game. If there isnt i guess i must create an event in the mysql databse or some other method.

EDIT

Ok i think i understand the problem now, the unbeforeunload is not getting trigered because the exiting by the exe dont runs a simple window.close, if i do a window close mannualy the pop up appears, so i need to investigate further to see how the exe works.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,886
Reaction score
981
First Language
English
Primarily Uses
RMMV
What you're asking goes beyond simple JavaScript, because clicking the X to close a window is a Windows process external to the game.

Here's the information on how Windows does what you're asking about, you'd have to see if there's some way you can tie this into your game. It might be easier to just manage it on the server side via polling.
 

ScorchedGround

Blizzards most disappointed fan (More than ever)
Veteran
Joined
Apr 12, 2020
Messages
632
Reaction score
848
First Language
German
Primarily Uses
RMMV
Quick question concerning constructing condition statements:

Is there a difference between


if (value > 0 && target.isActor() && user.isEnemy() || user.isActor() && target.isEnemy()) {
...
}

AND

if (value > 0 && (target.isActor() && user.isEnemy()) || (user.isActor() && target.isEnemy())) {
...
}

AND

if (value > 0 && ((target.isActor() && user.isEnemy()) || (user.isActor() && target.isEnemy()))) {
...
}

Basically, do brackets inside a condition statement have an effect on how they are evaluated?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,886
Reaction score
981
First Language
English
Primarily Uses
RMMV
Quick question concerning constructing condition statements:
The word you're looking for is parentheses. Brackets are [] and {} are braces. Also, as a tip for next time, I had no idea what you were asking about until I hit Reply, because the yellow color you chose for the extra parentheses doesn't show up against the light background of the forum - bolding or italicizing would've been better :wink:

The answer to your question is yes. The order of boolean operations functions identically to that in math. The order is NOT -> AND -> OR. Just as in mathematical operations, you can force an operation to have priority by putting it inside parentheses.

So:
Code:
if (a || b && c)
Will only be true if a is true, or if both b and c are true. Whereas:
Code:
if ((a || b) && c)
Will only be true if c is true, and also either of a or b.
 

ScorchedGround

Blizzards most disappointed fan (More than ever)
Veteran
Joined
Apr 12, 2020
Messages
632
Reaction score
848
First Language
German
Primarily Uses
RMMV
Also, as a tip for next time, I had no idea what you were asking about until I hit Reply, because the yellow color you chose for the extra parentheses doesn't show up against the light background of the forum - bolding or italicizing would've been better
Ah sorry, I wasn't aware that the yellow would be hard to read on light mode.
I never touch light mode so I didn't think it would be that bad. As for the parentheses, I was actually quickly looking up the word beforehand, but for some reason I was told that it is brackets.

I guess the symbol has different names when used in normal writing or in coding.


But thank you for clearing up my question. I already suspected this would work like that (because why shouldn't it) but I just wanted to make sure. :smile:

This will make creating intelligent conditions a lot easier.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,886
Reaction score
981
First Language
English
Primarily Uses
RMMV
I guess the symbol has different names when used in normal writing or in coding.
Not if it's used correctly - all three of those sets of symbols are used in coding, and they all mean different things, so calling them brackets is just incorrect. For example:
Parentheses are used to pass arguments to a function.
Brackets are used to reference the index of an array.
Braces are used to delineate the contents of a function or conditional section.

None of those things will work correctly if you use a different one of the symbols, so having the three separate names is necessary.

Edit: Note that these names are not referenced very often in regular English usage, so there are probably many people who just don't know the correct terms. Even coders, if they didn't have a careful teacher or use an accurate textbook, might never have learned the right words for the symbols they're typing.
 
Last edited:

epson777341

Veteran
Veteran
Joined
Oct 10, 2014
Messages
44
Reaction score
2
First Language
English
Primarily Uses
For RPG Maker MV.
Apologies if this has been asked before. Does anyone know how to change the Actor Positions via a script call with Yanfly's Battle Core? I can do it in the javascript editor, but not in-game. There's a lot of empty space that I'd rather spread my guys out a bit if there's a free slot.

In the Editor it's referred to as "Home Position X" and "Home Position Y" if that helps.
 

Nerine

Veteran
Veteran
Joined
Oct 3, 2020
Messages
104
Reaction score
60
First Language
Polish
Primarily Uses
RMMZ
How should I check if transfer player event is transferring player to the same map or different map. Cause I don't want some stuff to run when the transfer is occurring when player is just transferring across the same map?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,886
Reaction score
981
First Language
English
Primarily Uses
RMMV
For RPG Maker MV.
Apologies if this has been asked before. Does anyone know how to change the Actor Positions via a script call with Yanfly's Battle Core? I can do it in the javascript editor, but not in-game. There's a lot of empty space that I'd rather spread my guys out a bit if there's a free slot.
You shouldn't have to do script calls during the game, you should be able to make the Home X and Home Y plugin parameters account for this if you take into account $gameParty.battleMembers().length in the calculations.
How should I check if transfer player event is transferring player to the same map or different map. Cause I don't want some stuff to run when the transfer is occurring when player is just transferring across the same map?
This isn't a JavaScript question, as it can be done via event commands (Control Variable -> Game Data -> Map ID, do one before and after the transfer, then do a conditional check to see if they're the same).

But what are the circumstances? You create the Transfer Player events, so how would you not know if it's going to the same map or not?
 

Latest Threads

Latest Posts

Latest Profile Posts

Sweet nostalgia. My fave Final Fantasy game.
Steam page is now live!
1632768058957.png
just discovered thig game called Willowbrooke Post... beautiful artstyle if I do say so myself... does anyone know what this kind of style is called??
In one of my game projects, I am working on an arena where you can fight combatants or bet on monsters, and, man, it is taking so long, lmao. I do not think that it helps that I am using an evented combat system with a lot of things that I have to edit.
Time to take a little break from the project to work on another for Skyrim. Shouldn't take too long, as it's just fulfilling an easy to do request(more than likely I'll get beaten to the punch but...) this also gives me an excuse to play Skyrim again LOL.

Forum statistics

Threads
115,422
Messages
1,089,732
Members
150,169
Latest member
switchstone
Top