Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Valdred on April 03, 2010, 05:05:04 pm

Title: [resolved]$game_party.gold -= 100 [xp]
Post by: Valdred on April 03, 2010, 05:05:04 pm
here's the code I use
$game_party.gold -= 100


Heres my error message:

Nomethoderror occured. undefined method 'gold=' for #<Game_Party:0x13c0a50>


By some reason, rpg maker reads .gold as a method when in fact, it's a variable, or an attribute or whatever.
Title: Re: $game_party.gold -= 100 [xp]
Post by: (Hexamin) on April 03, 2010, 05:11:57 pm
$game_party.gain_gold(value)


Just make value -100 and you'll be golden ;)
Title: Re: $game_party.gold -= 100 [xp]
Post by: Valdred on April 03, 2010, 05:18:16 pm
Thank's a lot. Levels up. I'm making a better debug script  :haha:.
Good thing I discovered how great this site really is.
Title: Re: $game_party.gold -= 100 [xp]
Post by: (Hexamin) on April 03, 2010, 05:26:26 pm
We're here for you!   :-*
Title: Re: $game_party.gold -= 100 [xp]
Post by: Jackolas on April 03, 2010, 05:30:18 pm
just to let you know..

rmxp uses
$game_party.gold to request the current gold to use in something else (calls its up but can't change)
$game_party.lose_gold(amount) to remove gold
$game_party.gain_gold(amount) to add gold

know its kinda late but anyway :P

Title: Re: $game_party.gold -= 100 [xp]
Post by: Valdred on April 03, 2010, 05:31:55 pm
That's helpfull, gives you a level up too  :)
Title: Re: $game_party.gold -= 100 [xp]
Post by: (Hexamin) on April 03, 2010, 05:34:27 pm
And last but not least, if you put [RESOLVED] in the title of this thread, that'll prevent you from being eaten alive by a moderator... such as Aqua... she eats people alive.  BASED ON A TRUE STORY may have eaten lunch money and not an actual person
Title: Re: $game_party.gold -= 100 [xp]
Post by: G_G on April 03, 2010, 07:05:21 pm
To do it like this
$game_party.gold -= 100


You need to change the gold attribute to accessor so its not reader. You can do it the above way with this small snippet.

class Game_Party
  attr_accessor :gold
end


Its useless but thats why it wasn't working before.