Plugin:MirLua/Module/m core/ru: Difference between revisions
(copy formated for import to translation system) |
(Updating to match new version of source page) |
||
Line 1: | Line 1: | ||
<languages/> | |||
This module is imported into global table and available in any module through variable '''<var>m</var>'''. It allows you to access basic features of Miranda NG core. | |||
__TOC__ | |||
=== | == Constants == | ||
=== INVALID_HANDLE_VALUE === | {| class="wikitable" | ||
|- | |||
! | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" style="text-align:left" | {{Anchor|NULL}} NULL | |||
| style="text-align:center" | <code>light userdata</code> | |||
| Null pointer. | |||
|- | |||
! scope="row" style="text-align:left" | {{Anchor|INVALID_HANDLE_VALUE}} INVALID_HANDLE_VALUE | |||
| style="text-align:center" | <code>light userdata</code> | |||
| Invalid handle. | |||
|- | |||
! scope="row" style="text-align:left" | {{Anchor|CALLSERVICE_NOTFOUND}} CALLSERVICE_NOTFOUND | |||
| style="text-align:center" | <code>number</code> | |||
| Result of service call when service does not exist. | |||
|} | |||
=== | == Named events == | ||
=== CreateHookableEvent === | |||
Creates a hookable event. | |||
== | ==== {{Ls|MirLua/Modules/parameters}} ==== | ||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | name | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| Event name. | |||
|} | |||
=== | ==== {{Ls|MirLua/Modules/result}} ==== | ||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>light userdata</code> | |||
{{nbsp|5}}Returns event handle if event was created successfully, otherwise <code>nil</code>. | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code= | |||
local hEvent = m.CreateHookableEvent('MyEvent') | |||
if hEvent == m.NULL then | |||
print('Event handle is empty!') | |||
end | |||
}} | |||
---- | |||
=== HookEvent === | === 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: <code>function (wParam, lParam) return 0 end</code>. | |||
Correct result for a hook is <code>0</code>. When <code>1</code> is returned, the following hooks in a sequence won't be called. | |||
: | ==== {{Ls|MirLua/Modules/parameters}} ==== | ||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | name | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| Event name. | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | hook | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>function</code> | |||
| Hook function to be called when event occurs. | |||
|} | |||
: | ==== {{Ls|MirLua/Modules/result}} ==== | ||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>light userdata</code> | |||
{{nbsp|5}}Returns hook handle if hook was created successfully, otherwise <code>nil</code>. | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code=local hHook = m.HookEvent('MyEvent', function(w, l) | |||
print('MyEvent is raised!') | |||
end) | |||
}} | |||
---- | |||
=== UnhookEvent === | === UnhookEvent === | ||
Removes hook from event call sequence. | |||
==== {{Ls|MirLua/Modules/parameters}} ==== | |||
:: | {| class="wikitable" | ||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | hEvent | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>light userdata</code> | |||
| Event handle received on [[#CreateHookableEvent|CreateHookableEvent]] call. | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>boolean</code> | |||
{{nbsp|5}}Returns <code>true</code> if hook function was removed successfully, otherwise <code>false</code>. | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code=m.UnhookEvent(hHook)}} | |||
---- | |||
=== NotifyEventHooks === | === NotifyEventHooks === | ||
Calls all hooks of event call sequence one by one. | |||
: | ==== {{Ls|MirLua/Modules/parameters}} ==== | ||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | hEvent | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>light userdata</code> | |||
| Event handle received on [[#CreateHookableEvent|CreateHookableEvent]] call. | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | wParam | |||
| style="text-align:center" | {{Ls|YesNo/no}} | |||
| style="text-align:center" | | |||
| | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | lParam | |||
| style="text-align:center" | {{Ls|YesNo/no}} | |||
| style="text-align:center" | | |||
| | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>boolean</code> | |||
{{nbsp|5}}Returns <code>true</code> if all hooks were called, otherwise <code>false</code>. | |||
== | ==== {{Ls|MirLua/Modules/example}} ==== | ||
{{Content:MirLua/Example|code=m.NotifyEventHooks(hEvent)}} | |||
== Named service functions == | |||
=== CreateServiceFunction === | === CreateServiceFunction === | ||
Creates a service function ("service"). | |||
==== {{Ls|MirLua/Modules/parameters}} ==== | |||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | name | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| Service name. | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>light userdata</code> | |||
{{nbsp|5}}Returns service handle if service was created successfully, otherwise <code>nil</code>. | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code=local hService = m.CreateServiceFunction('MyService', function(w, l) | |||
print('MyServiceis called!') | |||
end) | |||
}} | |||
---- | |||
=== CallService === | === CallService === | ||
Calls service with parameters. | |||
: | ==== {{Ls|MirLua/Modules/parameters}} ==== | ||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | name | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| Service name. | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | wParam | |||
| style="text-align:center" | {{Ls|YesNo/no}} | |||
| style="text-align:center" | | |||
| | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | lParam | |||
| style="text-align:center" | {{Ls|YesNo/no}} | |||
| style="text-align:center" | | |||
| | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>number</code> | |||
{{nbsp|5}}Returns result of service execution or [[#CALLSERVICE_NOTFOUND|CALLSERVICE_NOTFOUND]]. | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code= | |||
local result = m.CallService('MyService') | |||
if result == m.CALLSERVICE_NOTFOUND then | |||
print('Service is not found!') | |||
end | |||
}} | |||
---- | |||
=== ServiceExists === | === ServiceExists === | ||
Checks if service exists by its name. | |||
: | ==== {{Ls|MirLua/Modules/parameters}} ==== | ||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | name | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| Service name. | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>boolean</code> | |||
{{nbsp|5}}Returns <code>true</code> if service exists, otherwise <code>false</code>. | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code=if m.ServiceExists('MyService') then | |||
m.CallService('MyService') | |||
end}} | |||
---- | |||
=== DestroyServiceFunction === | === DestroyServiceFunction === | ||
Destroys a service function. | |||
: | ==== {{Ls|MirLua/Modules/parameters}} ==== | ||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | hService | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>light userdata</code> | |||
| Service handle received on [[#CreateServiceFunction|CreateServiceFunction]] call. | |||
|} | |||
== | ==== {{Ls|MirLua/Modules/example}} ==== | ||
{{Content:MirLua/Example|code=m.DestroyServiceFunction(hService)}} | |||
== Other == | |||
=== IsPluginLoaded === | === IsPluginLoaded === | ||
Checks using UUID of the plugin whether it is loaded. | |||
: | ==== {{Ls|MirLua/Modules/parameters}} ==== | ||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | uuid | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| Plugin UUID in format ''<code>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</code>''. | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>boolean</code> | |||
{{nbsp|5}}Returns <code>true</code> if plugin is loaded, otherwise <code>false</code>. | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code=if m.IsPluginLoaded('{F0FDF73A-753D-499d-8DBA-336DB79CDD41}') then | |||
print('Advanced auto away plugin is loaded!') | |||
end | |||
}} | |||
---- | |||
=== Translate === | === Translate === | ||
Translates a string into the language of the current langpack. | |||
==== {{Ls|MirLua/Modules/parameters}} ==== | |||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | text | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>string</code> | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code=m.Translate('Exit')}} | |||
---- | |||
=== Parse === | === Parse === | ||
Replaces Miranda NG variables in a string. | |||
{| class="wikitable" | |||
|- | |||
! scope="col" | {{Ls|MirLua/Modules/param_name}} | |||
! scope="col" | {{Ls|MirLua/Modules/required_param}} | |||
! scope="col" | {{Ls|Content/TableHeaders/type}} | |||
! scope="col" | {{Ls|Content/TableHeaders/description}} | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | text | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}}: <code>string</code> | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code=local profileName = m.ReplaceVariables('%miranda_profilename%')}} |
Revision as of 13:26, 2 June 2018
This module is imported into global table and available in any module through variable m. It allows you to access basic features of Miranda NG core.
Constants
Тип | Описание | |
---|---|---|
NULL | light userdata
|
Null pointer. |
INVALID_HANDLE_VALUE | light userdata
|
Invalid handle. |
CALLSERVICE_NOTFOUND | number
|
Result of service call when service does not exist. |
Named events
CreateHookableEvent
Creates a hookable event.
Параметры
Имя параметра | Required | Тип | Описание |
---|---|---|---|
name | Да | string
|
Event name. |
Результат
Тип:: light userdata
Returns event handle if event was created successfully, otherwise 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%')