Module change via Custom Name?

Status
Not open for further replies.
Joined
Jul 17, 2017
Messages
41
Reaction score
3
First Language
Spanish
Primarily Uses
RMVXA
Hello everyone!
well first off i mean i have been using a very interesting script called "External Script Loader" which allows RPG Maker to load .rb script externally (as file)

the matter is the following.
I create an external file with a Module
Example:

Ruby:
module Vocab_2
Item_1 = "Bow"
end
RPG Maker loads it perfectly. but I wanted to experiment further.
in Window_Base / def draw_item_name
I wanted to see if the item name could define the module.
Example:

Write here:
0004.png
equals Item.name
0002.png

but I would like the item to have the name of the module Vocab_2 Item_1 to define its name (in this case "Bow")
so i did the following:
0003.png
in this case item.name is equals Item_1

but for some reason it doesn't work.
I would appreciate if someone told me how to make the item name in the program define the module to display the name.
can that be possible?

Anyway, I would like to see if this technique also works not only with the names of the items, but also with $game_message.all_text and/or item.description.
thanks to everyone beforehand.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
It doesnt work because Vocab_2:: + item.name would actually mean

Get the text equivalent of Vocab_2:: then add item.name to that text

It doesnt become a call to Vocab_2::Item_1

You can try to replace it with this, see if it works

eval("Vocab_2::" + item.name)

This should be adding the words first, before evaluating them as a ruby expression via the eval call. Though I dont suggest this since your rb file is external, if the player inputs a malicious ruby code as an item name, the eval will run that malicious code.

another possibility is doing it via a hash

Code:
module Vocab_2
TEXTS = {}
TEXTS["Item_1"] = "Bow"
Then on your draw_item_name, just do

Vocab_2::TEXTS[item.name]
 
Last edited:
Joined
Jul 17, 2017
Messages
41
Reaction score
3
First Language
Spanish
Primarily Uses
RMVXA
It doesnt work because Vocab_2:: + item.name would actually mean

Get the text equivalent of Vocab_2:: then add item.name to that text

It doesnt become a call to Vocab_2::Item_1

You can try to replace it with this, see if it works

eval("Vocab_2::" + item.name)

This should be adding the words first, before evaluating them as a ruby expression via the eval call. Though I dont suggest this since your rb file is external, if the player inputs a malicious ruby code as an item name, the eval will run that malicious code.

another possibility is doing it via a hash

Code:
module Vocab_2
TEXTS = {}
TEXTS["Item_1"] = "Bow"
Then on your draw_item_name, just do

Vocab_2::TEXTS[item.name]
Yes, it works, but does this method still work for text windows?
I mean, it has the same defined text that can be defined with a module.
as:
Window_Message
0005.png

Could I still function like this the way you say?
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Joined
Jul 17, 2017
Messages
41
Reaction score
3
First Language
Spanish
Primarily Uses
RMVXA
It should work for any thing that shows text... Or even other data types actually, as long as you're returning the correct data type.
I have tried it with the same formula, but the window does not show any text.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
What formula did you use? and what does your module look like right now? What is the text you wrote in your message box?

One problem I can think of though is that the text in the message box isnt actually coded directly as how you typed it because the engine adds some formatting stuff to it (like adding line breaks etc which is then handled by this process_text method). This would also mean that you need to know how the engine formats them so that your texts in the module would also follow the format to avoid problems in showing the text.
 
Last edited:
Joined
Jul 17, 2017
Messages
41
Reaction score
3
First Language
Spanish
Primarily Uses
RMVXA
What formula did you use? and what does your module look like right now?
0007.png
0008.png
it is assumed that if a text window that has the word "Diag_1" it should show the vocab_2 / MGS module word that says "Text of text"

but when you try it in the game it doesn't show any text.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
View attachment 140169
View attachment 140170
it is assumed that if a text window that has the word "Diag_1" it should show the vocab_2 / MGS module word that says "Text of text"

but when you try it in the game it doesn't show any text.

Add this line above above the convert call:

p $game_message.all_text

Then test it with the console running, this should print out the how the engine sees the current text in your message box into the console.

Also, are you editing the default scripts directly? That is not suggested because once you have problems, it will be harder to determine the original state of the scripts (you'd need to open a new project to check). Also, that means that if you have another script (placed below Materials) that overwrites that method, your edits will not work.
 
Joined
Jul 17, 2017
Messages
41
Reaction score
3
First Language
Spanish
Primarily Uses
RMVXA
there is no need to worry, I take into account all the actions I do.

here is the console:

mmmm .. for some reason the window added /n to the end of the text. I think that is the problem.
 
Last edited:
Joined
Jul 17, 2017
Messages
41
Reaction score
3
First Language
Spanish
Primarily Uses
RMVXA
Add this line above above the convert call:

p $game_message.all_text

Then test it with the console running, this should print out the how the engine sees the current text in your message box into the console.

Also, are you editing the default scripts directly? That is not suggested because once you have problems, it will be harder to determine the original state of the scripts (you'd need to open a new project to check). Also, that means that if you have another script (placed below Materials) that overwrites that method, your edits will not work.
ready, I fixed it c:
I added the /n in the module

MGS = {}
MGS ["Diag_1\n"] = "Test"

and it works, thank you very much!
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
there is no need to worry, I take into account all the actions I do.

here is the console:

mmmm .. for some reason the window added /n to the end of the text. I think that is the problem.

Yeah, as I said in one of the replies before, the game adds formatting codes to the message box text because that's how the game knows what to do (like line breaks to determine where the next line begins because the message box can have four lines but the text you write is only taken as 1 whole text). Aside from the message box, this might also be the case at least for the description boxes, not sure though..
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,862
Reaction score
5,240
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,358
Members
137,803
Latest member
andrewcole
Top