Hi!
@ATT_Turan
That was my question - why do you say "need"? I understand how RPG Maker sets the variables internally; but I also understand that all JS comparison operators disregard type.
Ok, let me explain the things I thought when I first read the author's question. That is a little hard for me because all that happens so automatically in my mind and English is not my native language:
- I don't know if the author knows javascript. And if he knows, how much he knows? I don't know.
- He wants to extract something from the note tag. So it seems to me that he didn't know about the meta property.
- His note tag is probably a number because "Lvl" means level, so a number.
- He will put it inside a variable.
- He doesn't want to use a lot of conditional branches.
So what I need to do to help him, with only this information with a less margin of error possible?
So I say "need", because I try to follow this logic above, with the information that I had and presume, about the post.
a certain difficulty level written in the note tags like this: <FishLvl: n>
He is putting that inside a variable. And I assume that "n" is a number.
That is the only thing I know.
I don't know exactly where he is using it or how he will use it. I don't have the exact reason. He will use the default maker comparison? He will use a js comparison, so "==" or "===" ? I don't know all the details. He will use that only on the conditional branches? Don't know.
All that I know is that he need to get the "n" of his note tag and that is probably a number(Because is a level).
If it is a number, for good practice, I do prefer to explicitly convert it.
So I explain to him that the meta property exists(because it seems to me he didn't know about it) and how it works, that by default all values of a meta are string.
So I follow the good practice to explicitly convert it as a number to avoid any misunderstanding or some future error, and I believe that's
one of the reasons "Good practices" exist, avoid common errors.
I will just tell you, as an example, three errors(
that comes to my mind, maybe there is more) or weird behaviors he can encounter if we do not explicitly convert it:
1 - Accessing an array index or object property:
Spoiler
<FishLvl: 3>
$dataItems[ID].meta.FishLvl => Will return " 3"
Let's say that we will access an array or object property with this value:
JavaScript:
let index = $dataItems[ID].meta.FishLvl
let names = ["Harold", "Therese", "Marsha", "Claude"]
let selectedName = names[index] => will return undefined
Because of the blank space " 3"
To avoid that, the author could make his note tags this way(without space):
<FishLvl:3>
So we can repeat the process above and will not throw undefined.
But if the author, sometimes adds the space and sometimes not(
I think these things, because when I make plugins for other people to use, I had to think it that way)?
He could have this note tag on item id 5(Without space): <FishLvl:3>
And on item id 8(With space): <FishLvl: 3>
And during his development, depending on how he uses it, he could get into this error and not understand why, since both note tags seem the same.
When converting it to a number, it will remove the blank space. And the author will not need to worry about it.
2 - Extra blank space on message window:
Spoiler
Let us say that he is storing the property of meta inside a variable id 5, to show it as a text on the message window.
The fish level is: \v[5]
Again, because of blank space already on the meta property, he can get a message like this:
The fish level is: 3
instead of this:
The fish level is: 3
Why I have a double space if I only put one space after the ":" ?
3 - Using a number method on a string can give him an error:
Anyway, little things, that can bother some people a lot(By the way, If you read again the author post specifying the note tag, you will see that he add the blank space).
So in the end, I'm not following the reason why you are asking.
Are you in doubt about something? Or you are just trying to say that there is no reason for the author to do the things the way I tell him to do(Which is totally fine, no problem)?
And I also believe we can go off-topic here with this discussion, since the author already said that the solution worked, we can just move on.