On this page I will describe how to replace a vanilla menu with your own. For example I will change the traderestrictionsmenu
At first you should create the following things in your mod folder:
- ui.xml
- ego_detailmonitorHelper.xml
- A Folder which is named ui
Now copy the traderestrictions.lua in your folder ui and rename it. For example in my case I named it FC_traderestrictions.lua.
Now we begin with the modding. We create the ui.xml and the ego_detailmonitor.xml
The following code is for the ui.xml:
Code Block |
---|
<addon name="FC_Traderestriction"> <environment type="detailmonitor"> <file name="ui/FC_menu_traderestrictions/FC_menu_traderestrictions.lua" /> <dependency name="ego_detailmonitorHelper" /> </environment> </addon> |
meanings:
- environment type="detailmonitor" = That's the environment/type of monitor you are working with.
- file name="ui/FC_menu_traderestrictions/FC_menu_traderestrictions.lua" = Thats the path of your lua file
- dependency name="ego_detailmonitorHelper"= Thats the line for the depency. In my example i use the DetailmonitorHelper
- addon name="FC_Traderestriction" = This specifies the name of the addon.
The following code is for the detailmonitorHelper.xml:
Code Block |
---|
<addon name="ego_detailmonitorHelper" viewtype="detailmonitor"> <file name="ui/FC_menu_traderestrictions/FC_menu_traderestrictions.lua" /> </addon> |
The following Codelines are to delete the old menu:
Code Block | ||
---|---|---|
| ||
local FC_menu = {} local Funcs = {} local function init() for _, menu in ipairs(Menus) do if menu.name == "TradeRestrictionsMenu" then -- Hier steht das Menu das ihr ersetzen möchtet /Here the name of the menu you want to replace FC_menu = menu menu.cleanup = Funcs.FC_cleanup -- Neue Definitionen für euer Menü/ New definitions for your own menu menu.buttonTradeRestriction = Funcs.FC_buttonTradeRestriction menu.buttonWareRestriction = Funcs.FC_buttonWareRestriction menu.buttonRestriction = Funcs.FC_buttonRestriction menu.onShowMenu = Funcs.FC_onShowMenu menu.showMenu = Funcs.FC_showMenu menu.onUpdate = Funcs.FC_onUpdate menu.onRowChanged = Funcs.FC_onRowChanged menu.onSelectElement = Funcs.FC_onSelectElement menu.onCloseElement = Funcs.FC_onCloseElement break end end end |
After deleting the old menu you can add your own code after that. For examples please write a PN to me FindolCaleb at the Egosoft Forum ( because the maincode is too long for this page)