Changing Database Terms

Discussion in 'RGSS3 Script Requests' started by Sketchward, Aug 13, 2019.

  1. Sketchward

    Sketchward Veteran Veteran

    Messages:
    55
    Likes Received:
    3
    Location:
    Canada
    First Language:
    English
    Hey all. I'm lost at how to find certain containers/variables again.

    The game I've been working on contains the ability to enter and leave playable spacecraft which can enter battles of their own, as well as normal player ability to enter battles, and I need a different set of Terms for the stats of each. So I was wondering if there was an easy way to re-write fields on the Terms Tab of the Database while you're in-game. Level, HP/MP, player stats, equip types, commands.

    Example:
    Re-write the DEF term to "Defense" while a pedestrian, and "Hull Strength" while piloting a space ship.
    Re-write the MP term to "Mana" while a pedestrian, and "Energy" while piloting a space ship.
    etc.
     
    #1
  2. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,152
    Likes Received:
    422
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    EDIT: sorry, misread the section, I'll edit this message later to add a proper reply.

    - - - - - - - - - - - -​

    Real Reply
    @Sketchward Everything you want to change can be found in the Vocab module (the very first element in the list of scripts when you press F11). Using the following script and changing the values accordingly will do what you need.

    Code:
    module Vocab
      #--------------------------------------------------------------------------
      # Change the following values with the names you need (no empty spaces)
      #--------------------------------------------------------------------------
      # Basic Info
      #--------------------------------------------------------------------------
      BASIC_STATUS_NAMES = [ # <- keep this
        "Level",
        "Level (Short)",
        "HP",
        "HP (Short)",
        "MP",
        "MP (Short)",
        "TP",
        "TP (Short)"
        # In case you remove something here, keep in mind that you need 8 values
      ] # <- keep this
      #--------------------------------------------------------------------------
      # Equip Types
      #--------------------------------------------------------------------------
      ETYPE_NAMES = [ <- keep this
        # Same as above, just for equip types
        # Separate them with a comma and put them in the same order they are in the egine
      ] # <- keep this
      #--------------------------------------------------------------------------
      # Parameters
      #--------------------------------------------------------------------------
      PARAM_NAMES = [ <- Keep this
        # List your parameters here (same order as the ones in the engine)
        # Don't forget to separate them with a comma and to list them all.
      ] # <- keep this
      #--------------------------------------------------------------------------
      # Commands
      #--------------------------------------------------------------------------
      COMMAND_NAMES = [ # <- Keep this
        "Fight", # Fight
        "Escape", # Escape
        "Attack",   # Attack
        "Guard", # Guard
        "Items", # Items
        "Skills", # Skills
        "Equip", # Equip
        "Status", # Status
        "Formation", # Change Formation
        "Save", # Save
        "Exit Game", # Exit Game
        "Weapons", # Weapons
        "Armor", # Armor
        "Key Items", # Key Items
        "Change Equipment", # Change Equipment
        "Ultimate Equipment", # Ultimate Equipment
        "Remove All", # Remove All
        "New Game", # New Game
        "Continue", # Continue
        "Shut Down", # Shut Down
        "Title", # Go to Title
        "Cancel" # Cancel
      ] # <- Keep this
      #--------------------------------------------------------------------------
      # ** Vocab class (used to alias methods in the Vocab module)
      #--------------------------------------------------------------------------
      class << Vocab
        #------------------------------------------------------------------------
        # * Aliased method: Basic Status
        #------------------------------------------------------------------------
        alias hrk_vcb_basic_status_old basic
        def basic(basic_id)
          if $game_switches[SWITCH_ID_HERE]
            BASIC_STATUS_NAMES[basic_id]
          else
            hrk_vcb_basic_status_old(basic_id)
          end
        end # Basic Status
        #------------------------------------------------------------------------
        # * Aliased method: Parameters
        #------------------------------------------------------------------------
        alias hrk_vcb_param_old param
        def param(param_id)
          if $game_switches[SWITCH_ID_HERE]
            PARAM_NAMES[param_id]
          else
            hrk_vcb_param_old(param_id)
          end
        end # Parameters
        #------------------------------------------------------------------------
        # * Aliased method: Equip Type
        #------------------------------------------------------------------------
        alias hrk_vcb_etype_old etype
        def etype(etype_id)
          if $game_switches[SWITCH_ID_HERE]
            ETYPE_NAMES[etype_id]
          else
            hrk_vcb_etype_old(etype_id)
          end
        end # Equip Type
        #------------------------------------------------------------------------
        # * Aliased method: Commands
        #------------------------------------------------------------------------
        alias hrk_vcb_commands_old commands
        def commands(command_id)
          if $game_switches[SWITCH_ID_HERE]
            COMMAND_NAMES[command_id]
          else
            hrk_vcb_commands_old(command_id)
          end
        end # Commands
      end # end of Vocab class
    end # end of Vocab module
    

    Remember to change SWITCH_ID_HERE with a switch ID (you can use two different switches there if you want, this should give you more freedom). The two arrays at the beginning must have respectively 8 and 23 elements, each element, except for the last one, must be followed by a comma to separate it from the next one.

    I wrote this from mobile and I could not test the code. It is very simple though, you should have no troubles. Just double-check that every element in the arrays is followed by a comma.
     
    Last edited: Aug 14, 2019
    #2
    Sketchward likes this.
  3. Andar

    Andar Veteran Veteran

    Messages:
    28,153
    Likes Received:
    6,375
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    another way would be to trick the player with a multilanguage setup. only instead of two languages, you use english-people and english-ships
    search for SES external text as one option for a multilanguage script
     
    #3
    Sketchward likes this.
  4. Sketchward

    Sketchward Veteran Veteran

    Messages:
    55
    Likes Received:
    3
    Location:
    Canada
    First Language:
    English
    Working perfectly! No bugs at all.

    It's missing a couple of sections of the Terms Tab, though. I also need to be able to change Parameters (MHP, MMP, ATK, DEF, MAT, MDF, AGI, LUK), and Equip Types (Weapon, Shield, Head, Body, Accessory).

    Thanks so much for your time on this :biggrin:

    I didn't know languages was an option on this program. I haven't seen them anywhere?

    PS. I love your forum avatar. Who is the artist?
     
    #4
  5. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,152
    Likes Received:
    422
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    I changed the code above so that you can edit those parameters and equip type in game as well. I didn't have enough time to list them all as I did with commands and basic information. I hope you can do that on your own, the procedure is absolutely the same used for the other two. Feel free to ask if you have troubles with the script.
     
    #5
  6. Sketchward

    Sketchward Veteran Veteran

    Messages:
    55
    Likes Received:
    3
    Location:
    Canada
    First Language:
    English
    There were a couple syntax errors in that one I fixed, but I'm getting a name error on the final chunk of code now.

    Script 'HRK Vocab' line 114: NameError occured.
    undefined method 'commands' for class 'module'

    The listed line 114 is:
    Code:
        alias hrk_vcb_commands_old commands
    in the section:
    Code:
        #------------------------------------------------------------------------
        # * Aliased method: Commands
        #------------------------------------------------------------------------
        alias hrk_vcb_commands_old commands
        def commands(command_id)
          if $game_switches[SWITCH_ID_HERE]
            COMMAND_NAMES[command_id]
          else
            hrk_vcb_commands_old(command_id)
          end
        end # Commands
     
    #6
  7. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,598
    Likes Received:
    349
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Because it's supposed to be command not commands
    Code:
        #------------------------------------------------------------------------
        # * Aliased method: Commands
        #------------------------------------------------------------------------
        alias hrk_vcb_commands_old command
        def command(command_id)
          if $game_switches[SWITCH_ID_HERE]
            COMMAND_NAMES[command_id]
          else
            hrk_vcb_commands_old(command_id)
          end
        end # Commands
     
    #7
    Heirukichi likes this.
  8. Sketchward

    Sketchward Veteran Veteran

    Messages:
    55
    Likes Received:
    3
    Location:
    Canada
    First Language:
    English
    That fixed it! I'll post the finished code in the other forum. I added a credits section at the front with your name (Heirukichi), version number, date, etc.
     
    #8
  9. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,152
    Likes Received:
    422
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    @Sketchward if you want to repost the script, please wait until I make it more comfortable to use and upload it on my GitHub. I appreciate the fact that you want to share it with other people, but if you copy/paste it somewhere else it is going to be difficult to maintain it (which is one of the reasons why I don't allow people to repost my scripts).

    This is something I wrote quickly without having time to check the syntax or anything, it is not really something that I would share with the public. Let me polish it a little bit and then you can repost it as much as you want (providing a link instead of copy/pasting it).

    P.S. Sorry for the typos. Writing code from mobile is not exactly helpful when you have to look for mistakes.
     
    Last edited: Aug 13, 2019
    #9
  10. Sketchward

    Sketchward Veteran Veteran

    Messages:
    55
    Likes Received:
    3
    Location:
    Canada
    First Language:
    English
    New bug discovered. When in-game, opening the menu and selecting Equipment and then a character causes a crash to desktop with the following error:

    Script 'HRK Vocab' line 108: NoMethodError occured.
    undefined method 'hrk_vcb_etype' for Vocab:Module

    The listed line 108 is:
    Code:
            hrk_vcb_etype(etype_id)
    In the section:
    Code:
        #------------------------------------------------------------------------
        # * Aliased method: Equip Type
        #------------------------------------------------------------------------
        alias hrk_vcb_etype_old etype
        def etype(etype_id)
          if $game_switches[1]
            ETYPE_NAMES[etype_id]
          else
            hrk_vcb_etype(etype_id)
          end
        end # Equip Type
     
    #10
  11. Sketchward

    Sketchward Veteran Veteran

    Messages:
    55
    Likes Received:
    3
    Location:
    Canada
    First Language:
    English
    Seemed to have fixed that bug by removing the _old suffix from the alias.
     
    #11
  12. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,152
    Likes Received:
    422
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    Instead of removing it from the alias, add it to the normal method. I will promptly fix that in the code listed above. It does not change how the code works, but it is always a good practice to use meaningful names, and leaving that _old suffix tells to anyone who reads it that the method is the old one (before the alias).

    EDIT
    @Sketchward I fixed it, the code in my previous message now shows the right name.
     
    Last edited: Aug 14, 2019
    #12
    Sketchward likes this.
  13. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    11,784
    Likes Received:
    11,822
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA

    Sketchward, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.



    Next time please just use edit to add to your post instead of posting directly below yourself.
     
    #13

Share This Page