[VX Ace]Two issues with 'Display States' icons' script (Lecode)(SOLVED)

Hi, me again (Not that I'm here often) with more issues with someone else's VX Ace script... I'm just gonna get right to it. Fortunately, I believe that these issues aren't gonna be as difficult to fix this time.

I'm using a script made by a Lecode that displays the icons of states applied to enemies. It's a great script, works wonderfully aside from two issues I'm having with it. In fact, I think these issues are downright bugs. Anyway, before I talk about the issues individually, let me provide you a link to where you can find the script... is what I would say except I can't seem to find the script on the Internet anymore. So, instead, I've attached a 'Text document' to this post that contains the script. Now, onto the issues.

Issue 1: Turn count always visible (Solved)
This script has a feature that displays a turn count on a state's icon. If a state is to be automatically removed after a set number of turns, the icon will display a small number that goes down once a turn. Once that number reaches 0, the state is removed. Personally, I don't want this feature. I want to remove it. Fortunately, this feature can be turned off by simply changing the line 'Turn_Count = true' to 'Turn_Count = false'. At least, that's the impression I'm getting from it. Thing is, true or false, the turn count is always visible. As far as I can tell, this is a bug and I'd like to believe that it's easy to fix. Unfortunately, as scripting inept as I am, I have no idea how to fix it.

Issue 2: Visible invisible states (Solved)
One of the things about states in VX Ace that I really like is that states without an icon don't take up space in an actor's list of states. For example: States S1, S2 and S3 with priorities 100, 75 and 50 respectively. S1 and S3 each have an icon while S2 does not. In battle, only two states can be displayed for an actor. If an actor has all states S1, S2 and S3, normally only S1 and S2 would be displayed. However, since S2 doesn't have an icon it will instead display S1 and S3. This can be really useful as it allows for invisible dummy states that the player would have no idea about regardless of their priorities (Although, I suppose this could also be avoided by simply giving those dummy states a priority of 0 *Shrugs*).
So, how does this apply to Lecode's 'Display States' icons' script? Well, the short answer is: It doesn't. This script doesn't have this function. States without an icon will still take up space in an enemy's list of states. Since these states are centered on an enemy's location, it causes the states to bounce left and right with possible gaps in between as dummy states are added and removed. Not to mention, if there's an invisible state that's permanent, that just pushes the list of states to the side permanently. So, anyone have any idea how to make states without icons not take up space in an enemy's list of states in this script? I sure don't.

There, those are the two issues I'm having trouble with. Here's to hoping that I'll get the help that I need. Also, if my explanation for the second issue was too difficult to understand, let me know and I'll see if I can provide a picture of it instead. Thanks in advance. This is Midashe signing out.
Hello. I'm using the same script, but I'm happy about the turn count, so I never did anything about it. However, I looked, and you're right, setting it to false doesn't do anything. I noticed in scripts that when you have colours, there are usually 4 numbers in brackets, the last one being opacity. In this script, there are only three. So I tried adding one more, zero, for invisible, and it seemed to have worked, there was no turn number next to the state icon. The lines in question are 30 - 43, add zeroes like this:


TC_Size = 16
TC_Color = Color.new(255,255,255,0)

#- Change text color when current turn count = TC_Warning_Turn
TC_Warning_Turn = 1
TC_Warning_Color = Color.new(245,100,100,0)

#- Enable blink effect ?
TC_Warning_Blink = true

TC_Blink_Color = Color.new(255,255,255,0)
TC_Blink_Duration = 30
#- Wait x frames before looping
TC_Blink_Wait = 5


About the other problem, I do have some dummy states on enemies, but I never noticed any shenanigans. And I'm afraid this is above my scripting abilities (which are pretty low anyway), so maybe someone else can help with that.
Yup, that worked. That solves at least one of the issues. Thanks for that.
That solution permanently sets the visibility to 0. so the opposite of the result you got before, but will never show them for others that want to see them.
The script needs to be fixed so that it does both option properly.
Unfortunately I'm not going to set up a demo to test it so that it can be fixed properly.

So what you did is fine and will work for you and others that want it visible can just leave it as it originally was.

Now for the second part, use this code. It's a modification to the original ( I also have an older version that has all of this in one method ) it will bypass creating the icon bitmap if the icon index is 0.
At least I'm assuming the index comes back with 0 since it's empty. If you changed it to another spot and that spot is empty then this will not work.
Ruby:
class LeStates_Icons
  def refresh_icons
    if @battler.dead?
      dispose_icons
      return
    end
    return unless can_refresh_icons
    @last_record = @battler.states
    dispose_icons
    @battler.states.each { |state|
      icon = create_icon(state)
      next if icon == nil
      create_turn_count(state)
      #-
      turn_count = state_turns(state)
      if Lecode_StatesIcons::TC_Warning_Blink && state.auto_removal_timing == 2
        start_blink(icon) if turn_count == Lecode_StatesIcons::TC_Warning_Turn
      end
    }
    @blink_frame = max_blink_frames
  end
  def create_icon(state)
    icon_index = state.icon_index
    return nil if icon_index == 0
    icon = Sprite.new
    icon.bitmap = Bitmap.new(24,24)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    icon.bitmap.blt(0, 0, bitmap, rect)
    icon.z = z
    icon.opacity = opacity
    @icons.push(icon)
    return icon
  end
end
Thank you. This has solved the second issue. It works perfectly. With that, both issues have been solved. Now, if a more, how-to-say, proper solution can be made for the first issue then I'll take it. However, the current solution works fine enough for me. Thank you guys for the help. Much appreciated.

Original thread: https://forums.rpgmakerweb.com/threads/vx-ace-two-issues-with-display-states-icons-script-lecode-solved.153365/