#---main.py
#---This file does the background work for the code to run live
#-- Note: Do not edit this file if you want the code to run as it was intended.
#-- PS: That's why script.py exists! 


import traceback

#Continually be running the code 
while True:
#Handle any exceptions 
 try:

   
   
   

  #These lines will read the script 
  scriptfileread = open("script.py", "r")
  scriptlines=scriptfileread.read()
  
  #These lines will read 
  scriptfilewrite=open("script.txt","w+")
  scriptfilewrite.write(scriptlines)

  #Read the whats stored in the text file to compare with the script lines 
  textversionofscriptfile=open("script.txt","r")
  textlines=textversionofscriptfile.read()

  #If code edited logic 
  if scriptlines!=textlines:
   
   #Clean the terminal
   print(chr(27)+'[2j')
   print('\033c')
   print('\x1bc')

   #This line will run the script
   exec(open("script.py").read())
  #If code not edited logic 
  else: 
    #if the code has not been edited do nothing, removing this will cause an infinite loop
    continue
 

    
 except Exception:
#Print stack trace for the user to see 
  traceback.print_exc()



