Script Call Support Boards

@Solr Without knowing the details of your script, that question is somewhat difficult to answer. Please post a thread in Script Support. This is not the place for script related questions. It is for script calls that can be used in events independently of any/all non-default scripts.
@Solr Without knowing the details of your script, that question is somewhat difficult to answer. Please post a thread in Script Support. This is not the place for script related questions. It is for script calls that can be used in events independently of any/all non-default scripts.
All right, I see. Sorry for the trouble.
Is there a script call that can get the ID of an actor that has weapon/armor X equipped, and store it to a variable?
@Vis_Mage
Code:
a = $game_party.members.select { |actor| actor.equips.include?($data_weapons[Y]) }[0]
$game_variables[X] = a
Where Y is the ID of the weapon (you can also use $data_armors instead) and X is the idea of the variable.

EDIT:
Actually, if you just want the ID, you could do:
Code:
a = $game_party.members.select { |actor| actor.equips.include?($data_weapons[Y]) }[0]
$game_variables[X] = a.id if a
The 'if a' just means it won't throw an error if there are no actors with that equipment.
Thank you for your help, although I seem to be running into an error while attempting to use either. In both cases, I get:

Game_Interpreter:1409:in `eval': undefined method `[]' for nil:NilClass, NoMethodError
Is the code splitting over multiple lines? In which case, you can trim it down by doing something like:
Code:
w = $data_weapons[Y]
a = $game_party.members.select { |m| m.equips.include?(w) }[0]
$game_variables[X] = a.id if a
Also, make sure you change the Y and the X in the code above to the numbers you want to use.
Is the code splitting over multiple lines? In which case, you can trim it down by doing something like:
Code:
w = $data_weapons[Y]
a = $game_party.members.select { |m| m.equips.include?(w) }[0]
$game_variables[X] = a.id if a
Also, make sure you change the Y and the X in the code above to the numbers you want to use.

That seems to do the trick, thank you very much! 👋
Another quick question, I'm trying to check if anyone in the active party (in my case, the first 4 characters in the party) has state 5.

I'm currently using the following script call:
$game_party.members.any? { |member| member.state?(5) }

Could someone help me edit this command to only check the first 4 party members? I'm sure it has to do with changing out the ".any", but I'm having trouble finding the right syntax.
@Vis_Mage You should be able to do this:
Code:
$game_party.members[0..3].any? { |member| member.state?(5) }
Additionally, you could also use this
Code:
$game_party.battle_members
I've got a bit of a peculiar problem with scripts. In my game I set up enemy respawn upon resting - and to do so I've a small script snippet that I call:

Code:
def respawn_all_enemies(self_switch)
      # Enemies list. Array = [[map ID, event ID],[map ID, event ID],...]
      enemies = [ # Map, Event
          # 004: Cavern
          [4,3],
          [4,4],
          [4,5],
          # 005: Cavern (top)
          [5,6],
          [5,7],
          [5,8],
      ]
      for i in 0..enemies.size
        $game_self_switches[[i[0],i[1],self_switch]] = false
      end
  end

It goes through all the enemies I killed and revives them. But the problem is that if I add an enemy to the list, and load up a save, it will be skipped, as save file has "old" list. Is there any way I could refresh this one script, or even just the snippet, on every game load?
if I add an enemy to the list, and load up a save
I wonder how could you even "add enemy to the list". Or even where that your particular script is placed.

Is there any way I could refresh this one script
If you want to add enemy from the list, make it as a save content.
Use either Game_System or Game_Variables like
Code:
$game_variables[x] = [
[1,2],
[3,4],
# ...
]
Then to add enemy, you can use
Code:
$game_variables[x] << [5,4]
Another quick question, haha.

I'm using this script call to check if any enemy battlers have a state:
$game_troop.alive_members.any? {|enemy| enemy.state?(10) }

How would I go about editing it to instead check if 2 or more enemies have a state?
@Vis_Mage You could do something like:
Code:
($game_troop.alive_members.collect { |enemy| enemy.state?(10) }).size >= 2
Is there a script call equivalent to the set move route command 'Move away from player' but instead of an event moving away from the player, I want the player to move away from an event?

Thanks.
@Kes You could try:
Code:
$game_player.move_away_from_character($game_map.events[ID])
@A-Moonless-Night Spot on perfection. Thank you very much.
How can i check the name of Weapon that an Actor is equipping?
I want to put a script call into a Set Move Route command, so that if the player is within 3 tiles of an event, that event moves towards the player until it touches it. I tried the following but it threw an error message
Code:
self.x.between?($game_player.x - 3, $game_player.x + 3) &&  self.y.between?($game_player.y - 3, $game_player.y + 3) ? move_toward_player

That error message was that it was missing a :
So I amended the call to this
Code:
self.x.between?($game_player.x - 3, $game_player.x + 3) &&  self.y.between?($game_player.y - 3, $game_player.y + 3) ? move_toward_player : move_toward_player

That solved the error message, but now the event moves even when it is well over 3 tiles away.

Can anyone see my mistake? Or maybe I'm just going about this in totally the wrong way.
Thanks.

EDIT
I've sort of solved it, I think.
Clearly it needs something to act as the 'else' part, so I've changed it to read
: turn_towards_player
because I can't think of anything else to put in there.
However, I suspect I should have constructed an entirely different script call, and that this one is sub-optimal.
@Kes Could you just do:
Code:
move_toward_player if self.x.between?($game_player.x - 3, $game_player.x + 3) &&  self.y.between?($game_player.y - 3, $game_player.y + 3)

Original thread: https://forums.rpgmakerweb.com/threads/script-call-support-boards.25767/