[resolved]$game_party.gold -= 100 [xp]

Started by Valdred, April 03, 2010, 05:05:04 pm

Previous topic - Next topic

Valdred

April 03, 2010, 05:05:04 pm Last Edit: April 04, 2010, 06:08:57 am by Valdred
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.

(Hexamin)

$game_party.gain_gold(value)


Just make value -100 and you'll be golden ;)
Max 1111101000; characters remaining: 1110111000

Valdred

Thank's a lot. Levels up. I'm making a better debug script  :haha:.
Good thing I discovered how great this site really is.

(Hexamin)

Max 1111101000; characters remaining: 1110111000

Jackolas

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


Valdred

That's helpfull, gives you a level up too  :)

(Hexamin)

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
Max 1111101000; characters remaining: 1110111000

G_G

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.