Changing an event's note tag via JS

SarcasticSloth

Villager
Member
Joined
Jul 11, 2018
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hello!

I am currently creating a game using the Alpha ABS plugin. It is an awesome plugin. Enemies are created by giving an event a notetag. The number on the note tag responds to the enemy database and determines which kind of enemy it will be.

I am looking to find a way to change the note tag during the game. I know this is a bad idea in many cases, but I have reason to believe that it will work in my game without too many issues.

I am new to JavaScript, and what I have been trying to use is this:
$dataMap.events[n].note=<ABS:5>

However, it gives me an error message. Can someone please let me know the proper way to write this JS code?

Thank you in advance.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
what error? You probably have to put that in quotes. However, if by the time the event appears on the map, the notes have already been read and turned into metadata, and the plugin may already have done its processing as well. So apart from the fact that notes will be reset every time the map loads, the plugin may not detect your change anyway.
 

SarcasticSloth

Villager
Member
Joined
Jul 11, 2018
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
I have attached a picture of the error message.

Hmmm... well, if I can't change the note tag, then I can't do it. But it seemed like the best way to go about changing the enemies on my map. I understand what you are saying, though. Is there any way to change a note tag before the events load? I don't see how, but I figure it is worth asking.
 

Attachments

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
There is always a way, you just need to prepare yourself for sometimes small and sometimes huge changes of the default engine or even plugins.

For example you could have reworked the default DataManager.onload function that if there's certain mapID and a switch is active, you replace a certain part of _note via string.replace method.
For example:
Code:
DataManager.onLoad = function(object) {
    var array;
    if (object === $dataMap) {
        this.extractMetadata(object);
        array = object.events;
    } else {
        array = object;
    }
    if (Array.isArray(array)) {
        for (var i = 0; i < array.length; i++) {
            var data = array[i];
            if (data && data.note !== undefined) {
if ($dataMap._mapId == 5 && $gameSwitches.value(5)) data.note.replace ("ABS: 5", "ABS: 150");
                this.extractMetadata(data);
            }
        }
    }
    if (object === $dataSystem) {
        Decrypter.hasEncryptedImages = !!object.hasEncryptedImages;
        Decrypter.hasEncryptedAudio = !!object.hasEncryptedAudio;
        Scene_Boot.loadSystemImages();
    }
};
Of course if you have many possible changes like these, it would result in the game's loading getting slow due to many ifs. In that case it would probably be better to load all possible dataMaps beforehand and process this thing asynchronously, then just upon map change pass the dataMap that is needed. Or there are many other ways, I'm sure of that.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Or you could change the plugin to look for a comment on an event page rather than a note on the event itself, so you just need to change the conditions dictating which page is active.

That is a very strange error message, and likely has nothing to do with what you wrote (except that you need to use quotes after the = but that still won't do what you want it to do).

Can you play your game, hit F8 to open the dev tools, and then do what you did to generate the error? At that point it should give you the real error. Whenever you have an issue that's generated an error, always use F8 and go to the console and copy/paste or post a screenshot of the messages in the console. The ones that appear on the game screen, as in your screenshot above, are only of very limited use.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
@SarcasticSloth
This type of print screen you show seems to show that you have not learned the basic dev and also javascript to work effectively in rmmv.
I suggest you try to start working with the terminal and the chromium inspector.
The error you present has no logical and reel value, it does not allow the developers to help you sorry.

You issue are maybe more luck in a plugin issue than a js issue.
Show a reel log please if you need more help.

if you need help , please study how dev tool work to understand issue and show us.
https://developers.google.com/web/tools/chrome-devtools/

If you don't have access to dev tool at boot, you can use F8
 
Last edited:

SarcasticSloth

Villager
Member
Joined
Jul 11, 2018
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
Thanks everybody for the replies. No, I do not know JS, that is the biggest reason I was asking. However, the plugin I am working with was recently updated and it fixed the problem I was having. Thank you all for your kind replies though!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,074
Members
137,578
Latest member
JamesLightning
Top