Version 1.5 - bug fixes and small improvements

This commit is contained in:
OTCv8
2019-12-23 20:19:46 +01:00
parent cf8b21263d
commit d15cc347dc
17 changed files with 149 additions and 25 deletions

View File

@@ -34,6 +34,7 @@ function init()
onGameStart = online,
onGameEnd = offline,
onTalk = botOnTalk,
onTextMessage = botOnTextMessage,
onUse = botOnUse,
onUseWith = botOnUseWith,
onChannelList = botChannelList,
@@ -161,6 +162,7 @@ function terminate()
onGameStart = online,
onGameEnd = offline,
onTalk = botOnTalk,
onTextMessage = botOnTextMessage,
onUse = botOnUse,
onUseWith = botOnUseWith,
onChannelList = botChannelList,
@@ -479,6 +481,11 @@ function botOnTalk(name, level, mode, text, channelId, pos)
safeBotCall(function() compiledConfig.callbacks.onTalk(name, level, mode, text, channelId, pos) end)
end
function botOnTextMessage(mode, text)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onTextMessage(mode, text) end)
end
function botAddThing(tile, thing)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onAddThing(tile, thing) end)

View File

@@ -19,6 +19,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, webs
onKeyUp = {},
onKeyPress = {},
onTalk = {},
onTextMessage = {},
onAddThing = {},
onRemoveThing = {},
onCreatureAppear = {},
@@ -169,6 +170,11 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, webs
callback(name, level, mode, text, channelId, pos)
end
end,
onTextMessage = function(mode, text)
for i, callback in ipairs(context._callbacks.onTextMessage) do
callback(mode, text)
end
end,
onAddThing = function(tile, thing)
for i, callback in ipairs(context._callbacks.onAddThing) do
callback(tile, thing)

View File

@@ -39,6 +39,11 @@ context.onTalk = function(callback)
return context.callback("onTalk", callback)
end
-- onTextMessage(callback) -- callback = function(mode, text)
context.onTextMessage = function(callback)
return context.callback("onTextMessage", callback)
end
-- onAddThing(callback) -- callback = function(tile, thing)
context.onAddThing = function(callback)
return context.callback("onAddThing", callback)

View File

@@ -64,12 +64,10 @@ context.macro = function(timeout, name, hotkey, callback, parent)
end
-- hotkey(keys, callback)
-- hotkey(keys, callback, parent)
-- hotkey(keys, name, callback)
-- hotkey(keys, name, callback, parent)
context.hotkey = function(keys, name, callback, parent, single)
if type(name) == 'function' then
parent = callback
callback = name
name = ""
end
@@ -110,12 +108,10 @@ context.hotkey = function(keys, name, callback, parent, single)
end
-- singlehotkey(keys, callback)
-- singlehotkey(keys, callback, parent)
-- singlehotkey(keys, name, callback)
-- singlehotkey(keys, name, callback, parent)
context.singlehotkey = function(keys, name, callback, parent)
if type(name) == 'function' then
parent = callback
callback = name
name = ""
end