[script editing help] Namebox + Variable control

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
Script I'm trying to edit: https://github.com/theoallen/RGSS3/blob/master/Untranslated/Namebox Window.rb
(I'll translate the help text at the top of the script if needed, but the script is easy to use without it.)

Would it be possible to control a variables for multiple namebox text results inside of the script? Example:
Variable[n] = 1 If (namebox text displayed) == "Name1"
Variable[n] = 2 If (namebox text displayed) == "Name2" (etc)

For context, I'm currently using a variable that is associated to a text sound effect script. Different variable values give different sounds.
(The code I'm using for the text SFX is from Zerbu: https://www.rpgmakercentral.com/topic/607-text-sound-effect-updated/)
 
Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
[move]RGSSx Script Support[/move]
 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
Bump. Any help would be appreciated.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
You could try to replace this line:
Code:
MESSAGE_SOUND.play
With these:
Code:
if $game_variables[222].is_a?(Array)
  RPG::SE.new(*$game_variables[222]).play
else
  MESSAGE_SOUND.play
end
In that text sound effect script.
This will set the specified variable to be used if it's an array.
Feel free to change the variable ID, I used 222 because that was closest to my fingers. :p

You can setup the variable with this script call:
Code:
$game_variables[222] = ["filename",volume,pitch]
Replace the stuff between the square brackets with your sound effect data.
Do this right before you want to show these message boxes, and the sound effect played will change depending on the value of the specified variable.

In case you want to set this variable dynamically within another script, you can do that too. For example:
Code:
$game_variables[222] = [actor_name+"_namebox_se",80,100]
This is just an example, and it assumes that the actor_name variable is defined and is a string.

Note that if that variable is not an array, it will play the default sound effect from the text sound effect script settings instead.
 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
You could try to replace this line:
Code:
MESSAGE_SOUND.play
With these:
Code:
if $game_variables[222].is_a?(Array)
  RPG::SE.new(*$game_variables[222]).play
else
  MESSAGE_SOUND.play
end
In that text sound effect script.
This will set the specified variable to be used if it's an array.
Feel free to change the variable ID, I used 222 because that was closest to my fingers. :p

You can setup the variable with this script call:
Code:
$game_variables[222] = ["filename",volume,pitch]
Replace the stuff between the square brackets with your sound effect data.
Do this right before you want to show these message boxes, and the sound effect played will change depending on the value of the specified variable.

In case you want to set this variable dynamically within another script, you can do that too. For example:
Code:
$game_variables[222] = [actor_name+"_namebox_se",80,100]
This is just an example, and it assumes that the actor_name variable is defined and is a string.

Note that if that variable is not an array, it will play the default sound effect from the text sound effect script settings instead.
Hello, thanks for your help! After reading through your reply and checking the code, I realized the mistakes inside of my edited code. The conditional branch/SE change issue I had is now solved.

For anyone trying to use both Zerbu's SFX code (either the original one or this edited one - the site is in french but the code is in english) and TheoAllen's namebox code - and want to change SFX pitch/filenames inside your game scripts rather than with script calls:
  • Put the conditional checks inside the theoallen namebox script: in "def set_text(text, right, from_list = true)" (line 130 or so.) * Also make sure you set a value with that same variable for when there is no namebox windows on-screen.
  • If you decide to do an "if $game_variables" check in the namebox script, make sure you include any sort of color or variable codes, rather than just putting in the name only inside quotes. Ex: $game_variables[X] = N if result == "\\c[1]NameHere" (which would appear as "NameHere" when you're playing). Same applies for \\v[N] and any other escape codes or symbols.
  • I also found out that there is a simpler version of this type of script feature: using some message codes will change the type of sound effect that plays. This could work if you only want 2-3 voice variations. (It's a variant of the Zerbu script, edited by Kirimash. check the last post on the thread.) I don't believe this one requires namebox scripts to work.
 

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

Latest Threads

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,855
Messages
1,017,007
Members
137,563
Latest member
MinyakaAeon
Top