Default code for LUA - - Copy-Paste into the editor to start
-- Gather 4 lightstones to defeat the Brawler.
-- If you find a lightstone, hide.
local checkTakeHide = function(item)
if item then
-- The item is here, so take it.
hero:moveXY(item.pos.x, item.pos.y)
-- Then move to the center of the camp (40, 34)
end
end
while true do
-- Move to the top right X mark.
hero:moveXY(68, 56)
-- Search for a stone there.
local stone = hero:findNearestItem()
-- Call checkTakeHide() with the argument: stone
checkTakeHide(stone)
-- Move to the top left mark.
-- Search for a stone.
-- Call the checkTakeHide() function.
-- Pass in the result of your search as an argument.
end
Overview for LUA
You can use a function parameter as a variable inside the function. But also you can add additional instructions, which are not related to the parameter. For example:
local checkAndHit = function(unit)
if unit then
hero:attack(unit)
-- An additional instruction without 'unit'.
hero:say("I'm dangerous!")
end
end
Also, don’t forget you can call the same function as many times as you want.
hero:moveXY(10, 10)
local enemy = hero:findNearestEnemy()
checkAndHit(enemy)
-- Next point.
hero:moveXY(70, 10)
enemy = hero:findNearestEnemy()
checkAndHit(enemy)
Please feel free to use this to help you with the level until the patch is applied.