-
Notifications
You must be signed in to change notification settings - Fork 1
GPhone Library
The GPhone library is primarily used to make it easier for developers when creating Apps and dependencies. Listed below are some variables that you should NOT change, but you can reference if you want to.
GPhone.Width -- The width of the phone screen
GPhone.Height -- The height of the phone screen
GPhone.Ratio -- The screen width divided by height
GPhone.Resolution -- The screen height divided by 830
GPhone.CursorPos -- Returns the "real" x and y coordinates. Use GPhone.GetCursorPos() instead to support all resolutions.
GPhone.CursorEnabled -- Whether the cursor is enabled
The functions below are most often used when setting/getting data from a specific app. app
should normally be left as nil
unless you are calling it from outside the app-specific functions (Like a timer or a Hook) in which case it would be the name of the App as a string
GPhone.SetAllAppData( table, app ) -- Save all data for a specific app (Leave empty for current app)
table = GPhone.GetAllAppData( app ) -- Retrieve all data from an app (Leave empty for current app)
GPhone.ClearAllAppData( app ) -- Clear all data from a specific app (Leave empty for current app)
GPhone.SetAppData( key, value, app ) -- Save data with the key tied to the app (Leave empty for current app)
var = GPhone.GetAppData( key, def, app ) -- Retrieve data with the key tied to the app (Leave empty for current app)
These functions are generally used when changing a universal setting that is supposed to prevail even when the user uninstalls the app. Settings like the background and such are saved here, so you shouldn't poke around too much unless necessary.
GPhone.SetData( key, value ) -- Save data with the unique key
var = GPhone.GetData( key, def ) -- Retrieve the data with the unique key or 'def' if nothing was found
These functions are mainly used for sharing tables of data with people on the server. It's untested so it might not work that well.
GPhone.HookSharedData( key, func ) -- Create a hook that is called every time you retrieve data with the specific key
GPhone.SendSharedData( ply, key, table ) -- Send a table of data to a specific player with a unique key
table = GPhone.GetSharedData( key, def ) -- Retrieve shared data of the specific key or 'def' if nothing was found
These functions are useful for playing music with the phone. Using StartMusic
multiple times will stop the previous song before playing the new one, even if the songs are the same path/URL.
GPhone.StartMusic( url ) -- Start playing music from the URL/path provided
GPhone.StopMusic() -- Stop any music currently playing
GPhone.ToggleMusic( play ) -- Pause or play music
table = GPhone.GetMusic() -- Returns a table containing data for the music
The functions below are mainly used for text-input. Most of them are self-explanatory.
GPhone.InputText( enter, change, cancel, text, keypress ) -- Start a text-input with 'text' as placeholder and 'enter', 'change', 'cancel' and 'keypress' callback functions
GPhone.CloseInput() -- Close the text-input (doesn't call the 'cancel' callback)
string = GPhone.GetInputText() -- Get the text from the text-input in real-time
GPhone.SetCaretPos( pos ) -- Sets the position of the caret
pos = GPhone.GetCaretPos() -- Returns the position of the caret
These functions can be used for cross-app functionality, like opening a song in a music-app from a different App or downloading an App from a custom store.
frame = GPhone.RunApp( name ) -- Runs or focuses the app with the name. Returns the root-panel on success, otherwise returns false
bool = GPhone.StopApp( name ) -- Stop the app with the name. Returns true on success, otherwise returns false
frame = GPhone.FocusApp( name ) -- Focus a specific app. Returns the root-panel on success, otherwise returns false
GPhone.FocusHome() -- Focus the home screen.
bool = GPhone.InstallApp( name ) -- Install an app. Returns true on success, otherwise returns false
GPhone.UninstallApp( name ) -- Uninstall an app. Removes the app-file if it is a clientside app. Returns true on success, otherwise returns false
name = GPhone.DownloadApp( url ) -- Downloads an app from the provided URL and returns it's name
Most of these functions are pretty self-explanatory and have nothing specific in common.
x,y = GPhone.GetCursorPos() -- Returns the x and y coordinates of the cursor.
GPhone.EnableSelfie( bool ) -- Enable selfie-mode. Thirdperson arm stretches forward in a 'pistol' stance
bool = GPhone.SelfieEnabled() -- Whether selfie-mode is enabled or not
GPhone.ChangeVolume( vol ) -- Change the phone volume (0-1)
GPhone.Vibrate() -- Makes the phone vibrate for a short time (WIP)
mat = GPhone.RenderCamera( fov, front, pre, post ) -- Renders a view from the camera (front or back), returns the material of the rendertarget
x,y = GPhone.RootToLocal( frame, x, y ) -- Return x and y coordinates relative to a panel
x,y = GPhone.LocalToRoot( frame, x, y ) -- Return x and y coordinates relative to the root-panel
GPhone.DownloadImage( url, size, css ) -- Downloads an image from the provided URL with given size and stylesheet
GPhone.GetImage( url ) -- Gets the downloaded image or a default texture if not found or loaded
The rest of the functions in the library, while useful in some cases, should not be accessed unless absolutely needed. They are mainly used for the core parts of the phone and are undocumented for a reason.