dakavid
Sep 10 2010, 11:45 PM
Hello, all! I'm looking to further my knowledge of the RPG XP system, which is by far my favorite. Does anyone know if it's possible to store a string (like the name of a town for instance) to a variable and then recall it later in a Message window in-game? The only way I've been able to figure to do that so far is to put town names in for "hero names" in the database and then call on the hero name in place of the town, which is a work-around for now. Is there another way that I'm missing? I'd like to branch out and do a lot more with this if there is.
Knot
Sep 11 2010, 12:20 AM
Welcome to the community! What you can do is use the "Script" command, the last one in the lists of events, maybe at the beggining of your game.
Enter this bit of code:
$game_variables[1] = 'blabla'
This will save 'blabla' to one of the normal variables, in this case number 1. You can then access that variable in the text box using \v[1]. Of course you can then also use 2,3,4 etc...
Just remember, the quotation marks are just there to identify it as a string and won't actually appear ingame.
Hope that works.
Zeriab
Sep 11 2010, 02:44 AM
Remember that using the variables containing strings for other than display in messages can easily lead to errors.
*hugs*
dakavid
Sep 11 2010, 07:06 AM
Oh, terrific guys! That looks really simple and makes a lot of sense. I'll be playing around a lot with that today and I'll let you know how I come out with it. Y'all are the greatest!
*hugs for Zeriab, too. hehe*
dakavid
Sep 11 2010, 07:45 AM
Hey, all right! That worked terrifically and was much easier than I'd thought it could be. This opens up all kinds of possibilities. I didn't know about the \v[#] command, I only knew the \n#] one. Are there other sage words of wisdom regarding the availability of such commands? Is it possible to join two strings together to form one composite string? (This one seems a certainty to me, I've been trying to study over the Ruby language and it seems it would just be telling it to add the two variables together and assign them to another. That can't be too left-field to be wrong right? hehe)
brewmeister
Sep 11 2010, 09:17 AM
example:
$game_variables[1] = 'this is '
$game_variables[2] = 'a string.'
$game_variables[3] = \
$game_variables[1] + \
$game_variables[2]
notice the '\' characters. the last 3 lines here are one single statement.
The Script Command editor has limited room & will mangle long lines.
dakavid
Sep 11 2010, 10:49 AM
Ah, terrific, Brewmeister, thanks! That worked out great, though it took a little playing around with it, because I started off in the not-simplest way and tried to combine three strings together with:
$game_variables[4] = \
$game_variables[1] + \
$game_variables[2] + \
$game_variables[3]
I had some application-closing errors come up that made me think it was the three-part combining that was causing them however and I've been pouring over what-went-wrong ever since, hehe.
My goal with this part is to make a random name generator. My game has randomly generated hirelings that can join you quite frequently, and to keep it from always just being "Hireling # 2 attacks", I'm having my events generate random appearances and names (random appearances are working, just working on this naming thing now). To make random fantasy names, I'm having an event draw on 2-4 or 2-5 syllables (depending on what seems to work best) and combine them together to form a composite name that is, hopefully, unique and distinctive.
You guys are a wealth of good information and friendly help! I'm really glad to be dipping my feet into the community finally, I've been working at this so long on my own and with just trying to read through things here for good ideas.
dakavid
Sep 11 2010, 10:03 PM
All right, I've been battling all day trying to find out why I'm getting random-seeming crash errors occasionally while trying to work with this string niceness. Unbelievably I sorted it down to the lower case letter j of all things. Any string that has j by itself, or j anywhere in it at all causes the application to crash-close when it tries to resolve the script. This is really strange to me. It does capital J well enough, and all the other letters of the English alphabet. Any thoughts to this?
j ......!! *boggle* why?! heh...
Please don't double post, wait 36 hours before bumping a topic. ~ Regashi
Knot
Sep 11 2010, 11:25 PM
I don't think there should be anything wrong with j O.o
Are you using any custom scripts?
Also why don't you post an example of exactly what you type in when you're having this problem. I mean, j works fine for me.
dakavid
Sep 11 2010, 11:59 PM
Certainly, Knot. Here we go:
No custom scripts aside from the ones I'm writing with here. I've erased out everything I've done until I have only the following line of Call Script written into an event:
$game_variables[950] = 'j'
Then I have a Message that reads simply: \v[950]
An F2 preview of it shows a 0 as expected when I'm in the editor.
In a Test Play it doesn't crash until it gets to displaying the message.
I have a 1000 variable array set up at the moment. Here's the weirdness: if I replace that j with any other letter or any word at all that doesn't have a lower case j in it, it works just fine as I was hoping for it to. In the end, I'm sure I can work around it. It'd just look funny if I tried to write in a capital J (BenJamin).
If your best estimate is that it's a strange bug, I'll be able to make do and console myself that it's possible that I'm not doing anything to cause it directly. Much appreciation for the insight once again!
Knot
Sep 12 2010, 12:23 AM
Well, it seems completely random to me. j gets along fine in my games
Why don't you try starting a new game and see if you get the same problem. If it works, you can then copy all your maps over.
dakavid
Sep 12 2010, 08:45 PM
Okies, there's just one last piece of this puzzle to make it all come together for me in this name generator. I've been attempting to find a way to take my newly-created string variables and assign them to the name variables for the heroes. I tried looking through the script to find the exact name of what I'm assigning, but I'm quite a bit uncertain of which one it is.
$mystery_hero_name_variables[1] = $game_variables[1]
is what I assume the syntax on that would look like to move my randomly pieced-together string from $game_variables[1] to whatever the name of the hero variables are.
Thanks again, you guys are terrific to post help on this. I'll be happy to share anything I learn in all this to anyone interested in doing a similar task or in anything at all that I have knowledge in!
watermelon_1234
Sep 12 2010, 09:25 PM
I think you want $game_actors[1].name.
It might be helpful for you to look at
Script References or
this when you want a more general view of the syntax.
Lethal Visions
Sep 13 2010, 04:50 AM
Well, don't know if it's been covered, but well, as far as actors go, you can have as many as you want...
You can create your town names and store them as say Actors 50-80 or however many you need for your places.Then when you need to use the messenger, you can easily have it say the actor's name in the message?
You can also develop a simple Common Event that does a conditional branch to determine what map you're in, and if its map 30 called Port Heart, you have it say that Actor's Name = "Port Heart"
All without scripting at all....
dakavid
Sep 13 2010, 09:28 PM
Ah, yep. That's roughly what I was trying to do before. I wasn't sure how much would be required from scripting when I started out here, but with everyone's guidance thus far it's turned out to be easier than I imagined. The advice from all and the syntax chart link from watermelon_1234 pointed me to exactly what I've needed. With luck and some work I'll have a fully functioning hireling generator by the end of the week: one that draws from a random sprite/battler, assigns a random class, equips them and comes up with a random name pieced together from drawn syllables so that you rarely could get the same minion twice, hehe. Small ambitions, mine, but steady nonetheless.
brewmeister
Sep 16 2010, 12:33 PM
letter 'j' problem...
If you're using an illegal version of RMXP, it's a bug. Deal with it.
If you using the legal version 101, upgrade to 102. (patch is on the Enterbrain site)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.