Creating Apps: Difference between revisions
Jump to navigation
Jump to search
Line 3: | Line 3: | ||
<syntaxhighlight lang="lua" lines> | <syntaxhighlight lang="lua" lines> | ||
app = { | app = { | ||
name = " | name = "Example App", | ||
description = " | description = "How to make your first app for Off Grid.", | ||
cost = 2 | cost = 2, | ||
targets = { | targets = {TargetType.Data}, | ||
showInRadial = | showInRadial = AppMenuState.target, | ||
showInAppWheel = | showInAppWheel = AppMenuState.byDefault, | ||
state = | state = AppState.off, | ||
icon = " | icon = "ExampleApp.png", | ||
iconColor = { | iconColor = Color.Blue, | ||
statusIcons = { "option1.png", "option2.png"}, | |||
actions = { | actions = { | ||
{ | { | ||
name = " | name = "DefaultAction", | ||
run = function(target) | run = function(target) | ||
-- In 3rd person mode executing app will always trigger first action | |||
end, | |||
}, | |||
{ | |||
name = "ExtraAction", | |||
run = function(target) | |||
-- In radial menu mode if there's more than one action, triggering the app opens a popup menu to select which action to take. | |||
end, | end, | ||
}, | }, | ||
Line 28: | Line 30: | ||
options = { | options = { | ||
someOption = { | |||
name = "Some option", | |||
enabled = true, | |||
}, | |||
anotherOption = { | |||
name = "Some other option", | |||
enabled = false, | |||
OnOptionChange = function() | |||
-- This runs when the option is toggled. | |||
end | |||
}, | |||
}, | }, | ||
Update = function(time) | |||
-- Update will run regularly when the app is switched on- | |||
end, | |||
OnStateChange = function(state) | OnStateChange = function(state) | ||
-- This runs when something on game side asks the app to change it's state | |||
app.state = state | app.state = state | ||
SetState(app.state) | SetState(app.state) | ||
end, | end, | ||
UpdateActions = function(target) | UpdateActions = function(target) | ||
-- If you want to change available actions based on the target player has selected, do it here. | |||
end, | end, | ||
Revision as of 14:35, 7 November 2018
Example Lua script
app = { name = "Example App", description = "How to make your first app for Off Grid.", cost = 2, targets = {TargetType.Data}, showInRadial = AppMenuState.target, showInAppWheel = AppMenuState.byDefault, state = AppState.off, icon = "ExampleApp.png", iconColor = Color.Blue, statusIcons = { "option1.png", "option2.png"}, actions = { { name = "DefaultAction", run = function(target) -- In 3rd person mode executing app will always trigger first action end, }, { name = "ExtraAction", run = function(target) -- In radial menu mode if there's more than one action, triggering the app opens a popup menu to select which action to take. end, }, }, options = { someOption = { name = "Some option", enabled = true, }, anotherOption = { name = "Some other option", enabled = false, OnOptionChange = function() -- This runs when the option is toggled. end }, }, Update = function(time) -- Update will run regularly when the app is switched on- end, OnStateChange = function(state) -- This runs when something on game side asks the app to change it's state app.state = state SetState(app.state) end, UpdateActions = function(target) -- If you want to change available actions based on the target player has selected, do it here. end, }
App configuration
App Table | ||
---|---|---|
Name | Required/Optional | Description |
name | required | Name of the app |
description | required | Short description of what the app does |
cost | optional | How many seconds the tracking progress increases when using this app |
targets | optional | List of what target types the app can have |
showInRadial | optional | How the app should be displayed in Radial menu. See menu options. |
showInAppWheel | optional | How the app should be displayed in the AppWheel. See menu options. |
state | required | Current state of the app. |
icon | required | Path to icon image |
iconColor | optional | background color for the app icon |
OnClickAppWheel | optional | The function to run when the app is launched from the AppWheel |
OnClickRadial | optional | The function to run when the app is launched from the radial menu |
Target types
targets = {TargetType.Data, TargetType.Hackable},
Name | value | Description |
---|---|---|
None | 0 | No target. USe for apps which don't require any target at all. |
Data | 1 | Any data points currently visible to the player |
Interaction | 2 | Physical interactions in the levels |
Hackable | 4 | Hackable devices in player's current networks |
Character | 8 | People |
Menu options
Name | Description |
---|---|
always | App is always displayed in this menu. |
never | App will never be shown in this menu |
default | App will be set as favourite for this menu by default |
target | App will always display in Radial menu if current target matches the App's targets value. |
States
Name | Description |
---|---|
unavailable | The player doesn't have this app yet |
disabled | App can't be used at the moment, for example no network connection |
off | "App is not doing anything |
on | App is switched on and running in the background |
alert | "App displays alert to notify the player about something |