| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		usernotfound Expert Cheater
  Reputation: 0
  Joined: 21 Feb 2016 Posts: 115
 
  | 
		
			
				 Posted: Thu Dec 29, 2016 5:29 am    Post subject: Question for mgr.inz.Player (or anyone else who can answer) | 
				       | 
			 
			
				
  | 
			 
			
				Sorry to create another topic so soon, I wanted to ask mgr.inz.Player directly but seems his PMs are blocked so hoping he or someone else can see this and answer. I'm using his example for saving/loading settings for CE trainers (http://forum.cheatengine.org/viewtopic.php?t=545361), but can't seem to figure out how to load a boolean value this way
 
 
 	  | Code: | 	 		  function SaveSettingsClick()
 
  if TrainerOrigin then
 
    settingsFile = io.open(TrainerOrigin.."Settings.ini", "w")
 
    if (settingsFile ~= nil) then
 
      settingsFile:write(tostring(UDF1.CECheckbox1.Checked))
 
      settingsFile:close()
 
    end
 
  end
 
end
 
 
function LoadSettingsClick()
 
  if TrainerOrigin then
 
    settingsFile = io.open(TrainerOrigin.."Settings.ini", "r")
 
    if (settingsFile ~= nil) then
 
      UDF1.CECheckbox1.Checked = settingsFile:read()
 
      settingsFile:close()
 
    end
 
  end
 
end | 	  
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		mgr.inz.Player I post too much
  Reputation: 222
  Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
  | 
		
			
				 Posted: Thu Dec 29, 2016 10:13 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Code: | 	 		  print( type('true'=='true') )
 
print( type('true'=='false') )
 
print( type('true'=='whatever') )
 
>boolean
 
>boolean
 
>boolean
 
 
print( tostring('true'=='true') )
 
print( tostring('true'=='false') )
 
print( tostring('true'=='whatever') )
 
>true
 
>false
 
>false
 
 | 	  
 
 
 
So, your code needs only one small modification:
 
 	  | Code: | 	 		  function SaveSettingsClick()
 
  if TrainerOrigin then
 
    settingsFile = io.open(TrainerOrigin.."Settings.ini", "w")
 
    if (settingsFile ~= nil) then
 
      settingsFile:write(tostring(UDF1.CECheckbox1.Checked))
 
      settingsFile:close()
 
    end
 
  end
 
end
 
 
function LoadSettingsClick()
 
  if TrainerOrigin then
 
    settingsFile = io.open(TrainerOrigin.."Settings.ini", "r")
 
    if (settingsFile ~= nil) then
 
      UDF1.CECheckbox1.Checked = ( settingsFile:read() == 'true' )    -----  here
 
      settingsFile:close()
 
    end
 
  end
 
end | 	  
 _________________
  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		usernotfound Expert Cheater
  Reputation: 0
  Joined: 21 Feb 2016 Posts: 115
 
  | 
		
			
				 Posted: Thu Dec 29, 2016 1:34 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				Thank you so much sir! Cheers  
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |