Why download a third-party script when this feature is built into MacOS? Just run:
sudo pmset -a disablesleep 1
to prevent macOS from sleeping. This works even when you close the lid and are on battery power. To re-enable normal sleep again, change the 1 to a 0.