System is not recognizing individual actor IDs.

Hello;

I'm using a modified version of Yanfly Engine Ace - Ace Status Menu v1.02, in which i'm trying to change the properties section which display hit rate and other data for one that displays variable numbers on a character by character basis. The section i'm modifying looks like this at the moment (I cut out all the redundant copies, because i just want to get the base script functioning before i paste it a bunch of times.)

  def draw_property(property, dx, dy, dw)

    fmt = "%1.2f%%"

    case property[0]

    #---

    when :hit

      if @actor=$data_actors[1]

         value = $game_variables[1]

       else value = $game_variables[21]

         end

    #---

    else; return dy

    end

    colour = Color.new(0, 0, 0, translucent_alpha/2)

    rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)

    contents.fill_rect(rect, colour)

    change_color(system_color)

    draw_text(dx+4, dy, dw-8, line_height, property[1], 0)

    change_color(normal_color)

    draw_text(dx+4, dy, dw-8, line_height, value, 2)

    return dy + line_height

  end

 

The script runs without error, but it shows all characters as meeting the criteria for displaying variable 1. How do i make a script differentiate between actor IDs?

  

 
= is assignment, so by saying @actor = $data_actors[1], you're SETTING @actor to $data_actors[1], and that's always going to make the if true. THIS is why everyone is showing variable 1. Instead, you should say this: if @actor.id == 1 (== is comparison).


Next time you need help with a script and you have a snippet to post, put your code into code tags, which makes it much easier to read. 🙂
Utter perfection. Thank you! I expected nothing less from a blue squirrel n_n

Also, how do i put a snippet in a code tag?  I apologize for being new.
Also, how do i put a snippet in a code tag?  I apologize for being new.
You write the opening code tag at the beginning and the closing code tag after the script.The dot inside the following lines needs to be removed, because if I write the correct tags, they would vanish and be replaced by the code frame.

[co.de]

write code here

[/co.de]

will turn into

Code:
write code here
if you write it without the dots.
If you use the full (GUI) editor, there's also a code button that you can use to create the opening/closing tags.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/system-is-not-recognizing-individual-actor-ids.21117/