dsod

Warper
Member
Joined
Apr 7, 2017
Messages
3
Reaction score
0
First Language
english
Primarily Uses
RMVXA
Hey im a real noob at the min but im trying to make the currency used in the game to be set to the name of a character/actor so the user can call it what they want.
I have this:
$data_system.currency_unit = $game_actors
[1].name

But it gives me this error:
Script 'Game_Interpreter' line 1411:NoMethodError occured.
undefined method for 'name' for [1]:Array

Im unsure on how my script this small can be causing this much of an issue xD If anybody has an idea on what im doing wrong please help.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,127
Reaction score
8,002
First Language
German
Primarily Uses
RMMV
that is because the [1].name is in the next line, not in the same line as the $game_actors

You need a manual break that tells the engine to look in the next line for the completion of the command, and you do that by manually pressing enter after the opening bracket.

$data_system.currency_unit = $game_actors[
1].name

will work where your variant creates an error.
 

dsod

Warper
Member
Joined
Apr 7, 2017
Messages
3
Reaction score
0
First Language
english
Primarily Uses
RMVXA
that is because the [1].name is in the next line, not in the same line as the $game_actors

You need a manual break that tells the engine to look in the next line for the completion of the command, and you do that by manually pressing enter after the opening bracket.

$data_system.currency_unit = $game_actors[
1].name

will work where your variant creates an error.
Thank you so much! been stuck on this for a while never would have thought it was that simple xD
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
585
Reaction score
295
First Language
German
Primarily Uses
Even though this isn't related to your question, keep in mind that by default the $data_... variables are only initialized when starting the game (or after resetting the game by pressing F12).
As a result all changes will be preserved when you load another savestate or start a new game, and all changes are reset to editor settings whenever the player quits the game.

In order to change the currency unit to an actors name, I'd suggest to redefine Vocab.currency_unit instead:
Code:
module Vocab
  def self.currency_unit
    return $game_actors[1].name
  end
end

In general, if you want to modify the database settings for your savestate, you could also modify these methods from the DataManager module to correct the settings whenever the player saves/loads a savestate or starts a new game:
create_game_objects is used for a new game
make_save_contents is used to determine what data is saved in your savefiles
extract_save_contents is used to restore the games state from savefile data

Hope this helps anyway...
 

dsod

Warper
Member
Joined
Apr 7, 2017
Messages
3
Reaction score
0
First Language
english
Primarily Uses
RMVXA
Even though this isn't related to your question, keep in mind that by default the $data_... variables are only initialized when starting the game (or after resetting the game by pressing F12).
As a result all changes will be preserved when you load another savestate or start a new game, and all changes are reset to editor settings whenever the player quits the game.

In order to change the currency unit to an actors name, I'd suggest to redefine Vocab.currency_unit instead:
Code:
module Vocab
  def self.currency_unit
    return $game_actors[1].name
  end
end

In general, if you want to modify the database settings for your savestate, you could also modify these methods from the DataManager module to correct the settings whenever the player saves/loads a savestate or starts a new game:
create_game_objects is used for a new game
make_save_contents is used to determine what data is saved in your savefiles
extract_save_contents is used to restore the games state from savefile data

Hope this helps anyway...

Oh right thanks I thought that may have been the case, so does that script set the currency only for the state you are currently on? Again sorry noob here.
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
585
Reaction score
295
First Language
German
Primarily Uses
The script does not change $data_system.currency_unit . Instead, it changes the source the currency unit is read from by the rest of the scripts.

By default, the name of the currency value is read by calling Vocab.currency_unit, which in turn returns the currency name you specified in the database (you can find the original implementation of this method in the Vocab script at the top of your script list, in line 109-111).
The script above redefines this method: If a method is defined multiple times (same name for the same class/module), the version closer to the Main script takes precedence (this is why you usually put scripts under the Materials section right before the Main script).

This script changes the method so it always returns Actor#1's name, regardless the value of $data_system.currency_unit , so you don't have to change that variable (you can change the source of your currency unit within the script if necessary).

Hope that solution is okay. :)
 

Latest Threads

Latest Posts

Latest Profile Posts

Anyone here is familiar with the US Law ? I'm working on a game idea at the moment and I have several questions on my mind :p
I just lost an hour plus of time to trying to modify the _battlefield sprite... when in reality MZ calls it _battleField ;_;

Even when debugging for the "undefined value", it looked exactly the same to my 20/60 eyesight.

I really prefer this_naming_convention rather than thisNamingConvention !!
hmm... I just solved one of the more annoying sideview battler problems in MV.. Passive States and Visual States can make it so when your character is in crisis HP, they don't go back to normal walk/wait when it's their turn. they stay in the crisis motion... neat.
Apparently all of LGBT reddit hates me. I posted a simple question and only got hate mail. What's the deal? The doompost was literally 6 months ago and I've changed my views since then and apologized.
MOD NOTE: See second response before replying to this. - Wavelength
Amazing. Simply amazing...

Forum statistics

Threads
109,107
Messages
1,042,127
Members
141,593
Latest member
Padouch
Top