panraven

mrCheckBoxEffect.lua

Sep 8th, 2020 (edited)
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. --
  2. -- The parent MR has desc as "[some test with out '['']' ]=>"
  3. -- then its children MR with same type may have some
  4. -- Checkbox effect
  5. -- updated from original: https://forum.cheatengine.org/viewtopic.php?t=587056
  6. --
  7. -- save script to autorun directory
  8. --
  9.   local function MRCheckBoxEffect(mr,newstate)
  10.     if not newstate then return end -- ignore deactivating
  11.     local parent = mr.Parent
  12.     local header = parent and parent.Description:match'^(%[[^%[%]]-%]=>)'
  13.     if not parent or not header then return end
  14.     -- ^ no effect if no parent or its desc not start with [...]=>
  15.     for i=1,parent.Count do
  16.       local sibling = parent[i-1]
  17.       if sibling~=mr and mr.Type==sibling.Type and sibling.Active then
  18.       --^ deactivate same type mr except the activating mr
  19.         sibling.Active=false
  20.       end
  21.     end
  22.     parent.Description = header .. mr.Description
  23.   end
  24.  
  25. onMemRecPreExecute = MRCheckBoxEffect
  26. -- there is only one definition for onMemRecPreExecute
  27. -- should test if onMemRecPreExecute already defined, and handle properly
Add Comment
Please, Sign In to add comment