Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Is this a Lua bug or not? createOpenDialog

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Fri Apr 15, 2016 3:34 am    Post subject: Is this a Lua bug or not? createOpenDialog Reply with quote

Please take a look at the screenshot. I am trying to make save and load functions for the settings of my trainer.

When I clicked the "red cross" or "cancel" to close the dialog window, the file (123.txt) was still loaded if I had selected it with my mouse (but I did not click "open" yet). Shouldn't the program just simply close the dialog window without loading the file? Because I did not click "open".

Is there a way to fix it? Thanks.
My code is something like this, I am planning to use it to load the settings of the trainer. Sorry for the awful variable name:
Code:

function CEButton2Click(sender)
  dialog2 = createOpenDialog(sender)
  dialog2.DefaultExt=".txt"
  dialog2.Filter="TXT File (*.txt)|*.txt"
  dialog2.FilterIndex=1
  dialog2.execute()
  local f = io.open(dialog2.Filename,"r")
  if f == nil then
    return 0
  else
    local t = f:read("*a")
    f:close()
    local tt = t:match("checkbox1")
    local ttt = tonumber(string.sub(t,#tt+3,#tt+3))
    if ttt == 1 then
      CETrainer.CECheckbox1.checked = true
    end
    tt = t:find("editbox1")
    ttt = string.sub(t,tt+10,tt+15)
    if ttt ~= 0 then
      control_setCaption(CETrainer.CEEdit1,ttt)
    end
.......
......
end



Untitled.jpg
 Description:
 Filesize:  111.74 KB
 Viewed:  3205 Time(s)

Untitled.jpg


Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Apr 15, 2016 4:52 am    Post subject: Reply with quote

From main.lua
Code:
CommonDialog class:
  properties
    OnShow: function(sender)
    OnClose: function(sender)
    Title: string - The caption at top of the dialog
  methods
    Execute() : Shows the dialog and return true/false depending on the dialog


So:
Code:
if dialog2.execute()
 
  // stuff here 

end

_________________
Back to top
View user's profile Send private message MSN Messenger
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Fri Apr 15, 2016 10:41 am    Post subject: Reply with quote

mgr.inz.Player wrote:
From main.lua
Code:
CommonDialog class:
  properties
    OnShow: function(sender)
    OnClose: function(sender)
    Title: string - The caption at top of the dialog
  methods
    Execute() : Shows the dialog and return true/false depending on the dialog


So:
Code:
if dialog2.execute()
 
  // stuff here 

end


Thanks a lot, mgr.inz.Player. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites