Skip to end of metadata
Go to start of metadata

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:

  1. ui.xml
  2. ego_detailmonitorHelper.xml
  3. 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:

<addon name="FC_Traderestriction">
  <environment type="detailmonitor">
    <file name="ui/FC_menu_traderestrictions/FC_menu_traderestrictions.lua" />
    <dependency name="ego_detailmonitorHelper" />
  </environment>
</addon>

 

meanings:

  1. environment type="detailmonitor" = That's the environment/type of monitor you are working with.
  2. file name="ui/FC_menu_traderestrictions/FC_menu_traderestrictions.lua" = Thats the path of your lua file
  3. dependency name="ego_detailmonitorHelper"= Thats the line for the depency. In my example i use the DetailmonitorHelper
  4. addon name="FC_Traderestriction" = This specifies the name of the addon.

The following code is for the detailmonitorHelper.xml:

 

<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:

 

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)

  • No labels

3 Comments

  1. Anonymous

    Code can be attached to page as files.

  2. Anonymous

    Did you forget to mention to add a folder named "FC_menu_traderestrictions" inside the "ui" folder ? im confused because your file path seems to suggest a folder "FC_menu_traderestrictions".

    <file name="ui/FC_menu_traderestrictions/FC_menu_traderestrictions.lua" />

     

    Also can you be more specific on how to do this ? for example i just wanted to change a function in the "PlatformsMenu". my target function is the "displaymenu" where it changes the fonts to red for enemies but neglected to color player owned NPCs in his station to green. i wanted to add this feature so that they are colored green and can be easy to spot against the spawned NPCs in player owned stations. how do i do that ?

  3. Anonymous

    Also how will that last code get executed ? should i add init() at the bottom ?