-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.lua
More file actions
32 lines (30 loc) · 980 Bytes
/
utils.lua
File metadata and controls
32 lines (30 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- this file should contains only functions to improve scripting experience
function onTalkContains(msg, callback)
local function onTalk(name, level, mode, message, channelId, creaturePos)
if message:lower():find(msg:lower()) then
callback(name, level, mode, message, channelId, creaturePos)
end
end
connect(g_game, {onTalk = onTalk})
return onTalk
end
function onScriptCallback(initFunc, terminateFunc, file)
if file then
if type(file) ~= "string" then
error("file parameter must be a string")
end
dofile(file)
end
if type(initFunc) ~= "function" or type(terminateFunc) ~= "function" then
error("initFunc and terminateFunc must be a function")
end
ScriptsManager.unhook() -- avoid getting data from functions called by initFunc
return initFunc()
end
function sendEquipItem(id)
local protocol = g_game.getProtocolGame()
local msg = OutputMessage.create()
msg:addU8(119)
msg:addU16(id)
protocol:send(msg)
end