[XP] Changing currency name in-game [RESOLVED]

Started by Kaiph, February 04, 2016, 09:21:05 pm

Previous topic - Next topic

Kaiph

February 04, 2016, 09:21:05 pm Last Edit: February 05, 2016, 08:15:51 am by Kaiph
It's unusual for a whole planet to use one universal currency, right? I've already got a currency conversion event up and running and it works for what I need, but I'm looking for a way to change the name of the currency to make it more 'realistic' (as realistic as RPGs aren't).
I'm assuming it could be done with a simple call script but I'm stumped as to what to actually do in that. I've looked at some of the RTP scripts and I can't seem to work it out. If anyone could help, that'd be great.
I'd prefer to not have to use a whole new script just for this minor detail, but obviously if it's needed then I'm all ears :)
Thanks!

Edit:
Just tried
Spoiler: ShowHide
$data_system.words.gold = "Gold2"

And it worked, until I saved my game and quit. When I came back to it, the words had reverted back. Tried using "==" (I don't know exactly what the difference is but it's worked before) and the event just froze.

ALSO I just realised I posted this in the wrong section. Apologies for that, if it's worth moving to the Event Requests page, then please do ^_^

KK20

Normally you would just change the string stored in $data_system.words.gold. The only problem is that this change is temporary. As soon as the user exits out of the game, it will default back to whatever you set it initially in your database.

A solution for that then is to reserve a variable in a class object that does get saved and call it from there. This class is typically Game_System.

class Game_System
  attr_accessor :gold
  alias init_for_currency_name initialize
  def initialize
    init_for_currency_name
    @gold = $data_system.words.gold_orig
  end
end

class RPG::System::Words
  def gold
    $game_system.nil? ? @gold : $game_system.gold
  end
  def gold=(newname)
    $game_system.nil? ? @gold = newname : $game_system.gold = newname
  end
  def gold_orig; @gold; end
end

So all of these script calls are now valid

# Print the currency name
$game_system.gold
$data_system.words.gold

# Change the currency name
$game_system.gold = "Cash"
$data_system.words.gold = "Cash"

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Kaiph

February 05, 2016, 08:15:30 am #2 Last Edit: February 05, 2016, 08:21:42 am by Kaiph
That's perfect, KK20! And it works with alternating between savegames. Thanks a bunch :)
One of these days I'll be able to undertand RGSS more so I don't have to keep asking for help xD

Also, thanks to whoever moved this. I figured it would come under events but I wasn't completely sure :')

Edit:
Just realised that was you too, KK20. Thanks :')