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,202
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

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top