Skip to content

Web Request

The static global WebRequest class allows you to interact with the web via get, post and put. This is a more advanced feature that allows you to store/retrieve data to/from an external database.

Example Usage:WebRequest.get(https://www.google.com/, self, webRequestCallback)

Member Variables

Like Object member variables, WebRequests have their own member variables.

A WebRequest is returned as part of a function, and these member variables are how your access its information.

Variable Description Type
download_progress Download percentage, represented as a value from 0-1.
error Error text.
is_error If there is an error with the WebRequest.
is_done If the WebRequest has finished.
text Returned data.
upload_progress Upload percentage, represented as a value from 0-1.
url The targeted URL.

Function Summary

All functions return a WebRequest.

Function Name Description  
get( url,  callback_owner,  callback) Get data from the current URL.
post( url,  form,  callback_owner,  callback) Post the form to the URL.
put( url,  data,  callback_owner,  callback) Post the data to the URL.

Function Details

get(...)

Get data from the current URL.

get(url, callback_owner, callback)

  • url: The url to pull data from.
  • callback_owner: The Object that the callback function will be called on.
    • Global, self or any Object reference are all valid targets.
  • callback: The name of the function to be called.
function onLoad()
    print("Web Request Called")
    WebRequest.get("https://www.google.com", Global, "webRequestCallback")
end

function webRequestCallback(webReturn)
    print("Web Request Returned")
    print(webReturn.is_done)
end

post(...)

Post the form to the URL.

post(url, form, callback_owner, callback)

  • url: The url to pull post to.
  • form: The form of data to post.
  • callback_owner: The Object that the callback function will be called on.
    • Global, self or any Object reference are all valid targets.
  • callback: The name of the function to be called.

put(...)

Post the data to the URL.

put(url, data, callback_owner, callback)

  • url: The url to pull post to.
  • data: The data string to post.
  • callback_owner: The Object that the callback function will be called on.
    • Global, self or any Object reference are all valid targets.
  • callback: The name of the function to be called.