If you are going to use an Arduino Mega, you have to edit everything on this sketch that says "Serial" and replace it with "Serial1" (or whatever number you are using ...
Nextion Arduino library provides an easy-to-use way to manipulate Nextion serial displays. Old deprecated Enhanced Nextion Library with single display support can be found with Release tag 0.12.1 ...