-
Notifications
You must be signed in to change notification settings - Fork 1
Client API
You can use these functions on Lua pages.
firewolf.version - The Firewolf Browser's version as a string. Ex: 3.4
firewolf.domain - The domain name of the site. Ex: mysite.com
center(text) - Center writes text.
firewolf.redirect(url) - Redirects the browser to another url, For example: firewolf.redirect("mysite.com/page") See Server API - Queries and firewolf.encode(vars) for advanced usage.
firewolf.download(page) - Downloads a file from the connected server to the /downloads folder on the client.
Returns: boolean success, string file path/error message. See example below.
firewolf.loadImage(page) - Loads an image as returned by paintutils.loadImage(path) from the server.
Returns: image image, string error message. See example below.
firewolf.encode(vars) - Encodes the dictionary table into the URL query format, the same way firewolf.query(page, [vars]) does it. For custom redirect requests, or for other things. See Server API - Queries for more information. See example below.
firewolf.query(page, [vars]) - Sends a request/query/data to the server and returns the text sent back from the server, recommended to be used in conjunction with the Server API to make things like forms and logins. vars is a dictionary table to be sent along with the url request, See Server API - Queries for more information.
Returns: string string the server responded with, otherwise false if error. See example below.
firewolf.download(page):
local success, msg = firewolf.download("myprogram")
-- This would be hosted on the server directory as
-- /fw_servers/mysite.com/myprogram
if success then
print("File downloaded to: " .. msg)
else
print("Error while downloading file: " .. msg)
end`firewolf.loadImage(page):` ```lua local image, error = firewolf.loadImage("image") if image then -- Draws the image in the top left corner paintutils.drawImage(image, 1, 1) else print("Could not load image: " .. error) end ```
`firewolf.encode(vars):`
Vars should be a dictionary table, like: {["cat"] = "meow", ["dog"] = "woof"}. All objects in the table should be strings, else they would be converted to strings. The Server API will be able to receive this dictionary table as a parameter to the handler function.
vars = {["cat"] = "meow", ["dog"] = "woof"}
local resp = firewolf.encode(vars)
print(resp) -- ?cat=meow&dog=woof`firewolf.query(page, [vars]):`
See firewolf.encode(vars) for use of vars
vars = {["cat"] = "meow", ["dog"] = "woof"}
local resp = firewolf.query("query", vars)
if resp then
print("Server responded with: " .. resp)
else
print("Error when querying server!")
end