-
Notifications
You must be signed in to change notification settings - Fork 1
The Basics
To start creating apps for the phone, you need a file to place your code in. You have a couple of options.
- You can place code in
lua/gpapps/
to have the apploader load and distribute them automatically - You can place code in any clientside lua directory and use
GPhone.AddApp(name, table)
to add it manually - You can place code in
data/gphone/apps/
as .txt files, though this only works ifgphone_csapp
is enabled and they will only be available to you
If you choose to place code in lua/gpapps/
or data/gphone/apps/
, the APP-table will be made automatically and the apploader will load it accordingly. This makes it easier if your addon adds a lot of Apps and you need them to be organized.
This is how an app-file could look if it was placed in one of the above directories.
APP.Name = "TestApp"
APP.Negative = true
APP.Icon = "vgui/icons/testicon.png"
APP.Run = function(frame, w, h, ratio)
print("it just works")
end
On the other hand if you're looking to add a single app it might be easier to use the GPhone.AddApp
function.
This can be done from any clientside lua file and will refresh automatically (if you have lua refresh enabled), unlike the other methods.
The above app-file could thus be written as follows, if it was placed in a clientside environment.
local APP = {} -- Note that the APP-table needs to be defined manually
APP.Name = "TestApp"
APP.Negative = true
APP.Icon = "vgui/icons/testicon.png"
APP.Run = function(frame, w, h, ratio)
print("it just works")
end
GPhone.AddApp( "testapp", APP ) -- We manually add it here
An important thing to remember is that Apps loaded via the apploader are not automatically updated if the code has changed. You'll have to do that manually using the gphone_reloadapps
command or pressing the 'Reload Apps' button in the sandbox Admin Settings. Likewise, Apps are not closed when refreshing the code, you'll have to do that manually in the Appscreen.
When encountering errors in your code the bugreporter may appear on screen. Do NOT send a bugreport with your error unless it's something that's clearly wrong with the addon itself and not your app. After attempting to fix the error you should always use gphone_log_wipe
and run your code again. If the log encounters the same error multiple times it will NOT write it in the log, and thus won't appear as a new error, even though your code still doesn't work as intended.
- Make sure the error log is empty, as you are starting fresh, old logs will just get in the way
- Change something in the code, like adding a new panel or intended feature
- Close the App from the Appscreen (If it's not an app just skip this step)
- Use
gphone_reloadapps
or the corresponding button in the Admin Settings - Run the App or code again
- If an error occurs close the bugreporter and check through your code and attempt to fix the error