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
Last revisionBoth sides next revision
minionlib [2018/06/04 11:27] fxfireminionlib [2021/01/17 20:19] – Response headers string to table example kali
Line 108: Line 108:
   ***''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 215: Line 219:
  
  
 +
 +==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.txt · Last modified: 2021/04/30 18:13 by ace