LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
Something I've been wondering, is there any built-in way to set wait times when displaying things like variables and actor names in the message editor? So, for example, you can type in \. to wait 1/4 of a second, or \| to wait a full second, but because \v[x] and \n[x] themselves are their own functions, there doesn't seem to be any way to call that wait when drawing the desired text.

Since I'm not seeing a function for such a thing listed when hovering over the message box, I'm assuming I would need to call a script to manually change how often a character is drawn into messages. Would I need a fully custom script to handle something like that, or is there a script call that's just a few lines at most that would work?
 

LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
No, I know that the wait commands are there, but I mean that there's no way to call the wait commands while displaying a variable or actor name.

So like, if I have an actor in the first slot in the database named 'Hero', and I want the player to be able to change the character's name to whatever they want, I can use \n[1] so that it will always display whatever the player changes the name to. But, let's say for stylistic purposes, I want to slowly draw out that actor's name. As far as I can tell, there's no way to call a wait command in the middle of the \n[x] function.

I'm basically trying to get the effect of saying "H\.e\.r\.o\.", but dependent on what name the player is using.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,802
Reaction score
5,642
First Language
English
Primarily Uses
RMMZ
No, I know that the wait commands are there, but I mean that there's no way to call the wait commands while displaying a variable or actor name.

So like, if I have an actor in the first slot in the database named 'Hero', and I want the player to be able to change the character's name to whatever they want, I can use \n[1] so that it will always display whatever the player changes the name to. But, let's say for stylistic purposes, I want to slowly draw out that actor's name. As far as I can tell, there's no way to call a wait command in the middle of the \n[x] function.

I'm basically trying to get the effect of saying "H\.e\.r\.o\.", but dependent on what name the player is using.
Ah, I see what you mean. You'd have to do this with a script call and use $game_message.add instead of the show text command, so that you could get the name property and insert wait codes in between each letter of the string.
 

LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
Ah, I see what you mean. You'd have to do this with a script call and use $game_message.add instead of the show text command, so that you could get the name property and insert wait codes in between each letter of the string.
Yeah, I figured something like that was the case. I'm guessing in order to get each letter of a custom string, I'd need to assign each letter to a variable, or something? Or am I overthinking this way too much?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,802
Reaction score
5,642
First Language
English
Primarily Uses
RMMZ
Yeah, I figured something like that was the case. I'm guessing in order to get each letter of a custom string, I'd need to assign each letter to a variable, or something? Or am I overthinking this way too much?
I would just use .split('') to convert the name into an array and then iterate through it, inserting a wait code between each element, then replace the name in the original text with that.
 

LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
I would just use .split('') to convert the name into an array and then iterate through it, inserting a wait code between each element, then replace the name in the original text with that.
Got it! So I'm assuming the .split('') is put at the end of $game_actors[x].name?
 

LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
So, if I'm understanding this right, the script for doing this would be something like,

Code:
$game_actors[1].name.split('string')
$game_message.add(string[1] + wait(15) + string[2] + wait(15)..)

And so on?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,802
Reaction score
5,642
First Language
English
Primarily Uses
RMMZ
Not quite. Look at the insert_at method, and you want to insert the actual character used to tell the engine it needs to do a wait, rather than the method itself. Then once you've inserted those into the array, you convert it back to a string and then interpolate it into your message.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,953
Reaction score
2,016
First Language
Spanish
Primarily Uses
RMVXA
Code:
$game_actors[var].name.split('').collect{|c| c.concat("\.")}.inject{|c,r| c+r}

returns "N\.a\.m\.e\."

there might also be a solution using sprintf, or regexp.
 

LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
Not quite. Look at the insert_at method, and you want to insert the actual character used to tell the engine it needs to do a wait, rather than the method itself. Then once you've inserted those into the array, you convert it back to a string and then interpolate it into your message.
I'm afraid I don't quite follow. Where do I use the insert_at method? I've only ever worked with the absolute bare basics when it comes to scripting in Ruby, so more complex things like setting up and using arrays are a bit beyond my current grasp.
Code:
$game_actors[var].name.split('').collect{|c| c.concat("\.")}.inject{|c,r| c+r}

returns "N\.a\.m\.e\."

there might also be a solution using sprintf, or regexp.
How are you getting it to return that? Do I call that line of code, and then use the \n[1] function in the message box?
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,953
Reaction score
2,016
First Language
Spanish
Primarily Uses
RMVXA
How are you getting it to return that? Do I call that line of code, and then use the \n[1] function in the message box?

I don't know what you're using to drive your action.
that line takes the name of the actor, and inserts \. in between.
that's why I say there might be other solutions for the same problem.
 

LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
I don't know what you're using to drive your action.
that line takes the name of the actor, and inserts \. in between.
that's why I say there might be other solutions for the same problem.
Okay, I think I've figured it out! I tested out that line of code via $game_message.add --

Code:
$game_message.add($game_actors[var].name.split('').collect{|c| c.concat("\.")}.inject{|
c,r| c+r})

And it does display the actor's name, but instead of applying the \. wait command, it returns the actor's name with periods in between each letter, so instead of drawing 'Hero' slowly, it draws 'H.e.r.o.'

So, I decided to add another '\' to the c.concat("\.") part of the code, and that got it working properly! My problem now is that I'm not sure how to add in other commands into the rest of the text box.

For example, I'm trying to draw, "This is a test, Hero.", and it works fine when my code is this:

Code:
$game_message.add('"This is a test, ' + $game_actors[1].name.split('').collect{|c|
c.concat("\\.")}.inject{|c,r| c+r} + '."')

But trying to add a '\.' between each letter in the "This is a test, " segment causes a crash. I can put in about three '\.'s before it crashes with an error message about an "unexpected ')'". I'm noticing that when adding the wait commands, the script itself is being pushed repeatedly into new lines, as opposed to like how most notepad/document programs work by only pushing a new line when the current line gets full.

Could this be causing the engine to not read the script properly?
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,953
Reaction score
2,016
First Language
Spanish
Primarily Uses
RMVXA
it's the quotes.
I've never learned why ones are more correct than the other, but there's a type priority with them.
"" is not the same as ''
I suggest you put my code as a separate procedure somewhere else, and send *it* the name of the actor OR string in question, and obtain the cut string as a result.
that way you work with all strings within the game_message.add() call, and little to no actual code.
 

LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
it's the quotes.
I've never learned why ones are more correct than the other, but there's a type priority with them.
"" is not the same as ''
I suggest you put my code as a separate procedure somewhere else, and send *it* the name of the actor OR string in question, and obtain the cut string as a result.
that way you work with all strings within the game_message.add() call, and little to no actual code.
Ah, I knew about "" not being the same as '', but I didn't realize there was a priority to them. I always figured whichever came first in a line of code took priority. I typically use "" quotations in my games to denote someone speaking, so that may be a problem.

Regardless, thank you for your help! I was able to figure it out, I set your code to a local variable, and then just plugged that variable into the $game_message.add line. Now it's all reading as intended! The one problem I can see however, is that the variable name has to be relatively short, or else the code breaks again because it's too long to fit on one line.

It's so strange, why in the world does VX Ace's script command seem to not work like any other notepad program?
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,953
Reaction score
2,016
First Language
Spanish
Primarily Uses
RMVXA
The one problem I can see however, is that the variable name has to be relatively short, or else the code breaks again because it's too long to fit on one line.
Code:
@obj = $game_actors
@name = @obj[var].name
@strspl = @name.split('')
@strspl.collect{|c| ... } etc

section every half step to variables

Code:
var = $object.property.method()
module.method(var)
this works.

Code:
@var = $object.property.method()
module.method(@var)
this works.

Code:
@var = $object.property.method()
Code:
module.method(@var)
this works.

Code:
var = $object.property.method()
Code:
module.method(var)
this doesn't.
you can split a long chain in between separate blocks, but use @ variables to link them.

Code:
@obj = $game_actors; @name = @obj[var].name; @strspl = @name.split('');
$game_message.add(@strspl.collect{|c| c.concat("\\.") }.inject{|c,r| c+r});
two or three lines, depending on width.
classic ; separator.
 
Last edited:

LucaBicono

Veteran
Veteran
Joined
May 14, 2015
Messages
84
Reaction score
78
First Language
English
Primarily Uses
RMVXA
Code:
@obj = $game_actors
@name = @obj[var].name
@strspl = @name.split('')
@strspl.collect{|c| ... } etc

section every half step to variables

Code:
var = $object.property.method()
module.method(var)
this works.

Code:
@var = $object.property.method()
module.method(@var)
this works.

Code:
@var = $object.property.method()
Code:
module.method(@var)
this works.

Code:
var = $object.property.method()
Code:
module.method(var)
this doesn't.
you can split a long chain in between separate blocks, but use @ variables to link them.

Code:
@obj = $game_actors; @name = @obj[var].name; @strspl = @name.split('');
$game_message.add(@strspl.collect{|c| c.concat("\\.") }.inject{|c,r| c+r});
two or three lines, depending on width.
classic ; separator.
I did not know this, thank you!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,802
Reaction score
5,642
First Language
English
Primarily Uses
RMMZ
I did not know this, thank you!
The reason your original attempt resulted in dots was that \. was doing an *escaped full stop*. You needed two slashes to make the first slash a literal one.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,557
Reaction score
1,285
First Language
English
Primarily Uses
RMVXA
I've never learned why ones are more correct than the other, but there's a type priority with them.
"" is not the same as ''
From what I remember from my ruby course, you use single quotes to write string. You write double quotes when you are performing actions on the string or including functions in the string.
e.g. "#{variable} is displayed"
You can also include single quotes in double quotes but not the other way around.
There was a more technical explanation, but I forget.

Code:
var = $object.property.method()
module.method(var)
this works.
Code:
var = $object.property.method()
module.method(var)
this doesn't.
Are they not the exact same thing?
 

Latest Threads

Latest Posts

Latest Profile Posts

All the artists on here always share their art, and I wanted to partake in the sharing. I wanted to show off the album art for my game's soundtrack while also showing off this song. I wanted to take a break from all the pianos/strings/jazz. I experimented with some side-chaining techniques to modulate the dub-step like synth.
Crazy idea to help people be more productive. We all upload a photo of someone who is good at nagging, cajoling, guilting, etc. you into doing what you should be doing. Then, after you have posted X amount of times in a defined period, that photo pops up with the text of "Shouldn't you be working on your game?" Just for fun.:wink:
Avery wrote on MouseWorks's profile.
That is a really cute avatar concept that you have there! I like it :3
Well, here's a screenshot of just another game that might never be completed...

quicktrip_xp01.jpg

Forum statistics

Threads
128,509
Messages
1,195,116
Members
169,086
Latest member
wadasssjjwd
Top