Fixing a Luna script crash with my custom battle system (RGSS3)

EDIT: Stumbled on another solution. Since it's checking arrays, I compared @list.size against the value of @index for my IF. Works now, you may close the thread. 😅
________________________________________________________


As this deals with Luna scripts, I'm avoiding posting a demo project or links because it's a paid script.


In the Luna scripts is an optional script called BattleLuna: Actor Command Configuration, which among other things is meant to display text in the Help Window when you highlight a command. The problem here, so far as my testing has shown, is that it isn't built to recognize situations in my custom battle system where no valid actor is highlighted, and crashes when I scroll outside of the more standard party members' command windows. The affected bit of the script is:

Spoiler: Script
def update_help
return unless @index >= 0
@help_window.set_text(addon_setting[:help][:text][@list[@index][:name]])
end

This generates the error:

Spoiler: Error Message
Script 'Actor Commands line 585: NoMethodError occurred.
undefined method '[]' for nil:NilClass

So clearly it's not built to handle cases where you're highlighting/scrolling to something that's nil, which will happen a lot in my battle system.

My Request:
I'd like a way to modify this section of script to only run if the affected components are not nil. Since I'm not much of a scripter myself, I can't really read what it's calling and my previous attempts to hack together an IF conditional have had no effect one way or another. I can confirm that the game works fine if this entire section of script simply *does not run* under any circumstance, so just wrapping it all in the appropriate IF check should work just fine. I just don't know the syntax or what to check.

It's a fairly important feature script for my game, so any insight would be very appreciated. 😢

Original thread: https://forums.rpgmakerweb.com/threads/fixing-a-luna-script-crash-with-my-custom-battle-system-rgss3.75730/