Checking Event Names with a Script Call (VX Ace)

I was pointing out that if you use
Code:
$game_map.events.values.select{|ev| ev.name =~ /door_(.*)/i ? true : false }
that catches the final index part in "Door_(xxx)" which is never evaluated,
since
Code:
ev.name =~ /door_(.*)/i ? true : false
always returns true if the event name includes 'door_' in it, which is the same as using
Code:
ev.name.include?("door_")

here,
Code:
$game_map.events.values.select{|ev| ev.name =~ /"Door"\s(\d+)/i ? $1.between?(0,99) : false}

this,
Code:
ev.name =~ /"Door"\s(\d+)/i ? $1.between?(0,99) : false
causes this,
Code:
$game_map.events.values.select{|ev| ev.name [...] }
to run and grab the event, only if the event's name includes a number at the end and the number is between 0 and 99, so "Door367" will never be grabbed.
(not that you would have 300 doors, but, I digress...)

this
Code:
$1.between?(0,99)
references the parentheses in
Code:
/"Door"\s(\d+)/i
which, if you're not expecting to find in the name, you don't need.
so, no point using the comparison when you can use .include?() directly

if all events named "Door" always imply a *door* code word for your logic, then go with .include?("door") and grab whatever results.
(which will NOT work, if you have numberings or other serialized things that would be part of the name, since you have to scan for the logic of it, which .include?() can't account for)
same for "dummy" or whatever naming.... as long as the same name implies the same function, it'll grab the bulk of them regardless of ID.
...Hold on.

*Puts on dunce cap*

Okay, so if I have:

Code:
mr = RPG::MoveRoute.new
mr.repeat = false
mr.wait = true
mr.list = []
mr.list.push( RPG::MoveCommand.new(36, []) )
mr.list.push( RPG::MoveCommand.new )

evs = $game_map.events.values.select{|ev| ev.name =~ /door_(.*)/i ? true : false }
evs.each {|ev| ev.force_move_route(mr) }

should be:

Code:
mr = RPG::MoveRoute.new
mr.repeat = false
mr.wait = true
mr.list = []
mr.list.push( RPG::MoveCommand.new(36, []) )
mr.list.push( RPG::MoveCommand.new )

evs = $game_map.events.values.select{|ev| ev.name.include?("door_")
evs.each {|ev| ev.force_move_route(mr) }
???

I know I'm terrible with code, so I made sure to read what you said multiple times to make sure I understood it. Thank you for explaining so thoroughly.
Both the include? method and the regexp check does the same in the end in this case, but if you don't need any further checks on the event name, you can use include? instead of the regexp.
I copied that code from my old samples for handling event names, didn't think about whether you need the match data or not (I always needed it 😛).

But more to the issue...
I highly doubt that anyone can solve your eventing issue without actually seeing how you built it up from the start to the end.
You should prepare a demo and show the event structure in it, more so because it uses multiple custom scripts.
Well, it's very fortunate that I prepared a demo recently, isn't it? I'll add a few notes and upload it.

I did want to have a second name check after the first one. There will be some doors facing north-south, and others east-west, which will obviously switch when the map rotates. Since those facing east-west will require a different hitbox change from the standard, I want to make them distinguished by naming them Door_Side_1, and so on. However, the doors can also be left open (will by noticed in enemy patrols, and by NPCs), meaning that there also needs to be a check for Self-Switch A on each Door event. It's been a headache working all this out, believe me.

Also, @Sixth , what's the real status on your shop? I've gotten mixed signals as to whether it's actually open.
Sorry, about that, I always forget to update that topic. Updated now, though. 😛
Ah, excellent. I'm hoping to commission an inventory script from you in late February, early March. That'd be difficult if your shop's not open! 😀


So, by redesigning the door event, and using the script call you've provided me, I have the doors properly rotating and operating, regardless of orientation, or whether they're open or not! All that's left is how to do a script call from a move route via a script call.

It should be similar to:

Code:
mr = RPG::MoveRoute.new
mr.repeat = false
mr.wait = true
mr.list = []
mr.list.push( RPG::MoveCommand.new(45, []) )   Game_Character defines this as: eval(params{0})
mr.list.push( RPG::MoveCommand.new )

evs = $game_map.events.values.select{|ev| ev.name =~ /door_(.*)/i ? true : false }
evs.each {|ev| ev.force_move_route(mr) }

Should I still upload a demo, or is this enough information? Now that I've fixed the door event, this will be a LOT easier.
It should look like this:
Code:
mr.list.push( RPG::MoveCommand.new(45, ["code goes here"]) )
So, you just put a string (the text between the quote marks) in the array (between the square brackets).
That string will be the code to evaluate (the "script call").
It works! Now I just need to differentiate the collision change depending on whether the door is open or not. Is there a way to do a batch check of each door's Self Switch A in a conditional branch?

Edit: That is no longer necessary! I've solved the issue through eventing. I woke up early this morning and couldn't go back to sleep, so I thought about this issue for a while. I realized that I could use a switch activating a page on each event to do the checking and hit-box-changing for me!

Hell ensued. However, after two and a half hours of hair-pulling frustration, it works entirely. Thank you so much for your help @Sixth , @gstv87 , and @Kes . I couldn't have done it without you (though ironically the final solution uses none of the code you provided me, but still! :|) !

Original thread: https://forums.rpgmakerweb.com/threads/checking-event-names-with-a-script-call-vx-ace.89053/