Skip to content
MINIONBOTS edited this page May 3, 2014 · 4 revisions

ESOMinion works outside of ESO's Lua. That means that you have to understand that you are either running your Lua code in our Lua API or in the ESO Lua API. By default all code is running in ESOMinion's Lua engine. In order to access the ESO LUA API you have to do the following: You can find a nice overview about the ESO LUA API here: http://wiki.esoui.com/Main_Page

##1. Calling ESO API Functions: To access ESO API functions, you have to use e("....."). The whole ESO function beeing passed as a string to this e() function. Example:

local playelevel = e("GetUnitLevel(player)")  - player beeing the UnitTag

local abilityCost,mechanicType =  e("GetSlotAbilityCost(2)")

local bagID = 1
local repariCost = e("GetItemRepairCost( bagID, 3 )") --integer bagId, integer slotIndex)

NOTES:

  • You cannot use ANY " or anything else but a single string for the e() function.
  • You cannot direclty use a GLOBAL as an argument, you need to resolve this global first.

##2. Accessing ESO API Globals: To access ESO API globals, you have to use g("....."). Example:

local powerType = g("POWERTYPE_MAGICKA") --returns the int value of the global  slotIndex)

NOTES:

  • You cannot direclty use a GLOBAL as an argument for e("..."), you need to resolve this global first.

##3. Registering for ESO API Events: To register your Minion Lua code for an ESO API Event, you have to do two steps, first tell Minion to register for that Event and secondly setup a event handler function in your minion code. Example:

-- 1st Tell Minion to Register for the ESO Event:
RegisterForEvent("EVENT_STEALTH_STATE_CHANGED", true)

-- 2nd Register a handler on Minion-lua side, you NEED to add "GAME_" at the beginning of your event!!
RegisterEventHandler("GAME_EVENT_STEALTH_STATE_CHANGED",MyLuaHandlerFunc)

-- 3rd Handle the event:
function MyLuaHandlerFunc(...)
    local args = { ... }
    local numArgs = #args

    for i=1,#args do
       d(args[i])   -- d() is the debug print func of minion
    end
end
-- The example output will be:
12345 -- the internal event ID
"GAME_EVENT_STEALTH_STATE_CHANGED"  -- the event name
"player" -- unitTag , 1st returned arg of the event
2  -- stealthState , 2nd returned result of the event

NOTES:

  • Please check out the included LuaMods/globals.lua file for all already registered Events

##4. Running your code inside the ESO LUA instead of Minion LUA: If there are still problems with calling functions or getting values back or when you want to do something crazy, you can also run your lua code inside the ESO LUA engine. To do that, we provided an accessor function: eDoString() Example:

-- Setup some code to be registered and ran inside ESO LUA 
mycode = [[
  function getmapid()   --- function we are going to define inside ESO LUA so we can use it
     return GetCurrentMapZoneIndex()
  end
]]
eDoString(mycode)  -- executing mycode inside ESO LUA
-- At this point the getmapid() function is registered inside the ESO LUA API and you can access it:

local mapzoneidx = e("getmapid()")
Clone this wiki locally