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 


Add few new useful menu entries.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 146

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

PostPosted: Mon Jul 15, 2013 11:20 am    Post subject: Add few new useful menu entries. Reply with quote

I often open main.lua (doc file) and defines.lua when I'm creating not so generic trainers. Script below adds two new entries inside Help submenu:

Code:
function addMenuItem(parent,caption)
  if parent==nil then return nil end

  local newItem = createMenuItem(parent); parent.add(newItem)
  newItem.Caption = caption

  return newItem
end
menuItem_help = getMainForm().findComponentByName('Help1')

--add two new useful entries
addMenuItem(menuItem_help,'-')

addMenuItem(menuItem_help,'main.lua').setOnClick(
       function ()
         shellExecute('main.lua','',getCheatEngineDir())
       end)
       
addMenuItem(menuItem_help,'defines.lua').setOnClick(
       function ()
         shellExecute('defines.lua','',getCheatEngineDir())
       end)
       
addMenuItem       = nil
menuItem_help     = nil



Of course, you have to associate .lua files with notepad or notepad++

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

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

PostPosted: Sat Jul 27, 2013 6:56 pm    Post subject: Reply with quote

Another version,
added new entry: "Switch to 32/64 bit" and

Code:
function addMenuItem(parent,caption)
  if parent==nil then return nil end

  local newItem = createMenuItem(parent); parent.add(newItem)
  newItem.Caption = caption

  return newItem
end

-- which CE ?
if cheatEngineIs64Bit() then
  getMainForm().Caption = getMainForm().Caption .. '   64bit'
else
  getMainForm().Caption = getMainForm().Caption .. '   32bit'
end

-- add few new useful entries
menuItem_help = getMainForm().Help1
addMenuItem(menuItem_help,'-')

addMenuItem(menuItem_help,'Open main.lua').setOnClick(
 function ()
    shellExecute('main.lua','',getCheatEngineDir())
 end)

addMenuItem(menuItem_help,'Open defines.lua').setOnClick(
 function ()
    shellExecute('defines.lua','',getCheatEngineDir())
 end)

opposite = cheatEngineIs64Bit() and '32bit' or '64bit'

addMenuItem(menuItem_help,'Switch to '..opposite..' CE').setOnClick(
  function ()
    local canNotSwitch = (cheatEngineIs64Bit()==false) and (os.getenv("PROCESSOR_ARCHITEW6432")==nil)
    if canNotSwitch then
      messageDialog('You can not switch to 64bit CE, you have Win32.',mtInformation,mbOK)
      return
    end

    oppositeBinary = cheatEngineIs64Bit() and 'cheatengine-i386.exe'
                                           or 'cheatengine-x86_64.exe'

    local mr=messageDialog('Are you sure?',mtConfirmation,mbYes,mbNo)
    if mr==mrNo then return end
    shellExecute(oppositeBinary,'',getCheatEngineDir())
    createTimer(nil,true).OnTimer = function() closeCE() end
  end)


addMenuItem       = nil
menuItem_help     = nil
opposite = nil

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

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

PostPosted: Fri Jan 10, 2014 10:29 pm    Post subject: Reply with quote

CE6.3+ have new Option entry for every parenting(has children) memoryrecord:
"manual expand/collapse"

it shows small square next to "active square". This square contains tiny "-" when memoryrecord is collapsed, and tiny "+" when expanded.



This code will set "manual expand/collapse" for all memoryrecords which have hidden children:
Code:
addMenuItem(menuItem_help,'Reveal expandable memory records...').setOnClick(
  function ()
    local al = getAddressList()
    for i=0,al.Count-1 do
      local mr = al.getMemoryRecord(i)
      if mr.Count>=1 and mr.Options:match("%[moHideChildren%]") then
         mr.Options = "[moHideChildren,moManualExpandCollapse]"
      end
    end
  end)


paste it before this line
addMenuItem = nil

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials 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 cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites