First code I've done using Toyhou.se's coding, hopefully it looks alright!
https://pastebin.com/MuwV086m