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_function) Get data from the current URL.
post( url,  form,  callback_function) Post the form to the URL.
put( url,  data,  callback_function) Post the data to the URL.

Function Details

get(...)

Get data from the current URL.

get(url, callback_function)

  • url: The url to pull data from.
  • callback_function: The function that will be triggered
    • Optional, but you will get no data back from the get if it isn't used.
function onLoad()
    print("Web Request Called")
    WebRequest.get("https://www.google.com", function(a) webRequestCallback(a) end)
end

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

post(...)

Post the form to the URL.

post(url, form, callback_function)

  • url: The url to pull post to.
  • form: The form of data to post.
  • callback_function: The function that will be triggered
    • Optional, but you will get no data back from the get if it isn't used.

put(...)

Post the data to the URL.

put(url, data, callback_function)

  • url: The url to pull post to.
  • data: The data string to post.
  • callback_function: The function that will be triggered
    • Optional, but you will get no data back from the get if it isn't used.