[MOD] Sidebar Extender

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Phipsz
Posts: 334
Joined: Mon, 23. Apr 12, 23:56
x4

[MOD] Sidebar Extender

Post by Phipsz » Fri, 12. Sep 14, 18:45

So, this is already known I think, but I've been requested to put the HowTo for this mod here as well, so here it goes:

This mod enables the use of a generic menu system in 2.5(+?). For examples see the example files (folder "SideBarExamples").
Basic instruction: create a file named "mainmenuEntriesTop.lua" or "mainmenuEntriesTop.txt" in the main folder of the extension for adding entries to the top part of the menu (that's where most of it should go) and/or a file named "mainmenuEntriesBottom.lua"/"mainmenuEntriesBottom.txt" respectively for adding entries to the lower part of the menu.
Note: use the file extension .txt when uploading your mod to the Steam WorkShop, as .lua will not(!) be recognised by X:Rebirth anymore when packed in .cat .

basic syntax:

Code: Select all

local d = {}
d[0] = {
    category = "info",
    insertions = {{
        section = "",
        icon = "",
        sectionparam = {},
        condition = true,
        name = ReadText(x, x),
        info = ReadText(x, x),
        list = {}
        }
    }
}

return d
  • category must be one of the following:
    • modes
    • info
    • missions
    • navigation
    • communication
    • trading
    • crew
    • drones
    • new
  • section is the md section to start
  • sectionparam is a list containing parameters for the section that is to be started
  • icon may contain one of the following (or any entry named in libraries/icons.xml")
    • mm_ic_comm, mm_ic_comm_crewforplayer, mm_ic_comm_crewforcapship, mm_ic_comm_crewforstation, mm_ic_comm_specialistforstation,
    • mm_ic_comm_trader, mm_ic_comm_services, mm_ic_comm_missioncontacts,
    • mm_ic_modes, mm_ic_modes_stationscan, mm_ic_modes_cargo, mm_ic_modes_mining, mm_ic_modes_shipscan, mm_ic_modes_longrangescan,
    • mm_ic_modes_stop,
    • mm_ic_crew, mm_ic_crew_callremotely, mm_ic_crew_exitplatform, mm_ic_crew_entercockpit, mm_ic_crew_enterbackroom
    • mm_ic_info, mm_ic_info_mystatus, mm_ic_info_propertyowned, mm_ic_info_shipstatus, mm_ic_info_logbook, mm_ic_info_enyclopedia,
    • mm_ic_info_missionmanager,
    • mm_ic_navig, mm_ic_navig_galaymap, mm_ic_navig_systemmap, mm_ic_navig_sectormap, mm_ic_navig_zonemap
    • mm_ic_trading,
    • mm_ic_options,
    • mm_ic_hide
  • condition (bool) disables the entry if false
  • list marks subentries, see example files
  • insertions contains the list that is to be inserted.
Of course you can execute whatever code you want in that file, to be inserted into the menu you just have to return a table in the specified format. (table being the lua name for associative arrays/dict/list)
Can be found at SteamWorkshop
Last edited by Phipsz on Mon, 15. Sep 14, 18:42, edited 1 time in total.

User avatar
NZ-Wanderer
Posts: 1623
Joined: Thu, 5. Aug 04, 01:57
x4

Post by NZ-Wanderer » Sat, 13. Sep 14, 02:38

You have just made our modders lives a lot easier, thank you :)
Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth

NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.

Phipsz
Posts: 334
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Mon, 15. Sep 14, 18:44

Just uploaded the new version to steam, is now compatible to version 2.5b7. Thanks to cyberfuzzie here, as I am now using his more generic approach. The extender should now be compatible also to future updates, except if these change the order of the menu entries

User avatar
TheRealBix
Posts: 400
Joined: Thu, 2. Jul 09, 14:34
x4

Post by TheRealBix » Wed, 26. Nov 14, 05:32

Your tool sounds really nice, but the menu I want to show seems to be shy..

I'm trying to make PlayerJump (from Euclid) working with the sidebar.

What he did :

Code: Select all

<cue name="EuclidsJ0" instantiate="true" namespace="this">
		<conditions>
		 <check_any>
			<event_conversation_next_section sectionprefix="gMainNav_main" />	
			<event_conversation_returned_to_section sectionprefix="gMainNav_main" />
		 </check_any>
		</conditions>
	   <actions>
		  <add_player_choice_sub text="'Jump Menu'" section="gJumpMenu"/>
		 </actions>										
	  </cue>
	 
	 <cue name="EuclidsJ1" instantiate="true" namespace="this">
		<conditions>
		 <check_any>
			<event_conversation_next_section sectionprefix="gJumpMenu" />	
			<event_conversation_returned_to_section sectionprefix="gJumpMenu" />
		 </check_any>
		</conditions>
	  <actions>
		 <add_player_choice_sub text="'Mark position'" section="g_MarkPos"/>
		 <do_if value="global.$PlayerPos">
		  <add_player_choice_sub text="'Jump to position'" section="g_JumpPos"/>
		 </do_if>
		 <add_player_choice_sub text="'Jump to Zone'" section="g_JumpZone" choiceparam="[0, 0, 'sector', player.primaryship.sector, null, null, 'selectzone',  ['gOrders_selectedZone']]"/>
		</actions>										
	  </cue>
What I did :

Code: Select all

local d = {}
d[0] = {
    category = "navigation",
    insertions = {{
    section = "gJumpMenu",
    icon = "mm_ic_options",
    name = "Jumpdrive",
    info = "Use the jumpdrive to cross large distances instantly",
    list = {
          {
            section = "g_MarkPos",
            icon = "mm_ic_info",
            name = "Mark position",
            info = "Save your current coordinates, so that you'll be able to jump here in the future"
          },
          {
            section = "g_JumpPos",
            condition = global.$PlayerPos,
            name = "Jump to position",
            info = "Jump on your saved position"
          },
         {
            section = "g_JumpZone",
            name = "Jump to zone",
            info = "Select a zone to jump on"
         }
         }
		
        }
        }
    }
}

return d 
So.. I did something wrong, but what ?

Phipsz
Posts: 334
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Thu, 27. Nov 14, 00:16

hm, a tricky one... first, you don't need the "section" in the main part, I don't think it's an error but never hurts to be sure :) the second one is illegal lua and hides the menu: "condition = global.$PlayerPos"... the "global" sadly doesn't work like that here, as that would be no legal lua in that case... sadly, I don't know how to get global variables in lua yet... only thing I know is to get npc blackboard variables... if the "$PlayerPos" was not stored via "global." but "player." instead, you could set

Code: Select all

condition = GetNPCBlackboard(GetComponentData(GetPlayerPrimaryShipID(), "owner"), "$PlayerPos")
but that would mean to change all references on "global.$PlayerPos" to "player.$PlayerPos"... a far more easy but not that nice solution would be to just strip all the options off the sidebar and use the base menu:

Code: Select all

local d = {}
d[0] = {
    category = "navigation",
    insertions = {{
        section = "gJumpMenu",
        icon = "mm_ic_options",
        name = "Jumpdrive",
        info = "Use the jumpdrive to cross large distances instantly"
    }}
}

return d 

User avatar
TheRealBix
Posts: 400
Joined: Thu, 2. Jul 09, 14:34
x4

Post by TheRealBix » Thu, 27. Nov 14, 03:18

Thank you !!

In fact you're right it's far easier to create a shortcut to the old menu. So now the mod can work with the sidebar.

What I want now, and from the beginning (when I've been dropped out from a highway at 23000km of the zone..), is to create a shortcut to jump out immediately if a similar bug happens (a debug option actually).

So what I did is :

Code: Select all

local test = {}
test[0] = {
    category = "navigation",
    insertions = {{
        section = "gJump",
        icon = "mm_ic_options",
        name = "Jumpdrive",
		sectionparam = {
		0,
		0,
		"sector",
		GetNPCBlackboard(GetComponentData(GetPlayerPrimaryShipID(), "owner"), "sector"),
		null,
		null,
		"selectzone",
		gOrders_selectedZone
		},
        info = "Use the jumpdrive to cross large distances instantly"
				
		}
        }
    }

return test 
But it seems that the last parameter 'gOrders_selectedZone' isn't taken in count as the jump doesn't work :/
Any idea ? (sorry for those newbie questions :roll: )

Phipsz
Posts: 334
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Mon, 1. Dec 14, 00:01

Don't know for sure, as I don't use the PlayerJump :roll: but replacing gOrders_selectedZone with

Code: Select all

{"gOrders_selectedZone"}
should do the trick. PlayerJump seems to expect a section as string in a list, so that would resolve the jump I guess
oh, and change null to nil, that's the one used in lua :)
and one more thing: for retrieving the player sector you would use

Code: Select all

GetComponentData(GetPlayerPrimaryShipID(), "sector")
you try to get a variable named "sector" from player, which doesn't exist

User avatar
TheRealBix
Posts: 400
Joined: Thu, 2. Jul 09, 14:34
x4

Post by TheRealBix » Mon, 1. Dec 14, 05:09

Thanks a lot teacher ! :lol:

My last question (I swear ^^) would be : how to call a cue through a lua shortcut ?

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Mon, 1. Dec 14, 13:41

TheRealBix wrote:Thanks a lot teacher ! :lol:

My last question (I swear ^^) would be : how to call a cue through a lua shortcut ?
I'm not certain that you can directly trigger an MD cue from within a piece of Lua code. All MD scripts seem to be triggered from the return parameters of the Lua script.

Remember though that you can have MD scripts that trigger on a generic stub and then add a suffix to this stub which the MD cue can interrogate and execute statements conditionally. Probably easier to explain with a bit of code:

Code: Select all

		<cue name="SectionHandler_MT_WarpPlayer" instantiate="false" namespace="this">
			<conditions>
				<check_any>
					<event_conversation_next_section sectionprefix="gMT_tools_WarpPlayerShip" />
					<event_conversation_returned_to_section sectionprefix="gMT_tools_WarpPlayerShip" />
				</check_any>
			</conditions>
			<actions>
				<do_if value="event.param == 'gMT_tools_WarpPlayerShip'">
					<open_conversation_menu menu="MapMenu" param="[0, 0, 'sector', player.primaryship.sector, null, null, 'selectzone', ['gMT_tools_WarpPlayerShip_zoneselected']]" />
					<add_conversation_view view="closeupdetailmonitor" />
					<debug_text text="'MT MOD TOOLS: Next section: ' + event.param + '  ' + event.param2" />
				</do_if>
				<do_elseif value="event.param == 'gMT_tools_WarpPlayerShip_zoneselected'">
					<debug_text text="'MT MOD TOOLS: Next section: ' + event.param + '   ' + event.param2" />
					<debug_text text="'MT MOD TOOLS: WE HAVE SUCCESSFULLY CALLED THE NEXT SECTION:'" />
					<debug_text text="'MT MOD TOOLS: The zone selected was:  ' + event.param2.{3}.name" />
					<speak actor="player.entity" priority="0">
						<text line="103081" comment="[Ren]: I'm getting us out of here!" />
					</speak>
					<warp object="player.primaryship" zone="event.param2.{3}" />
				</do_elseif>
				<reset_cue cue="this" />
			</actions>
		</cue>
This is an exerpt from a little tool I wrote to allow me to insta-warp anywhere in the galaxy. The menu (Lua) entry looks like:

Code: Select all

	{
		section = "gMT_tools_WarpPlayerShip",
		icon = "engineer_active",
		name = "Warp Player to new location",
		condition = true,
		sectionparam = { 0, 0 },
		info = "Experimental - use with caution!"
	},
Note here that I am passing the value to be returned into the holomap lua code (took me a good while to figure that one out :D )
So the menu entry triggers the script to open up the holomap - the script then resets ready to handle the return param from the holomap. Once a zone is selected the cue returns with 'gMT_tools_WarpPlayerShip_zoneselected' and executes the second conditional branch that actually does the warping. Note here that I could have maybe just as easily signalled another MD script to fire which would probably achieve what you're trying to do.

The final trick I have used which may help is that you can easily trigger a dummy menu from the MD code if you want to do something in Lua that you can't do in XML/MD scripting. As a trivial example here's some code that executes a Lua "schedulereloadui()" command from the menu bar:

Code: Select all

	{
		section = "gMT_tools_ReloadUI",
		icon = "engineer_active",
		name = "Reload User Interface",
		condition = true,
		sectionparam = { 0, 0 },
		info = "Experimental - use with caution!"
	},
and the associated MD script excerpt:

Code: Select all

		<cue name="SectionHandler_MT_ReloadUI" instantiate="false" namespace="this">
			<conditions>
				<check_any>
					<event_conversation_next_section sectionprefix="gMT_tools_ReloadUI" />
					<event_conversation_returned_to_section sectionprefix="gMT_tools_ReloadUI" />
				</check_any>
			</conditions>
			<actions>
				<speak actor="player.computer" priority="0">
					<text line="131" comment="[Betty]: Affirmitive" />
				</speak>
				<open_conversation_menu menu="gMT_ReloadUI"/>
				<!-- Reset our cue for the next time -->
				<reset_cue cue="this" />
			</actions>
		</cue>
And finally the dummy Lua script that executes to reset the UI:

Code: Select all

-- Schedule a reload of the UI
-- Set up the default menu table
local menu = {	
	name = "gMT_ReloadUI",
}

-- Standard menu initialiser - initialise variables global to this menu here if needed
local function init()
	Menus = Menus or {}

	table.insert(Menus, menu)

	if Helper then
		Helper.registerMenu(menu)
	end

	return
end

-- Standard Menu cleanup utility - place all variables no longer needed in here and assign the value nil to them
menu.cleanup = function ()
	return
end

-- Simply exit the menu and schedule a reload of the UI
menu.onShowMenu = function ()
	Helper.closeMenuAndCancel(menu)
	menu.cleanup()
	ScheduleReloadUI()
	return
end

init()

return
Hope this helps - I'm not near the game just now and been so busy at work that I did this stuff quite a while ago so it's a bit rusty inside my old brain!

Cheers
Wysi :)

Drag00nFighter
Posts: 74
Joined: Wed, 7. Dec 05, 20:33
x4

Post by Drag00nFighter » Wed, 3. Dec 14, 17:16

Since update yesterday to 3.06 Beta, no mods using SideBar-Extender are functional ingame. Think problem is in SBE.

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Wed, 3. Dec 14, 17:31

Drag00nFighter wrote:Since update yesterday to 3.06 Beta, no mods using SideBar-Extender are functional ingame. Think problem is in SBE.
The problem is a change in naming convention adopted by Egosoft and relating to all mods that reference the addon capability of the UI.

http://forum.egosoft.com/viewtopic.php?t=374367

Phipsz
Posts: 334
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Wed, 3. Dec 14, 23:01

Darnit... could anyone possibly tell me what I would have to change? I'm sadly not using the beta yet... I would get the beta and try myself this weekend otherwise

User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg » Wed, 3. Dec 14, 23:13

If I understand correctly your mod simply replaces Egosoft's mainmenu.xpl file with your own. Just make your mainmenu.xpl file sit in a folder called:

Code: Select all

ui\addons\ego_mainmenu\
This should fix the issue caused by the renaming. Note it will probably break the mod for pre beta 6 users.

No need to change any of the code inside the .lua file as far as I can tell unless you want to include any new features (if any) found in Ego's v3.0 mainmenu.

EDIT: If I get time tomorrow I'll have a play around and see if this works.

Phipsz
Posts: 334
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Sun, 7. Dec 14, 01:36

sooo, I think I patched it, and I sincerely hope I didn't break it for non-beta users :sceptic: and thanks to dragoon for fixing it! (you are the dragoon who posted on the workshop site, right? :) )

D.O.S.
Posts: 403
Joined: Wed, 6. Nov 02, 20:31
x4

Post by D.O.S. » Thu, 19. Feb 15, 20:23

Sorry to say but it looks like 3.50 Beta 1 has broke this mod
OS:MS Windows 10 Pro x64 / Cpu: AMD-FX Piledriver 8350 @4.0Ghz / Mb:GA-990FXA-UD3 / Memory:16Gb DDR3 Crucial Ballistix Tactical @1866
Gpu:Gigabyte Nvidia 770GTX 4GB GDDR5 / Storage:Crucial RealSSD M4 128GB System, WD Caviar Green 2TB HD Data & Games / Display:24" Asus VG248 1920 x 1080 @144Hz + Nvidia 3D Vision Kit
Input Devices:Razer Deathstalker / Razer Oruoboros / Thrustmaster Hotas Warthog / BroadBand:EE 4GEE MobileBroadBand (50Gb PCM)

Phipsz
Posts: 334
Joined: Mon, 23. Apr 12, 23:56
x4

Post by Phipsz » Sat, 21. Feb 15, 02:31

D.O.S. wrote:Sorry to say but it looks like 3.50 Beta 1 has broke this mod
I'll fix when I get some more free time. will possibly not be this weekend sadly

crackgrahamer
Posts: 6
Joined: Mon, 21. Apr 14, 22:34
x3ap

Post by crackgrahamer » Tue, 13. Oct 15, 18:42

I'm no good at this modding stuff so I'm plainly asking if someone with this mod could post the base game's sidebar. Installed the mod so I could use the exploration software since Scouting all the stations is wasteful ingame and real time life, But now I have no sidebar which makes the game unplayable.
meh is understood to be a shoulder shrug.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Tue, 13. Oct 15, 18:53

Sidebar is Vanilla Content - do you use the legacy Main Manu by chance?
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Vim Razz
Posts: 1842
Joined: Tue, 2. Nov 10, 02:20
x4

Post by Vim Razz » Tue, 13. Oct 15, 19:36

The variants of UniTrader's own Station Leave that move Yisha on and off the skunk with the rest of the crew can break the sidebar menu, but I'm not aware of anything else that can.

crackgrahamer
Posts: 6
Joined: Mon, 21. Apr 14, 22:34
x3ap

Post by crackgrahamer » Tue, 13. Oct 15, 20:17

Just to get some of the information out there I install via steam workshop and I don't use legacy Main Menu, but I do use: (listing them all)
-side bar extender
-exploration software
-Ledda Industrial Constrcution Shop
-Canteran Refinery Ship (produces reinforced metal plates)
-Innes Library Scripts
-LibMJ - MajJoker's Library Scripts
-UFO - Ultimate Fleet Overhaul
-Vanoefim's Jump Drive for Skunk (cheat version)
-Scaldis Cargo Fix
-Ledda Ship Tech Fab Fusion Reactors
-hull repair laser
-repack construction vessel
-Nonstop
-Ship Classifciation Names v2
-Black Market Seminars
-Remotely Call Crew in Space
-Player Shipyards and Enhancements (Merged Multimod)
-NPCs on your Stations!
-Trade Menu Cargo Hold Filter
-no Jump Fuel for Player Ships
-Speedy Delivery
-Show Skills
-revealthingz
-Player Shipyards
-More Crew
-Extra Builder Cargo
-Autolooter
-Boarding Options

I only chose to install side bar extension when (today) i finally actually read what the red meant for software exploration mod not working. So today is the first time I ran into this problem.
meh is understood to be a shoulder shrug.

Post Reply

Return to “X Rebirth - Scripts and Modding”