User Tools

Site Tools



minionlib_lua_api

This is an old revision of the document!


MinionLib Lua

This library is holding the core functionality on which all our bots are running. You can freely use the available functions for your Addon, in order to do that, you just need to open your module.def and set the dependency of your Addon to the lib:

[Module]
Name=YourAddon
Dependencies=minionlib
Version=1
Files=myluacode.lua
Enabled=1

Utility Functions

General
  • d(…)
    • Prints our the passed variable or the result of a function into the console.
  • Exit()
    • Closes the current game instance
  • getStartupPath()
    • Returns string root folderpath of the bot
  • ml_debug( stringstr )
    • Prints our the passed variable or the result of a function into the console when gEnableLog == “1”.
  • ml_error( stringstr )
    • Prints our the passed variable or the result of a function into the console.
  • ml_log( stringstr )
    • Adds the string to the statusbar-line which gets shown on each pulse.
  • Now()
    • Returns tickcount from ml_global_information.Now
  • RegisterEventHandler(stringeventtoregisterfor,functionhandler)
    • Registers a local handler to an event
  • Reload()
    • Returns bool , reloads all lua modules
  • TimeSince(integer previousTime)
    • Returns integer ml_global_information.Now - previousTime
  • Unload(integer previousTime)
    • Returns bool , tries to unload the bot
File I/O
  • FileExists(string pathtofile)
    • Returns bool
  • dirlist(string folderpath)
    • Returns table , all filenames in that folder
  • fileread(string pathtofile)
    • Returns table
  • filewrite(string pathtofile, stringstrtowrite)
    • Returns bool
  • LinesFrom(string pathtofile)
    • Returns table , this one cleanes the lines unlike fileread
  • LoadFile(stringpathtofile)
    • Loads a lua script from a file
Math
  • ApproxEqual(numbernum1,number num2)
    • Returns bool
  • Distance2D(numberx, numbery, numberx1, numbery1)
    • Returns number
  • Distance2DXY(numberx, numbery, numberx1, numbery1)
    • Returns number
  • Distance2DXZ(numberx, numberz, numberx1, numberz1)
    • Returns number
  • Distance3D(numberx, numbery, numberz, numberx1, numbery1, numberz1)
    • Returns number
  • round(number num, integerdecimals)
    • Returns number
  • randomize(integer int)
    • Returns integer , takes in a percentage from 0-100 and gives back a random number “near” that value
  • PathDistance(tableposTable)
    • Returns numberdistance, usage: PathDistance(NavigationManager:GetPath(myPos.x,myPos.y,myPos.z,p.x,p.y,p.z))
Strings
  • MultiComp(number or stringsearch, criteria)
    • Returns bool, criteria should be (,)-separated for OR's, (+)-separated for AND's
  • IsNullString(string arg)
    • Returns bool
  • StringContains(stringstr, item)
    • Returns bool
  • StringSplit(strings,stringdelimiter)
    • Returns functioniterator, usage:for itemid in StringSplit(potions,“;”) do
  • StringToTable(stringstr, stringdelimiter)
    • Returns table
  • TrimString(stringstr, integer numtoremovefromtheend)
    • Returns string
  • ValidString(string arg)
    • Returns bool
  • ValidString(string arg)
    • Returns bool
Tables
  • deepcopy( table, boolskipMetaTable )
    • Returns table
  • deepcompare(tabletable1,tabletable2,boolignore_metatable)
    • Returns bool, compares two tables if they are equal
  • pairsByKeys (tabletable)
    • Returns functioniterator, iterates over a table by keys, usage: for k,v in pairsByKeys(table) do
  • spairs(tabletable, functionsortfunc)
    • Returns functioniterator, iterates over and optionally sorts a table by keys, for k,v in spairs(TP.table,sort_func) do
  • TableSize(tabletable)
    • Returns integer
  • TableContains(tabletable, element)
    • Returns bool
  • table_invert(tabletable)
    • Returns table, flips a table so keys become values
  • shallowcopy(tabletable)
    • Returns table
  • table_merge(tabletable1,tabletable2)
    • Returns table
  • TableInsertSort(tabletblSort, integeriInsertPoint, tableitemvInsertValue)
    • Returns tableorderedTable
  • TableRemoveSort(tabletblSort, integeriRemovePoint)
    • Returns tableorderedTable
  • ValidTable(table arg)
    • Returns bool
minionlib_lua_api.1429873763.txt.gz · Last modified: 2015/04/24 11:09 by fxfire