-- Useful instruction when experimenting with Lua Engine -- GetLuaEngine().Menu.getItems()[0][5].doClick() local launchGameScript = [[ {$LUA} -- Launch Game Script -- if syntaxcheck then return end [ENABLE] local storedData = findTableFile("File Path.txt") local filePath = nil if storedData then local stream = createStringStream() stream.Position = 0 stream.copyFrom(storedData.Stream, storedData.Stream.Size) filePath = stream.DataString stream.destroy() else storedData = createTableFile("File Path.txt") end local function launchGame(filePath) local success, err = pcall(function() createProcess(filePath) end) if success then local stream = createStringStream(filePath) storedData.Stream.Position = 0 storedData.Stream.copyFrom(stream, stream.Size) stream.destroy() else error(err, 0) end end local function launchOpenFileDialog(filePath) local dialog = createOpenDialog(nil) dialog.Title = "Select Game File" dialog.InitialDir = filePath dialog.Filter = "Executables (*.exe)|*.exe|All files" dialog.DefaultExt = "exe" if dialog.execute() then filePath = dialog.FileName launchGame(filePath) else error("No file selected", 0) end dialog.destroy() end if filePath and filePath ~= "" then local message = string.format("Do you want to Launch\n<%s> ?", filePath) local result = messageDialog(message, mtConfirmation, mbYes, mbNo) if result == mrYes then launchGame(filePath) else launchOpenFileDialog(filePath) end else launchOpenFileDialog(filePath) end sleep(1000) getMainForm().Menu.Items[0][2].doClick() createThread(function() while readInteger(process) ~= nil do sleep(1000) end memrec.Active = false end) [DISABLE] ]] local function addLaunchGame() --[[ Creates a memory record containing the Launch Game script and adds it to the table --]] local memoryRecordName = "Launch Game" local memoryRecord = AddressList.getMemoryRecordByDescription(memoryRecordName) if not memoryRecord then memoryRecord = AddressList.createMemoryRecord() memoryRecord.Description = memoryRecordName memoryRecord.Type = vtAutoAssembler memoryRecord.Script = launchGameScript memoryRecord.Color = clPurple end end local function findItem(name, itemList) --[[ Finds a MenuItem object given it's Caption and parent Menu or MenuItem --]] for i = 0, itemList.Count - 1 do if itemList[i].Caption == name then return itemList[i] end end return nil end -- MainForm -> MainMenu -> TableMenu -> OptionsMenu -> Add Launch Game Item local mainForm = getMainForm() local mainMenu = mainForm.Menu local menuItems = mainMenu.getItems() local item = findItem("Table", menuItems) item = findItem("Options", item) if item then local newItem = createMenuItem(item) newItem.Caption = "Add Launch Game" newItem.onClick = addLaunchGame item.add(newItem) end