Changing data field of actors

Beiben

Warper
Member
Joined
Nov 4, 2014
Messages
2
Reaction score
0
First Language
English
Primarily Uses
Hey Guys,

I've got a question which might have a very simple answer, but I've been stuck on this problem for a while now.

I want to add a data field for every actor which tracks how many of a certain troop they have killed. 

I don't want use variables to track it since it gets messy very quickly with several actor and several enemy types, so I've resorted to notetagging.

This is what I have so far:

class RPG::Actordef slainif @note =~ /<slain (.)>/i@slain = $1.to_ielsereturn 0endendendThis works fine. I can assign the field $data_actors[1].slain to a variable and it will show me the correct value. Changing the value of 

 $data_actors[1].slain doesn't seem to work. When I try:

$data_actors[1].slain += 1It shows me this error:

undefined method 'slain=' for #<RPG:Actor......>I thought $data_actors[1].slain was an integer? Why would '=' not be defined?

If anyone knows how to increment $data_actors[1].slain, I'd be very grateful for their help.

Thank You,

Beiben.
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,203
First Language
Binary
Primarily Uses
RMMZ
Dont! You should not be incrementing anything $data_xxxx as it will affect all save files.
 

PK8

I sense there's something in the wind...
Veteran
Joined
Mar 17, 2012
Messages
1,220
Reaction score
152
Primarily Uses
^ Thanks for the mention!


Because my topic's archived and I recently just moved my scripts around in my dropbox account, I'm going to link to the new (and temporary) location here: dl.dropbox.com/u/68527961/RMVXA/Scripts/[2012]/Self%20Data.zip


* Copy the url and paste it to your browser's address bar. This site's parsing my url oddly due to it having brackets.
 
Last edited by a moderator:

Beiben

Warper
Member
Joined
Nov 4, 2014
Messages
2
Reaction score
0
First Language
English
Primarily Uses
Thanks for the help guys.

That suite looks like it would do the trick for me. Unfortunately the link to your dropbox is not working for me.
 

PK8

I sense there's something in the wind...
Veteran
Joined
Mar 17, 2012
Messages
1,220
Reaction score
152
Primarily Uses
Ah, I forgot to add the dl subdomain. Here we go, just edited my other post.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


Do you also need help in adjusting those self-variables?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
slain is not an integer, it's a method that returns an integer...

if you want, you could simply do

class Game_Actor   attr_accessor: slain   alias initialize_slain initialize  def initialize(actor_id)    initialize_slain(actor_id)    @slain = 0  end  end

then you can safely do things like

$game_actors[1].slain += 1
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top