adding travel charge time & attack time to tooltips ?

The place to discuss scripting and game modifications for X4: Foundations.

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

Post Reply
User avatar
Whismerhill
Posts: 579
Joined: Wed, 20. Oct 04, 21:16
x3ap

adding travel charge time & attack time to tooltips ?

Post by Whismerhill » Sun, 1. Jan 23, 15:03

Hello
so I'm trying to modify the mod "equipment tooltips" https://www.nexusmods.com/x4foundations/mods/838

it's first & foremost for my own usage, but if it works, I'll propose it to the author or ask if I can release another version depending ...

What I want is to display the following data :
Travel Charge Time, Travel Attack Time, Travel Release Time

here's my temporary code some of which works, but thanks to sanity checks doesn't make everything bug out

Code: Select all

-- travel speed ? (added by whis)
    if hoveredData.travel_thrustfactor and hoveredData.travel_thrustfactor > 0 then
    	met.addToOutput(ReadText(1001, 8053),
    			hoveredData.travel_thrustfactor, --This Works in kN
    			selectedData and selectedData.travel_thrustfactor,
    			ReadText(1001, 115)
    	)
	end
	-- travel charge
	if hoveredData.TravelChargeTimeFactor then
		met.addTextLine("TravelChargeTimeFactor") -- TravelChargeTimeFactor is nil
	end
	if hoveredData.travel_chargetime and hoveredData.travel_chargetime > 0 then 
    	met.addToOutput(ReadText(1001, 11141), --travel_chargetime is nil
    			hoveredData.travel_chargetime,
    			selectedData and selectedData.travel_chargetime,
    			ReadText(1001, 115)
    	)
	end
	-- travel attack time
    if hoveredData.travel_attacktime and hoveredData.travel_attacktime > 0 then
    	met.addToOutput(ReadText(1001, 11121),
    			hoveredData.travel_attacktime, --is nil
    			selectedData and selectedData.travel_attacktime,
    			ReadText(1001, 115)
    	)
	end
	-- travel release time
    if hoveredData.travel_releasetime and hoveredData.travel_releasetime > 0 then
    	met.addToOutput(ReadText(1001, 11131),
    			hoveredData.travel_releasetime, --is nil
    			selectedData and selectedData.travel_releasetime,
    			ReadText(1001, 115)
    	)
	end
I've looked through menu_encyclopaedia.lua and there's none of those
I've searched through game unpacked source files
and in helper.lua we have the following :

Code: Select all

typedef struct {
		const char* Name;
		const char* RawName;
		const char* Ware;
		uint32_t Quality;
		const char* PropertyType;
		float ForwardThrustFactor;
		float StrafeThrustFactor;
		float RotationThrustFactor;
		float BoostThrustFactor;
		float BoostDurationFactor;
		float BoostAttackTimeFactor;
		float BoostReleaseTimeFactor;
		float BoostChargeTimeFactor;
		float BoostRechargeTimeFactor;
		float TravelThrustFactor;
		float TravelStartThrustFactor;
		float TravelAttackTimeFactor;
		float TravelReleaseTimeFactor;
		float TravelChargeTimeFactor;
	}
sidenotes: I'm editing with sublime text so it's not a full blown IDE

User avatar
Whismerhill
Posts: 579
Joined: Wed, 20. Oct 04, 21:16
x3ap

Re: adding travel charge time & attack time to tooltips ?

Post by Whismerhill » Sun, 1. Jan 23, 18:30

alright I made some progress
the struct : hoveredData does NOT contain what I'm looking for
Spoiler
Show

Code: Select all

    for key,value in pairs(hoveredData) do
    	met.addToOutput(key, 1, 1,value);
	end
this bit of code helped see what were the members of the hoveredData
so it seems the X4 base function GetLibraryEntry()
does NOT go fetch the necessary data
hummmm

User avatar
Dj_FRedy
Posts: 229
Joined: Mon, 27. Jun 11, 05:58
x4

Re: adding travel charge time & attack time to tooltips ?

Post by Dj_FRedy » Sun, 1. Jan 23, 22:51

All those keywords you point to belong to 'GetInstalledEngineMod()', a foreign function. These are properties that are retrieved from a component as installed pieces of mod. 'Helper.getInstalledModInfo()' assigns the instances which in turn are displayed in different UI menus. GetLibraryEntry() as you point out does not handle these values. Therefore, you would have to compare components with previously installed mods and the Mycu's mod does not handle such entries.
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

User avatar
Whismerhill
Posts: 579
Joined: Wed, 20. Oct 04, 21:16
x3ap

Re: adding travel charge time & attack time to tooltips ?

Post by Whismerhill » Mon, 2. Jan 23, 15:12

Dj_FRedy wrote:
Sun, 1. Jan 23, 22:51
All those keywords you point to belong to 'GetInstalledEngineMod()', a foreign function. These are properties that are retrieved from a component as installed pieces of mod. 'Helper.getInstalledModInfo()' assigns the instances which in turn are displayed in different UI menus. GetLibraryEntry() as you point out does not handle these values. Therefore, you would have to compare components with previously installed mods and the Mycu's mod does not handle such entries.
ha ...

well I'll be damned
If I understood correctly, this seems like there's no way to get engine (not mod) actual charge time, attack time & release time in game then ????

so EGOSOFT would need to introduce this themselves I suppose ?
still can't believe this is missing from the encyclopedia !

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13289
Joined: Sun, 15. Feb 04, 20:12
x4

Re: adding travel charge time & attack time to tooltips ?

Post by euclid » Mon, 2. Jan 23, 16:01

Via UI only will be tricky (if possible at all) but you could use an MD script and display the result onscreen, write it to the playerlog or save it to a global/local parameter that may be parsed to the UI (not sure about that). Check the common.xsd for

Code: Select all

 <xs:element name="event_player_travelmode_charge_started"> Event is raised when the player ship travel mode begins charging (param = time when the mode is fully charged)
Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

User avatar
Whismerhill
Posts: 579
Joined: Wed, 20. Oct 04, 21:16
x3ap

Re: adding travel charge time & attack time to tooltips ?

Post by Whismerhill » Tue, 3. Jan 23, 00:08

euclid wrote:
Mon, 2. Jan 23, 16:01
Via UI only will be tricky (if possible at all) but you could use an MD script and display the result onscreen, write it to the playerlog or save it to a global/local parameter that may be parsed to the UI (not sure about that). Check the common.xsd for

Code: Select all

 <xs:element name="event_player_travelmode_charge_started"> Event is raised when the player ship travel mode begins charging (param = time when the mode is fully charged)
Cheers Euclid

hum sorry I failed to precise it was to see the equipments' values while browsing for them in equipment docks, warfs or shipyards

so I don't think this event will help me out

IMHO EGOSOFT should add these fields and display them in the encyclopaedia

meanwhile I found a very very bad workaround
I just made a local table of engines and their parameters, directly copied from the game's files with the help of X4 editor, some smart copy paste, excel export to csv and sublime text reformatting with regular expressions and voilà ....

the good:

it works just fine here's how it looks like : https://prnt.sc/qvIIJCXtVp9B
although I made some more changes since then, such as inverting the colors red & green since the scale is reversed (e.g. lower is better instead of worse)

the bad:
it won't display any engine modified through the workshop, since it doesn't actually read the games' files
any update by egosoft to those values will require an update of the "mod"

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13289
Joined: Sun, 15. Feb 04, 20:12
x4

Re: adding travel charge time & attack time to tooltips ?

Post by euclid » Tue, 3. Jan 23, 15:21

Whismerhill wrote:
Tue, 3. Jan 23, 00:08
.....
hum sorry I failed to precise it was to see the equipments' values while browsing for them in equipment docks, warfs or shipyards
.....
meanwhile I found a very very bad workaround
I just made a local table of engines and their parameters, directly copied from the game's files with the help of X4 editor, some smart copy paste, excel export to csv and sublime text reformatting with regular expressions and voilà ....
Yes, that is a problem because the "objects" (ships, modules etc.) offered by NPCs are not really there. I'm sure you could extract those data from ships which are actually in-game. I had a similar problem once with station modules when trying to obtain information like cycle times, production volume etc., and used the same workaround by adding the corresponding data from the game files which (obviously) do not take into account workforce and sunlight. From an existing station it's possible to extract all those data.

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

User avatar
Dj_FRedy
Posts: 229
Joined: Mon, 27. Jun 11, 05:58
x4

Re: adding travel charge time & attack time to tooltips ?

Post by Dj_FRedy » Fri, 20. Jan 23, 18:59

Whismerhill wrote:
You may be interested: with update 6.00 the attributes 'charge', 'thrust', 'attack' is now retrieved by 'GetLibraryEntry()':

Code: Select all

<travel charge="x" thrust="x" attack="x" release="x" />
travel_chargetime, travel_thrustfactor, travel_attacktime
'release' is not yet retrievable, I'm afraid.
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

User avatar
Whismerhill
Posts: 579
Joined: Wed, 20. Oct 04, 21:16
x3ap

Re: adding travel charge time & attack time to tooltips ?

Post by Whismerhill » Sat, 21. Jan 23, 07:15

Dj_FRedy wrote:
Fri, 20. Jan 23, 18:59
Whismerhill wrote:
You may be interested: with update 6.00 the attributes 'charge', 'thrust', 'attack' is now retrieved by 'GetLibraryEntry()':

Code: Select all

<travel charge="x" thrust="x" attack="x" release="x" />
travel_chargetime, travel_thrustfactor, travel_attacktime
'release' is not yet retrievable, I'm afraid.
thank you very much.
Although I have a user report that my current mod is broken in v6.00beta for now :lol:

but then I have no idea if it's really my mod or the two mod dependencies that it relies on so meh no hurries to update IMHO
But I'll keep that in mind when you guyz publish a list of API changes or something

I'll still need a local table for release times but I guess it simplifies the maintenance in the future for mods or new engines.
Anyway none of that matters, thank you, again.

Post Reply

Return to “X4: Foundations - Scripts and Modding”