bot traceback, moveup function, chat setting default ongamestart

master
Henrique Santiago 12 years ago
parent c89665848d
commit 60495174a4

@ -194,8 +194,7 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
if lookThing then
local parentContainer = lookThing:getParentContainer()
if parentContainer and parentContainer:hasParent() then
local pos = lookThing:getPosition()
menu:addOption('Move up', function() g_game.move(lookThing, { x=pos.x, y=pos.y, z=254 }, lookThing:getCount()) end)
menu:addOption('Move up', function() g_game.moveToParentContainer(lookThing, lookThing:getCount()) end)
end
end

@ -176,6 +176,12 @@ local function onChannelList(channelList)
end
end
local function onGameStart()
local tab = Console.getTab('Default')
if tab then
addEvent(function() consoleTabBar:selectTab(tab) end, false)
end
end
-- public functions
function Console.init()
@ -185,6 +191,7 @@ function Console.init()
onOpenPrivateChannel = onOpenPrivateChannel,
onOpenOwnPrivateChannel = onOpenOwnPrivateChannel,
onCloseChannel = onCloseChannel,
onGameStart = onGameStart,
onGameEnd = Console.clear })
consolePanel = displayUI('console.otui', GameInterface.getBottomPanel())
@ -221,6 +228,7 @@ function Console.terminate()
onOpenPrivateChannel = onOpenPrivateChannel,
onOpenOwnPrivateChannel = onOpenPrivateChannel,
onCloseChannel = onCloseChannel,
onGameStart = onGameStart,
onGameEnd = Console.clear })
for channelid, channelname in pairs(channels) do

@ -521,6 +521,15 @@ void Game::move(const ThingPtr& thing, const Position& toPos, int count)
m_protocolGame->sendMove(thing->getPosition(), thing->getId(), thing->getStackpos(), toPos, count);
}
void Game::moveToParentContainer(const ThingPtr& thing, int count)
{
if(!canPerformGameAction() || !thing || count <= 0)
return;
Position position = thing->getPosition();
move(thing, Position(position.x, position.y, 254), count);
}
void Game::rotate(const ThingPtr& thing)
{
if(!canPerformGameAction() || !thing)
@ -927,7 +936,7 @@ bool Game::checkBotProtection()
// accepts calls comming from a stacktrace containing only C++ functions,
// if the stacktrace contains a lua function, then only accept if the engine is processing an input event
if(g_lua.isInCppCallback() && !g_ui.isOnInputEvent()) {
logError("caught a lua call to a bot protected game function, the call was canceled");
logError(g_lua.traceback("caught a lua call to a bot protected game function, the call was canceled"));
return false;
}
#endif

@ -132,6 +132,7 @@ public:
// item related
void look(const ThingPtr& thing);
void move(const ThingPtr &thing, const Position& toPos, int count);
void moveToParentContainer(const ThingPtr& thing, int count);
void rotate(const ThingPtr& thing);
void use(const ThingPtr& thing);
void useWith(const ItemPtr& fromThing, const ThingPtr& toThing);

@ -89,6 +89,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction("g_game", "stop", std::bind(&Game::stop, &g_game));
g_lua.bindClassStaticFunction("g_game", "look", std::bind(&Game::look, &g_game, std::placeholders::_1));
g_lua.bindClassStaticFunction("g_game", "move", std::bind(&Game::move, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
g_lua.bindClassStaticFunction("g_game", "moveToParentContainer", std::bind(&Game::moveToParentContainer, &g_game, std::placeholders::_1, std::placeholders::_2));
g_lua.bindClassStaticFunction("g_game", "rotate", std::bind(&Game::rotate, &g_game, std::placeholders::_1));
g_lua.bindClassStaticFunction("g_game", "use", std::bind(&Game::use, &g_game, std::placeholders::_1));
g_lua.bindClassStaticFunction("g_game", "useWith", std::bind(&Game::useWith, &g_game, std::placeholders::_1, std::placeholders::_2));

Loading…
Cancel
Save