The code is really simple, you could look for yourself if it works for func_train and func_tracktrain aswell. Just replace func_pushable with the desired entity classes. You can also copy-paste the while loop to perform the search with multiple entities, you just need to set iEnt = 0 in front of each while block.