User Tools

Site Tools



minionlib

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
minionlib [2018/04/18 08:44] fxfireminionlib [2021/04/30 18:13] (current) ace
Line 59: Line 59:
 ml_gui.ui_mgr:AddSubMember({ id = "FFXIVMINION##DEV_4", name = "DevC", onClick = function() Dev.GUI.open = not Dev.GUI.open end, tooltip = "Open the Dev monitor."},"FFXIVMINION##MENU_HEADER","FFXIVMINION##MENU_DEV5") ml_gui.ui_mgr:AddSubMember({ id = "FFXIVMINION##DEV_4", name = "DevC", onClick = function() Dev.GUI.open = not Dev.GUI.open end, tooltip = "Open the Dev monitor."},"FFXIVMINION##MENU_HEADER","FFXIVMINION##MENU_DEV5")
 </code> </code>
 +
 ===Utility Functions=== ===Utility Functions===
 +
 +==General==
 +  ***''d(...)''**
 +    *Prints out the passed variable or the result of a function into the console.
 +  ***''stacktrace()''**
 +    *Prints out the current call stack into the console.
 +  ***''Exit()''**
 +    *Closes the current game instance
 +  ***''ml_debug( //string// str )''**
 +    *Prints our the passed variable or the result of a function into the console when gEnableLog == "1".
 +  ***''ml_error( //string// str )''**
 +    *Prints our the passed variable or the result of a function into the console.
 +  ***''ml_log( //string// str )''**
 +    *Adds the string to the statusbar-line which gets shown on each pulse.
 +  ***''Now()''**
 +    *Returns tickcount from ml_global_information.Now
 +  ***''RegisterEventHandler(//string// eventtoregisterfor,//function// handler, //string// customNameHereToIdentifyYourCode)''**
 +    *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()''**
 +    *Returns //bool// , tries to unload the bot
 +  ***''QueueEvent( //string// eventname, //string// args, ...)''**
 +    *Queues and Fires the Event with 1-n arguments. Eventname and arguments need to be strings. 
 +    *Use RegisterEventHandler("eventname", handlerfunc) , to register a lua function which will handle the fired event.
 +    *Requires at least 1 argument, even if it's a blank string. (ex. QueueEvent("some event",""))
 +
 +
 ==File I/O== ==File I/O==
 For every I/O function, you need to use double dashes! Example: FolderExists("c:\\minionapp\\ILikeBeer\\Folder") For every I/O function, you need to use double dashes! Example: FolderExists("c:\\minionapp\\ILikeBeer\\Folder")
Line 78: Line 109:
   ***''FileDelete(//string// fullpathtofile)''**   ***''FileDelete(//string// fullpathtofile)''**
     *Returns //bool//      *Returns //bool// 
 +  ***''FileIsValidImage(//string// fullpathtofile)''**
 +    *Returns //bool// 
 +  ***''FileSize(//string// fullpathtofile)''**
 +    *Returns //number//
   ***''FolderExists(//string// fullpathtofolder)''**   ***''FolderExists(//string// fullpathtofolder)''**
     *Returns //bool//     *Returns //bool//
Line 178: Line 213:
  
  
-==General== 
-  ***''d(...)''** 
-    *Prints our the passed variable or the result of a function into the console. 
-  ***''Exit()''** 
-    *Closes the current game instance 
-  ***''ml_debug( //string// str )''** 
-    *Prints our the passed variable or the result of a function into the console when gEnableLog == "1". 
-  ***''ml_error( //string// str )''** 
-    *Prints our the passed variable or the result of a function into the console. 
-  ***''ml_log( //string// str )''** 
-    *Adds the string to the statusbar-line which gets shown on each pulse. 
-  ***''Now()''** 
-    *Returns tickcount from ml_global_information.Now 
-  ***''RegisterEventHandler(//string// eventtoregisterfor,//function// handler)''** 
-    *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()''** 
-    *Returns //bool// , tries to unload the bot 
-  ***''QueueEvent( //string// eventname, //string// args, ...)''** 
-    *Queues and Fires the Event with 1-n arguments. Eventname and arguments need to be strings.  
-    *Use RegisterEventHandler("eventname", handlerfunc) , to register a lua function which will handle the fired event. 
  
 ==Navigation== ==Navigation==
Line 209: Line 220:
  
  
 +
 +==Structure==
 +
 +The minion is layered into 3 distinct parts, components, members, and submembers.
 +
 +All components must have a header and (optionally) members, which are displayed when the header is clicked (and the menu is open).\\
 +All component headers require the following properties: **//bool// ''expanded'', //string// ''name'', //string// ''id''** \\
 +All component headers optionally contain the following properties: **//string// ''texture''**\\
 +
 +Members are displayed below their component containers, and they represent the rows that appear directly below the header.\\
 +Members may optionally contain submembers.\\
 +All members require the following properties: **//string// ''name'', //string// ''id''**\\
 +All members optionally contain the following properties: **//string// ''texture'', //string// ''tooltip'', //function// ''onClick'', //bool// ''sort''**\\
 +
 +Submembers are displayed to the right and grow vertically downward.  They are useful if you wish to section off a large amount of events.\\
 +Submembers will be sorted in alphabetical order by name if the **''sort''** tag is specified on the parent member.\\
 +All submembers require the following properties: **//string// ''name'', //string// ''id''**\\
 +All submembers optionally contain the following properties: **//string// ''texture'', //string// ''tooltip'', //function// ''onClick''**\\
 +
 +==API==
 +
 +  ***''ml_gui.ui_mgr:AddComponent( //table// component)''**
 +  ***''ml_gui.ui_mgr:AddMember( //table// member, //string// componentid)''**
 +  ***''ml_gui.ui_mgr:AddComponent( //table// submember, //string// componentid, //string// memberid)''**
 +
 +
 +===HTTPRequest===
 +Use this function to do any kind of asynchronous http calls. Example:
 +
 +<code lua>
 +function SendHttpRequest()
 +   local function success(str, header, statuscode)
 +      d("HTTP Request: success.")
 +      d("HTTP Result Header: " .. tostring(header))
 +      d("HTTP Result StatusCode: " .. tostring(statuscode))
 +
 +      local data = json.decode(str)
 +      if data then
 +         d("HTTP Request: data valid. Currency Coin info:")
 +         d(data)
 +      end
 +      
 +      local function HeadersTable(header)
 +         if type(header) == "string" and #header > 0 then
 +            header = string.match(header,".?%c(.*)") -- Removing the first entry
 +            local tbl = {}
 +            for w in header:gmatch("[^%c]+") do
 +               local k,v = string.match(w,"(.*): (.*)")
 +               tbl[k] = v
 +            end
 +            table.print(tbl)
 +            return tbl
 +         end
 +      end
 +      
 +      header = HeadersTable(header) -- if you want to convert the header string to a table
 +   end
 +
 +   local function failed(error, header, statuscode)
 +      d("HTTP Failed Error: " .. error)
 +      d("HTTP Failed Header: " .. header)
 +      d("HTTP Failed StatusCode: " .. tostring(statuscode))
 +   end
 +
 +   local params = {
 +      host = "api.guildwars2.com",
 +      path = "/v2/currencies?ids=1",
 +      port = 443,
 +      method = "GET", -- "GET","POST","PUT","DELETE"
 +      https = true,
 +      onsuccess = success,
 +      onfailure = failed,
 +      getheaders = true, --true will return the headers, if you dont need it you can leave this at nil
 +      body = "", --optional, if not required for your call can be nil or ""
 +      headers = {}, --optional, if not required for your call can be nil or ""
 +   }
 +
 +   HttpRequest(params)
 +end
 +</code>
minionlib.1524041097.txt.gz · Last modified: 2018/04/18 08:44 by fxfire