Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Alyon93

Name of heroes in database

Question

Hi guys I have another question for you all. I don't actually know how to explain the problem, the title might be very confusing. However let's give it a try. So I know that every character name goes into a variable with a proper id, and I know that if you write \n[heroID] in a message, is actual name will come out, but now I have another question. If it's possible to use the same variable also in any other istance of the database. For example if I have a spar from two members of the team with a random name theirselves, i would like to show in place of the enemy name the current name of the other character. Example Peter fights David. When I enter the battle, Peter(which is the hero I'm using) is visible as Peter itself, but if I write in the enemy's name \n[003] which for example might be David's name variable instead of appear David it actually come out \n[003]. Also another situation might be a weapon with the name of one character. For example if Peter has a favourite sword i would like to write something like "Sword of \n[001]" and it should come out "Sword of Peter", but this actually doesn't work. So I hope someone might help. Thanks in advance for any answer!

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I haven't used rmxp since 2008 but i remember doung this.

 

You find the syntax in rmxp s help document. If not... i might have been using the advanced message script which you can download in the scripts section.

Share this post


Link to post
Share on other sites
  • 0

Actually my friend I don't think it's a matter of advanced message script, also I already got one. It's a matter of finding out how to show a variable in a database text box, i guess.... Thanks anyway for the fast answer ;-)

Share this post


Link to post
Share on other sites
  • 0

GSUB and Regular Expressions with Ruby

 

The part of the script you are looking for specifically is a Ruby Text Replacement for "Group Substitution".  Thats basically how \n[id] works, but you can add to that using something like \e[enemy_id] to replace the Message Text with the name of an Enemy.

 

      @text.gsub!(/\\[Ee]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_troop.enemies[$1.to_i].name : ""
      end

 

Untested, but that should replace a \e[enemy_id] with "Ghost" or "Basilisk".

(Note: the Exclamation Point! after gsub! is used to "destroy" the original variable, thus altering it how you want.  Otherwise a string is captured but the original variable is not altered.  Leaving a string the same is useful for Special Event Names: EV001\cat_actor[actor_id], or for Special Comments.

 

More enhanced message systems like MMW or Multiple Message Windows (available in my collection) do accomplish exactly what you ask.  You can display the name of Items, Weapons, Armors, Maps, and Icons for each of those things as well.  Even if you dont want to use MMW, the code that pulls off displaying the value of Variables may still be very useful to you.  Its all based around GSUB, GSUB!, and Regular Expressions.

Share this post


Link to post
Share on other sites
  • 0

Still I think i didn't explained myself really well(or at least I don't really understand what you were trying to say me). What you are telling me now is that I can put the name of an Enemy inside a message, right?
I'm not looking for this. I don't really have idea on how to explain it better. I'll make a long example to illustrate. Let's suppose that starting the game it asks you to name two heroes. "CharacterA" with the ID 001 the user called him "Peter"; "CharacterB" with the ID 002 the user called him "David".
So in the database they are still called "CharacterA" and "CharacterB" but in my save they will be called "Peter" and "David".
Now if I start a text message and i write  "\n[001] would you like to fight with \n[002]?" I should have this message "Peter would you like to fight with David?" ok. Now it's time to start the battle Peter is the hero actually in the party, while David is the enemy(even if it's a hero itself, only not in the party right now), since the name David is only stored in the hero[002] variable I can't actually copy it inside the enemy_name. At least not if I call the enemy with CharacterB's appearance and in his name I put \n[002]; I know someone might think I could simply call the enemy David, but if another user call it Robert instead of David in the battle it will still be called David. I hope I explained myself a lot better now.
Same goes with the "items" question. I don't want to show the name of an object inside of a message, I could simply write it, I want that inside the name or description of that item appears the name of one of my characters. Like before if "CharacterA" is called by the user "Peter" and I obtain an object ingame for example "Sword of *CharacterA*" I would like to show the current name of CharacterA whether I call it Peter, John, Richard and so on.
My question is all based on the possibility to give name to the character as anyone prefere. I hope you will understand something else now. Thanks anyway for the answer :-)

Share this post


Link to post
Share on other sites
  • 0

You can achieve this using Dubealex message script.

 

Have the item named like "Sword of \n[n]", and you can call in in text using \v[in], with n in the square brackets being replaced with the appropriate number of heroes and items in the database.

 

EDIT.

On a second though, it'll appear only in a message. The one that you want is to have it appeared on the menus and item description, right? Let's see if I can find something.

 

EDIT 2.

I think you're gonna need to write a script on that, for each window that you want to have the shortcut replaced into stored name in current database. All that I've heard is only a script for message windows, haven't heard any for items and menus. But, yeah, it still possible to do that.

 

The way to achieve that for message window is already posted by Heretic. You can apply the same method for other window script.

Edited by black mage

Share this post


Link to post
Share on other sites
  • 0

Basically, every hero name is a variable, so if I find a way to access to that variable by script it wouldn't be so hard to realize it. I'll try something and let you know. Also if you or anyone else can give me any advice on where to look, it would be great.

Share this post


Link to post
Share on other sites
  • 0

I solved the problem. 

Ichk from italian forum Rpg2s gave me this code. I'll leave it here in case someone might be interested. Anyway remember that he did this:

# Personal Generic Module
module Pers
  RE_ACT = /[\\]n[\[](\d)[\]]/i
  
  # Returns the name of the heroe from variable "\n[id]"
  def self.parsed_actor_name(text)
    a = text =~ self::RE_ACT ? $1.to_s : ""
    return $game_actors[a.to_i].name if a != ""
    return ""
  end
  
end

class RPG::Weapon
  def name
    return @name.gsub(Pers::RE_ACT) {Pers.parsed_actor_name(@name)}
  end
  
  def description
    return @description.gsub(Pers::RE_ACT) {Pers.parsed_actor_name(@description)}
  end
end

class RPG::Enemy
  def name
    return @name.gsub(Pers::RE_ACT) {Pers.parsed_actor_name(@name)}
  end
end 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...