Changing data field of actors

● ARCHIVED · READ-ONLY
Started by Beiben 8 posts View original ↗
  1. 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.
  2. Dont! You should not be incrementing anything $data_xxxx as it will affect all save files.
  3. ^ 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.
  4. 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.
  5. Ah, I forgot to add the dl subdomain. Here we go, just edited my other post.
  6. 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?
  7. 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