--[===[ Author: YoucefHam Email: youcefham20@gmail.com Discord: YoucefHam#5634 LUA ENGINE SETTINGS EXTRAS Add "LUA Engine" Button next to Memory View button Add items to the Right click menu in the lua engine editor: "Font Size": to change the font size of the editor and the output. "LuaEngine Editor On Top": Puts the editor on top and the output at the bottom. "Clear Output": Clear the output text. Add some functions: "clc()": Clear Output. "tsprint(...)": it is print(tostring(...)). "cprint(Component,'string to filter')": print components, example "cprint(MainForm)" or "cprint(MainForm,'memory')" "countPattern(String, pattern)": count how many pattern in String, example "Countpattern('29 87 1C 01 00 00 FF 77 7C', '%x%x')" return 9. ]===] -- My Default value, change if you want to mOutput_Font_Size = 13 mScript_Font_Size = 13 -- Add Lua Engine Button next to Memory View local timer = createTimer(nil, false) timer.Interval = 2000 timer_times = 1 timer.OnTimer = function(timer) synchronize(function() timer_times = timer_times + 1 if timer_times == 5 then timer.Interval = 5000 elseif timer_times >= 10 then -- After 2 min stop timer timer.Enabled = false timer.destroy() timer_times = nil end if not MainForm.Visible then return end timer.Enabled = false timer.destroy() timer_times = nil getLuaEngine().ComponentByName['mOutput'].Font.Size = mOutput_Font_Size getLuaEngine().ComponentByName['mScript'].Font.Size = mScript_Font_Size MainForm.btnLuaEngineMain.Height = MainForm.btnMemoryView.Height or 23 MainForm.btnLuaEngineMain.Width = MainForm.btnMemoryView.Width or 164 end) end timer.Enabled = true if MainForm.btnLuaEngineMain then MainForm.btnLuaEngineMain.destroy() end local bx1 = createButton(MainForm) bx1.Name = 'btnLuaEngineMain' bx1.Parent = MainForm.btnMemoryView.Parent bx1.AnchorSideLeft.Control = MainForm.btnMemoryView bx1.AnchorSideLeft.Side = asrRight bx1.AnchorSideTop.Control = MainForm.btnMemoryView bx1.AnchorSideTop.Side = asrTop bx1.BorderSpacing.Left = 5 bx1.Height = 23 bx1.Width = 164 bx1.caption = translate("LUA Engine") bx1.OnClick=function() if getLuaEngine().GetVisible() then if getLuaEngine().WindowState == 'wsMinimized' then getLuaEngine().WindowState = 'wsNormal' end getLuaEngine().BringToFront() else getLuaEngine().show() end end -- Change Lua Engine font size function LuaEngineEditorOnTop() for i = 0, getFormCount() - 1 do local frm = getForm(i) if frm.ClassName=='TfrmLuaEngine' and frm.isForegroundWindow(frm) then synchronize(function() frm.Panel1.Align = 'alTop' frm.Splitter1.Align = 'alTop' frm.GroupBox1.Align = 'alClient' frm.Panel1.Anchors = '[akTop,akLeft,akRight]' frm.Splitter1.Anchors = '[akTop,akLeft,akRight]' frm.GroupBox1.Anchors = '[akTop,akLeft,akRight,akBottom]' frm.Panel1.Top = 0 frm.Panel1.BorderSpacing.Bottom = 5 frm.Splitter1.Constraints.MaxHeight = 5 frm.Splitter1.Top = frm.Panel1.Top + frm.Panel1.Height frm.GroupBox1.Top = frm.Splitter1.Top + frm.Splitter1.Height end) return 1 end end end registerLuaFunctionHighlight('LuaEnginechangeFontSize') -- Put editor (script) on top, and the output at the bottom function LuaEngineEditorOnTop() for i = 0, getFormCount() - 1 do local frm = getForm(i) if frm.ClassName=='TfrmLuaEngine' and frm.isForegroundWindow(frm) then frm.Panel1.Align = 'alTop' frm.Splitter1.Align = 'alTop' frm.GroupBox1.Align = 'alClient' frm.Panel1.Anchors = '[akTop,akLeft,akRight]' frm.Splitter1.Anchors = '[akTop,akLeft,akRight]' frm.GroupBox1.Anchors = '[akTop,akLeft,akRight,akBottom]' frm.Panel1.Top = 0 frm.Panel1.BorderSpacing.Bottom = 5 frm.Splitter1.Constraints.MaxHeight = 5 frm.Splitter1.Top = frm.Panel1.Top + frm.Panel1.Height frm.GroupBox1.Top = frm.Splitter1.Top + frm.Splitter1.Height frm.Panel1.AnchorSideTop.Control = frm frm.Panel1.AnchorSideTop.Side = asrTop frm.Panel1.AnchorSideBottom.Control = '' frm.Panel1.AnchorSideBottom.Side = asrTop frm.Panel1.AnchorSideLeft.Control = frm frm.Panel1.AnchorSideLeft.Side = asrLeft frm.Panel1.AnchorSideRight.Control = frm frm.Panel1.AnchorSideRight.Side = asrRight frm.Splitter1.AnchorSideTop.Control = frm.Panel1 frm.Splitter1.AnchorSideTop.Side = asrBottom frm.Splitter1.AnchorSideBottom.Control = '' frm.Splitter1.AnchorSideBottom.Side = asrTop frm.Splitter1.AnchorSideLeft.Control = frm frm.Splitter1.AnchorSideLeft.Side = asrLeft frm.Splitter1.AnchorSideRight.Control = frm frm.Splitter1.AnchorSideRight.Side = asrRight frm.GroupBox1.AnchorSideTop.Control = frm.Splitter1 frm.GroupBox1.AnchorSideTop.Side = asrBottom frm.GroupBox1.AnchorSideBottom.Control = frm frm.GroupBox1.AnchorSideBottom.Side = asrBottom frm.GroupBox1.AnchorSideLeft.Control = frm frm.GroupBox1.AnchorSideLeft.Side = asrLeft frm.GroupBox1.AnchorSideRight.Control = frm frm.GroupBox1.AnchorSideRight.Side = asrRight return 1 end end end registerLuaFunctionHighlight('LuaEngineEditorOnTop') -- Creat Menu Items in Popup Menu local function addMenuItem(_Menu, _Name, _Caption, _OnClick, _ImageIndex) if not _Menu then return 0 end synchronize(function() local _item = createMenuItem(_Menu) _item.Name = _Name _item.Caption = _Caption if _OnClick then _item.OnClick = _OnClick end if _ImageIndex then _item.ImageIndex = _ImageIndex end _Menu.Items.Add(_item) end) end --Lua Engine Add Menus function LuaEngineAddMenu() local frm for i = 0, getFormCount() - 1 do frm = getForm(i) if frm.ClassName=='TfrmLuaEngine' and frm.isForegroundWindow(frm) then break end end frm = frm.ClassName=='TfrmLuaEngine' and frm or getLuaEngine() -- Get Popup Menu local pm = frm.ComponentByName['pmEditor'] --set the Default Value frm.ComponentByName['mOutput'].Font.Size = mOutput_Font_Size frm.ComponentByName['mScript'].Font.Size = mScript_Font_Size -- Add Separator addMenuItem( pm, 'mi__Seperator', '-' ) -- Add menu Font Size addMenuItem( pm, 'miFontSize', translate('Font Size'), LuaEnginechangeFontSize, frm.ComponentByName['MenuItem15'].ImageIndex ) -- Add menu Lua Engine Editor On Top addMenuItem( pm, 'miScriptOnTop', translate('LuaEngine Editor On Top'), LuaEngineEditorOnTop ) --Add menu Clear Lua Engine Output addMenuItem( pm, 'miClearOutput', translate('Clear Output'), frm.ComponentByName['MenuItem5'].doClick, frm.ComponentByName['MenuItem5'].ImageIndex ) -- Set "New Lua Engine window" to add the menus local oldNewWindow = frm.ComponentByName['MenuItem11'].OnClick frm.ComponentByName['MenuItem11'].OnClick = function(...) if oldNewWindow then oldNewWindow(...) end local timer = createTimer(nil, false) timer.Interval = 500 timer.OnTimer = function(timer) timer.Enabled = false timer.destroy() LuaEngineAddMenu() end timer.Enabled = true end end LuaEngineAddMenu() registerLuaFunctionHighlight('LuaEngineAddMenu') -- ///////////// Usefull functions /////////////// -- Clear Lua Engine Output function clc() local frm for i = 0, getFormCount() - 1 do frm = getForm(i) if frm.ClassName=='TfrmLuaEngine' and (_frm and true or frm.isForegroundWindow(frm)) then break end end frm = frm.ClassName=='TfrmLuaEngine' and frm or getLuaEngine() frm.ComponentByName['MenuItem5'].doClick() end registerLuaFunctionHighlight('clc') -- Print toString function tsprint(...) print(tostring(...)) end registerLuaFunctionHighlight('tsprint') -- Print components function cprint(m,str) if not m.ComponentCount then return end local mc = m.Component print('"Index" : "Component.Name" // "Component.Caption" || "Paresnt.Name" // "Parent.Caption"\n',('--'):rep(40)) for i = 0, m.ComponentCount - 1 do local p = function () print(i,':', mc[i].Name,' \t// \t', mc[i].Caption, (mc[i].Parent and ' \t|| \t'..mc[i].Parent.Name..' \t// \t'..mc[i].Parent.Caption or nil) ) end if not str then p() else if (mc[i].Name and mc[i].Name:lower():find(str:lower())) then p() elseif (mc[i].Caption and mc[i].Caption:lower():find(str:lower())) then p() elseif (mc[i].Parent and mc[i].Parent.Name:lower():find(str:lower())) then p() elseif (mc[i].Parent and mc[i].Parent.Caption:lower():find(str:lower())) then p() end end end end registerLuaFunctionHighlight('cprint') --Count how many pattern in string function countPattern(String, pattern) local count = {String:gsub(pattern,string)} return count[2] end registerLuaFunctionHighlight('countPattern') --Show Lua engine on startup --getLuaEngine().Show()