View Full Version : Need some info on LUA functions

06-12-2014, 06:06 PM
Hi guys, I was wanting to know something about the LUA Engine for Eluna.

I do not have internet access on my computer right now so I'm having to do everything from my phone, which is quite difficult, and rendered me unable to get the information I needed by myself so.

I was thinking about coding a rotation bot, and I was viewing the Unit functions in the source code to see if I would be able to improve my bot calling functions like

Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const

Now I could be completely wrong about this so correct me if so but I've seen this done on retail before using custom API such as this

function NumberObjects(Function, type)
for i=1,GetTotalObjects() do
local ThisGUID= IGetObjectListEntry(i);
if not Type or (Type and IGetType(ThisGUID == Type) then
if not Function(ThisGUID) then
return false;
return true;

function GetNearbyEnemies(sourceUnit, dist)
dist = dist or 8;
local Nearby = {};
local Type = IGetType(ThisGuid);
if (Type == 3 or Type = 4) and not UnitIsDeadOrGhost("internal") and ICanAttack(UnitGuid("player") ,ThisGuid) and _distanceToObject(ThisGuid,sourceUnit) <= dist then
return true;
return Nearby;

and it opened up new doors for a whole lot of other fuctions like,

_Cast("spell", nearby)

So my question is would that be possible to do with a LUA Script within the LUA Folder, if so how would I go upon calling Blizzard functions such as



06-12-2014, 07:11 PM
I'm not entirely sure what you are asking for specifically, however the Blizzard API is not a part of the Eluna API. The Blizzard API is client side only.

06-12-2014, 07:13 PM
Okay that's what I was unsure about. I didn't know if you could mix them together. Sorry I didn't really specify.

06-12-2014, 07:14 PM
You are fine, if you specify what you want to do specifically I'm sure we could find a way for you to do what you need to do :)

06-12-2014, 07:26 PM
Well basically, to start off with I want it to get the enemies around me and Cast Corruption on them.

then i was gonna make it track the dots and if the dots about to go off of one of the enemies then re cast it on them.

06-12-2014, 08:13 PM
There are a few very nice and one very powerful function / method (s) to get creatures etc around you.
With GetNearObject you can do VERY large range of selections around a worldobject (player, creature, gameobject..).

:GetNearObject([nearest, range, typemask, entry, hostile])
Returns nearest WorldObject or table of objects in given range with given typemask (can contain several types) with given entry if given. Hostile can be 0 for any, 1 hostile, 2 friendly

Also see
:GetUnfriendlyUnitsInRange([range]) - Returns a list of unfriendly units in range, can return nil

With these you should be able to get the targets you want around the player.
Casting a spell is rather self explanatory

:CastSpell(target, spellID[, triggered]) - Casts spell on target (player/npc/creature), if triggered is true then instant cast

Now. Im pretty sure the spell will be instant cast in any case. Channeling wont likely work nor will cast times unfortunately.
If this is true ( have not tested, but likely is ), you cant exactly cast a spell like a client would with a lua method.

06-12-2014, 08:43 PM
Okay, I'll try to come up with something, thanks :)

- - - Updated - - -

If anyone else has any helpful suggestions it'd be appreciated :)