-
Notifications
You must be signed in to change notification settings - Fork 2
Example App
The Fern edited this page Apr 22, 2018
·
19 revisions
Let's imagine the following code is placed in "garrysmod/addons/myapp/gpapps/testapp.lua". The GPhone will automatically add it to the App-list once the map loads.
APP.Name = "TestApp" -- The name of the App
APP.Author = "TesterChester" -- The author's name
APP.Negative = false -- Whether the App should use negative top-colors or not
APP.Fullscreen = false -- Whether the App runs in fullscreen or not
APP.Icon = "https://example.com/icon.png" -- The icon. Can point to a local file or an online file
function APP.Run( frame, w, h ) -- Called when the App is first opened (frame, width, height)
function frame:Paint( x, y, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 200, 200, 200, 255 ) )
end
local button = GPnl.AddPanel( frame, "button" ) -- Creates a panel of type "button"
button:SetPos( 32, 32 )
button:SetSize( w - 64, 64 )
button.Color = Color( 0, 255, 0 ) -- Green color
function button:Paint( x, y, w, h )
draw.RoundedBox( 0, 0, 0, w, h, button.Color ) -- Paint the button using the color
end
function button:OnClick() -- Called when we click
button.Color = Color( 255, 0, 0 ) -- Red color
end
end
function APP.Think( frame, w, h ) -- Called every time the SWEP.Think function is called
print("thonk")
end
function APP.Stop( frame ) -- Called when the App is closed
print("closed")
end
This App obviously doesn't do that much, but you could practially do anything GLua allows if you are willing to put in the work.