Kindly note, this year, the Pilatus cogwheel railway will only operate from 05 June. Until then, the only way to get up to Pilatus is via cable way in Kriens.
I strongly suggest you not to buy any mountain railways tickets in advance. The weather in Switzerland, especially the nearer to the Alps, is not predictable, and you should only buy the tickets once the weather forecast is reliable, which isn’t the case more than 2 days out. You can even buy the tickets on the day of travel at the SBB Travel Center in the station of Lucerne, on the 1st floor. There is no financial benefit if you buy the tickets in advance; it is the opposite, you risk wasting money on a mountain excursion while you end up in bad weather and close at the top of Mt. Pilatus.
Does that sound reasonable to you?