Plugin:MirLua/Module/m core/ru: Difference between revisions

From Miranda NG
Jump to navigation Jump to search
(Imported translation using page migration)
(Imported translation using page migration)
Line 46: Line 46:
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>light userdata</code>
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>light userdata</code>


{{nbsp|5}}Returns event handle if event was created successfully, otherwise <code>nil</code>.
{{nbsp|5}}Возвращает дескриптор события, если событие было успешно создано, иначе <code>nil</code>.


==== {{Ls|MirLua/Modules/example}} ====
==== {{Ls|MirLua/Modules/example}} ====

Revision as of 13:35, 2 June 2018

Other languages:

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

Константы

Тип Описание
NULL light userdata Нулевой указатель.
INVALID_HANDLE_VALUE light userdata Невалидный дескриптор.
CALLSERVICE_NOTFOUND number Результат вызова несуществующего сервиса.

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

CreateHookableEvent

Создает событие.

Параметры

Имя параметра Required Тип Описание
name Да string Имя события.

Результат

     Тип:: light userdata

     Возвращает дескриптор события, если событие было успешно создано, иначе nil.

Пример

local hEvent = m.CreateHookableEvent('MyEvent')
if hEvent == m.NULL then
  print('Event handle is empty!')
end

HookEvent

Sets a callback function ("hook") to react to event call. Hooks are called one by one in the order they were added to the sequence.

Hook signature: function (wParam, lParam) return 0 end.

Correct result for a hook is 0. When 1 is returned, the following hooks in a sequence won't be called.

Параметры

Имя параметра Required Тип Описание
name Да string Event name.
hook Да function Hook function to be called when event occurs.

Результат

     Тип:: light userdata

     Returns hook handle if hook was created successfully, otherwise nil.

Пример

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

UnhookEvent

Removes hook from event call sequence.

Параметры

Имя параметра Required Тип Описание
hEvent Да light userdata Event handle received on CreateHookableEvent call.

Результат

     Тип:: boolean

     Returns true if hook function was removed successfully, otherwise false.

Пример

m.UnhookEvent(hHook)

NotifyEventHooks

Calls all hooks of event call sequence one by one.

Параметры

Имя параметра Required Тип Описание
hEvent Да light userdata Event handle received on CreateHookableEvent call.
wParam Нет
lParam Нет

Результат

     Тип:: boolean

     Returns true if all hooks were called, otherwise false.

Пример

m.NotifyEventHooks(hEvent)

Named service functions

CreateServiceFunction

Creates a service function ("service").

Параметры

Имя параметра Required Тип Описание
name Да string Service name.

Результат

     Тип:: light userdata

     Returns service handle if service was created successfully, otherwise nil.

Пример

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

CallService

Calls service with parameters.

Параметры

Имя параметра Required Тип Описание
name Да string Service name.
wParam Нет
lParam Нет

Результат

     Тип:: number

     Returns result of service execution or CALLSERVICE_NOTFOUND.

Пример

local result = m.CallService('MyService')
if result == m.CALLSERVICE_NOTFOUND then
  print('Service is not found!')
end

ServiceExists

Checks if service exists by its name.

Параметры

Имя параметра Required Тип Описание
name Да string Service name.

Результат

     Тип:: boolean

     Returns true if service exists, otherwise false.

Пример

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

DestroyServiceFunction

Destroys a service function.

Параметры

Имя параметра Required Тип Описание
hService Да light userdata Service handle received on CreateServiceFunction call.

Пример

m.DestroyServiceFunction(hService)

Other

IsPluginLoaded

Checks using UUID of the plugin whether it is loaded.

Параметры

Имя параметра Required Тип Описание
uuid Да string Plugin UUID in format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

Результат

     Тип:: boolean

     Returns true if plugin is loaded, otherwise false.

Пример

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

Translate

Translates a string into the language of the current langpack.

Параметры

Имя параметра Required Тип Описание
text Да string

Результат

     Тип:: string

Пример

m.Translate('Exit')

Parse

Replaces Miranda NG variables in a string.

Имя параметра Required Тип Описание
text Да string

Результат

     Тип:: string

Пример

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