Version 1.1 - crash bug fix and more advanced bot

This commit is contained in:
OTCv8
2019-11-03 19:20:48 +01:00
parent e65bdb534a
commit 6b5edaf6c8
12 changed files with 191 additions and 15 deletions

View File

@@ -31,7 +31,11 @@ function init()
onGameEnd = offline,
onTalk = botOnTalk,
onUse = botOnUse,
onUseWith = botOnUseWith
onUseWith = botOnUseWith,
onChannelList = botChannelList,
onOpenChannel = botOpenChannel,
onCloseChannel = botCloseChannel,
onChannelEvent = botChannelEvent
})
connect(rootWidget, { onKeyDown = botKeyDown,
@@ -53,6 +57,7 @@ function init()
connect(Container, { onOpen = botContainerOpen,
onClose = botContainerClose,
onUpdateItem = botContainerUpdateItem })
connect(g_map, { onMissle = botOnMissle })
botConfigFile = g_configs.create("/bot.otml")
local config = botConfigFile:get("config")
@@ -153,7 +158,11 @@ function terminate()
onGameEnd = offline,
onTalk = botOnTalk,
onUse = botOnUse,
onUseWith = botOnUseWith
onUseWith = botOnUseWith,
onChannelList = botChannelList,
onOpenChannel = botOpenChannel,
onCloseChannel = botCloseChannel,
onChannelEvent = botChannelEvent
})
disconnect(Tile, { onAddThing = botAddThing, onRemoveThing = botRemoveThing })
@@ -171,6 +180,7 @@ function terminate()
disconnect(Container, { onOpen = botContainerOpen,
onClose = botContainerClose,
onUpdateItem = botContainerUpdateItem })
disconnect(g_map, { onMissle = botOnMissle })
removeEvent(executeEvent)
removeEvent(checkMsgsEvent)
@@ -506,3 +516,33 @@ function botContainerUpdateItem(container, slot, item)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onContainerUpdateItem(container, slot, item) end)
end
function botOnMissle(missle)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onMissle(missle) end)
end
function botOnMissle(missle)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onMissle(missle) end)
end
function botChannelList(channels)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onChannelList(channels) end)
end
function botOpenChannel(channelId, name)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onOpenChannel(channelId, name) end)
end
function botCloseChannel(channelId)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onCloseChannel(channelId) end)
end
function botChannelEvent(channelId, name, event)
if compiledConfig == nil then return false end
safeBotCall(function() compiledConfig.callbacks.onChannelEvent(channelId, name, event) end)
end