Hello,
Is there a way to edit the character name through script? I'd like to recreate and old name changer from my game made with RM2K3 and I want to avoid heavy scripting/plugins.
I found that this script can change the name of the character #1 with the variable #4 value:
$gameActors.actor(1).setName($gameVariables.value(4));
But what if I wanted to remove the last character or ad a letter? I'm new to javascript and RMV , I tried many options but I have to figure out how RMV works to do that.
Any help? 🙂
string.length = string.length -1 should work for subtracting. At least this worked in python.
If this doesn't work, then perhaps string -= string[-1].
Adding letters is same as everywere, string += letter you wanna add.
This isn't totally about figuring out how RMMV works though, but really basic javascript 😀
Thank you!
So the script would be something like this...?
$gameActors.actor(1).setName($gameVariables.string -= string[-1]);
I'm getting started with java so I don't have the right syntax figured out yet ^^
Anyway, whatever I try it says "string is not defined" 🙁
$gameActors.actor(1).setName($gameVariables.value(4) - $gameVariables.value(4)[-1])
in this particular case. Also, javascript, not java 🙂
Before you work on javascript, I suggest you learn it first a bit, it will be much easier.
Ah sorry! I copied the wrong code!
The $gameVariables.value(4) was just a placeholder for the code, its not useful for my purpose.
what I'm trying is something like:
$gameActors.actor(1).setName($gameActors.actor(1) -= string[-1]);
But I get error, I also noted that there is no string command in your code.
I've made up my mind to learn javascript, but I wanted to try some small thing right on the battlefield first 🙂
In this case $gameActors.actor(1).setName($gameActors.actor(1) - $gameActors.actor(1)[-1]) should do the trick.
That string change the name to Not a Number (NaN).
I'm an idiot 😀 Forgot completely to type in name.
$gameActors.actor(1).setName($gameActors.actor(1)._name - $gameActors.actor(1)._name[-1])
That's strange because I keep getting NaN :/
Can you confirm?
Ok, this time it will work!
The reason is, for some unknown reason javascript doesn't recognize [-1] as last and throws in undefined.
So now it will work.
$gameActors.actor(1).setName($gameActors.actor(1)._name - $gameActors.actor(1)._name[$gameActors.actor(1)._name.length -1])
Believe it or not, still getting NaN 🙁
Are you kidding me 😀
I know you aren't.
Alright, time for brute force.
$gameActors.actor(1).setName($gameActors.actor(1)._name.slice (0, $gameActors.actor(1)._namelength - 2))
If this doesn't work, I don't know what will.
Well, it doesn't give NaN anymore, but the hero name (wich is 4 letters btw) disappear completely.
Didn't immagined It could be so tricky @_@
Ok, then one question. What kind of a name are you using?
Character 0001 is named "Rain"
Jesus... I missed one dot and missed missing that dot!
$gameActors.actor(1).setName($gameActors.actor(1)._name.slice (0, $gameActors.actor(1)._name.length - 2))
Now the dot is there. Really sorry for that. It's these small mistakes that turn a 5 min job into 5 hour one though, I can guarantee that 😀
It works!! 😀
By this logic, wat's the script for adding a letter?
Adding letters uses normal addition.
I've made it!
it is $gameActors.actor(1)._name += "abc";
For further reference 🙂
Thank you!