User:Unsane/MirLua/m core: Difference between revisions

From Miranda NG
Jump to navigation Jump to search
No edit summary
(syntax highlight test)
Line 5: Line 5:
===CreateHookableEvent===
===CreateHookableEvent===
Создает именованное событие
Создает именованное событие
<code>local hEvent = m.CreateHookableEvent('MyEvent')</code>
{{Content:MirLua/Example|code=local hEvent = m.CreateHookableEvent('MyEvent')}}


===HookEvent===
===HookEvent===
Создает подписку на именованное событие
Создает подписку на именованное событие
<code>local hHook = m.HookEvent('MyEvent', function(w, l)
{{Content:MirLua/Example|code=local hHook = m.HookEvent('MyEvent', function(w, l)
   print('MyEvent is raised!')
   print('MyEvent is raised!')
end)</code>
end)
}}


===NotifyEventHooks===
===NotifyEventHooks===
Оповещает всех подписчиков именованного события
Оповещает всех подписчиков именованного события
<code>m.NotifyEventHooks(hEvent)</code>
{{Content:MirLua/Example|code=m.NotifyEventHooks(hEvent)}}


===UnhookEvent===
===UnhookEvent===
Удаляет подписку на именованное событие
Удаляет подписку на именованное событие
<code>m.UnhookEvent(hHook)</code>
{{Content:MirLua/Example|code=m.UnhookEvent(hHook)}}


===DestroyHookableEvent===
===DestroyHookableEvent===
Удаляет именованное событие
Удаляет именованное событие
<code>m.DestroyHookableEvent(hEvent)</code>
{{Content:MirLua/Example|code=m.DestroyHookableEvent(hEvent)}}


==Именованные сервисные функции==
==Именованные сервисные функции==
===CreateServiceFunction===
===CreateServiceFunction===
Создает именованную сервисную функцию
Создает именованную сервисную функцию
<code>local hService = m.CreateServiceFunction('MyService', function(w, l)
{{Content:MirLua/Example|code=local hService = m.CreateServiceFunction('MyService', function(w, l)
   print('MyServiceis called!')
   print('MyServiceis called!')
end)</code>
end)
}}


===CallService===
===CallService===
Вызывает именованную сервисную функцию
Вызывает именованную сервисную функцию
<code>m.CallService('MyService', 0, 0)</code>
{{Content:MirLua/Example|code=m.CallService('MyService', 0, 0)}}


===ServiceExists===
===ServiceExists===
Проверяет существование сервиса по имени
Проверяет существование сервиса по имени
<code>if m.ServiceExists('MyService') then
{{Content:MirLua/Example|code=if m.ServiceExists('MyService') then
   m.CallService('MyService')
   m.CallService('MyService')
end
end}}
</code>


===DestroyServiceFunction===
===DestroyServiceFunction===
Удаляет сервисную функцию
Удаляет сервисную функцию
<code>m.DestroyServiceFunction(hService)</code>
{{Content:MirLua/Example|code=m.DestroyServiceFunction(hService)}}


==Остальное==
==Остальное==
===IsPluginLoaded===
===IsPluginLoaded===
Проверяет загружен ли плагин по его muuid
Проверяет загружен ли плагин по его muuid
<code>if m.IsPluginLoaded('{F0FDF73A-753D-499d-8DBA-336DB79CDD41}') then
{{Content:MirLua/Example|code=if m.IsPluginLoaded('{F0FDF73A-753D-499d-8DBA-336DB79CDD41}') then
   print('Advanced auto away plugin is loaded!')
   print('Advanced auto away plugin is loaded!')
end
end
</code>
}}


===Utf8DecodeA===
===Utf8DecodeA===
Конвертирует содержимое lua строки в ANSI
Конвертирует содержимое lua строки в ANSI
<code>m.CallService("Quotes/Import", 0, Utf8DecodeA('c:\\quotes.xml'))</code>
{{Content:MirLua/Example|code=m.CallService("Quotes/Import", 0, Utf8DecodeA('c:\\quotes.xml'))}}


===Utf8DecodeW===
===Utf8DecodeW===
Конвертирует содержимое lua строки в Unicode
Конвертирует содержимое lua строки в Unicode
<code>m.CallService("Popup/ShowMessageW", m.Utf8DecodeW('Hello, World!'), 2)</code>
{{Content:MirLua/Example|code=m.CallService("Popup/ShowMessageW", m.Utf8DecodeW('Hello, World!'), 2)}}


===Translate===
===Translate===
Переводит строку на язык текущего языкового пакета
Переводит строку на язык текущего языкового пакета
<code>m.Translate('Exit')</code>
{{Content:MirLua/Example|code=m.Translate('Exit')}}


===ReplaceVariables===
===ReplaceVariables===
Заменяет переменные ядра Miranda NG в строке
Заменяет переменные ядра Miranda NG в строке
<code>local profileName = m.ReplaceVariables('%miranda_profilename%')</code>
{{Content:MirLua/Example|code=local profileName = m.ReplaceVariables('%miranda_profilename%')}}

Revision as of 00:45, 8 November 2015

Этот модуль изначально импортирован в глобальную таблицу и доступен через переменную m в любом модуле. Он предоставляет доступ к основным возможностям ядра Miranda NG.

Именованные события

CreateHookableEvent

Создает именованное событие

local hEvent = m.CreateHookableEvent('MyEvent')

HookEvent

Создает подписку на именованное событие

local hHook = m.HookEvent('MyEvent', function(w, l)
  print('MyEvent is raised!')
end)

NotifyEventHooks

Оповещает всех подписчиков именованного события

m.NotifyEventHooks(hEvent)

UnhookEvent

Удаляет подписку на именованное событие

m.UnhookEvent(hHook)

DestroyHookableEvent

Удаляет именованное событие

m.DestroyHookableEvent(hEvent)

Именованные сервисные функции

CreateServiceFunction

Создает именованную сервисную функцию

local hService = m.CreateServiceFunction('MyService', function(w, l)
  print('MyServiceis called!')
end)

CallService

Вызывает именованную сервисную функцию

m.CallService('MyService', 0, 0)

ServiceExists

Проверяет существование сервиса по имени

if m.ServiceExists('MyService') then
  m.CallService('MyService')
end

DestroyServiceFunction

Удаляет сервисную функцию

m.DestroyServiceFunction(hService)

Остальное

IsPluginLoaded

Проверяет загружен ли плагин по его muuid

if m.IsPluginLoaded('{F0FDF73A-753D-499d-8DBA-336DB79CDD41}') then
  print('Advanced auto away plugin is loaded!')
end

Utf8DecodeA

Конвертирует содержимое lua строки в ANSI

m.CallService("Quotes/Import", 0, Utf8DecodeA('c:\\quotes.xml'))

Utf8DecodeW

Конвертирует содержимое lua строки в Unicode

m.CallService("Popup/ShowMessageW", m.Utf8DecodeW('Hello, World!'), 2)

Translate

Переводит строку на язык текущего языкового пакета

m.Translate('Exit')

ReplaceVariables

Заменяет переменные ядра Miranda NG в строке

local profileName = m.ReplaceVariables('%miranda_profilename%')