Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Substituting Letters in Database w/ Script

Status
Not open for further replies.

Culex

Member

I was wondering if there could be a modification in Window_Item, perhaps somewhere within a draw_text method, to allow the substitution of letters (it doesn't have to be that way, but it's the only method that seems to make sense to me). For instance, I would like to insert the Greek letter Omega (Ω) into one of my item names, however, the database does not allow for that (it instantly converts it to the English letter 'O').

Here's an example of what I would like the script or script particle to do:

In the database, I would put an asterisk (*) somewhere in my item name in the database. Then, what the script or script particle would do is change any asterisk in an item name to the desired letter (in my case, the Greek letter Omega (Ω)).

So a Potion * would be a Potion Ω! I hope that makes sense to someone out there. Thanks for your time.
 
I did this in a few seconds :p

Code:
class Scene_Title
  alias_method :trick_nameitems_title_main, :main
  def main
    trick_nameitems_title_main
    $data_items[1].name = 'PotionΩ'
  end
end

All you have to do is change the data that is stored in the database with new data, however if you want it the way you requested it (with the substitution of * with the Omega sign) then reply and I will edit it to do that
 

Culex

Member

I suppose I could have done that, although I'm going to have a lot of items and spells suffixed with Beta and Omega, just as a change of pace from 2 and 3 (like Fire Omega instead of Fire 3, etc.). Though your help is direly appreciated, I would be thrilled to see it done with letter substitution, only because it would be easier. Thanks, though!
 
Ok and edited

Code:
class Scene_Title
  Name_Substitutions = {'*' => 'Ω'}
  alias_method :trick_nameitems_title_main, :main
  def main
    trick_nameitems_title_main
    $data_items.each do |item|
      next if item == nil
      Name_Substitutions.each do |sub, new|
        item.name.gsub!(sub, new) if item.name.include?(sub)
      end
    end
  end
end

The Syntax for name subtitutions is

string_to_find => string_to_replace_with
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top