Toggle search
Search
Toggle menu
Toggle personal menu
Editing
Modding/Templates/UI Addon
From Desynced Wiki
Read
Edit
Edit source
View history
Page
Discussion
More actions
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
__FORCETOC__ This mod template creates a custom UI overlay. == Code == === def.json === Content<syntaxhighlight lang="json"> { "id": "ModTemplateUIAddon", "name": "Mod Template UI Addon", "version_name": "1.0", "version_code": 1, "author": "The Desynced Team", "homepage": "https://www.desyncedgame.com/", "description": "Mod Template UI Addon", "packages": { "UI": { "name": "UI", "entry": "ui.lua", "dependencies": [ "Main/UI" ], "type": "Addon" } } } </syntaxhighlight> === ui.lua === Content<syntaxhighlight lang="lua"> local package = ... -- define the layout of the widget local ModSampleUI_layout<const> = [[ <Box dock=bottom padding=3> <Button text="Hello World" on_click={on_click_hello}/> </Box> ]] -- register the widget layout local ModSampleUI<const> = {} UI.Register("ModSampleUI", ModSampleUI_layout, ModSampleUI) -- called when the registered widget is created function ModSampleUI:construct() end -- called when the button is clicked function ModSampleUI:on_click_hello(btn) MessageBox("Hello World from the UI Sample") end -- called when the UI is being set up function UIMsg.OnSetup() UI.AddLayout("ModSampleUI", 9) end -- called when mod is initializing function package:init_ui() end </syntaxhighlight> {{ModdingNav}}
Summary:
Please note that all contributions to Desynced Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Desynced Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:ModdingNav
(
edit
)
Template:Navbox
(
edit
)