[LUA][question] getting the average price of an equipment item

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

[LUA][question] getting the average price of an equipment item

Post by Whismerhill » Sun, 15. Jan 23, 23:40

Hello,
so I have an idea, I want the player to be able to know the average price of equipment while buying or upgrading ships

so for that purpose I'm looking for a function that returns for example :
  • for ARG M Ion Blaster Mk1
  • 56 Advanced Electronics
  • 10 Energy Cells
  • 77 Weapon Components
I've looked for a while at the encyclopedia LUA but so far I haven't made much progress in understanding how to get that information.

then I'll probably be able to use GetWareData() to get the average price of wares & then it's just a bit of math.

Thanks for reading.

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

Re: [LUA][question] getting the average price of an equipment item

Post by Dj_FRedy » Mon, 16. Jan 23, 11:32

Yes, you can use 'GetWareData()'. If the attributes are present in 'wares.xml':

Code: Select all

 <price min="x" average="x" max="x" />
you can retrieve it using the keys:

Code: Select all

 "minprice", "avgprice", "maxprice"
You can check more keys in the wiki, although they are not all there, as a reference it's nice to have a starting point:
Link to egosoft wiki: https://www.egosoft.com:8444/confluence ... %0AReturns
"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: [LUA][question] getting the average price of an equipment item

Post by Whismerhill » Mon, 16. Jan 23, 18:00

Dj_FRedy wrote:
Mon, 16. Jan 23, 11:32
Yes, you can use 'GetWareData()'. If the attributes are present in 'wares.xml':

Code: Select all

 <price min="x" average="x" max="x" />
you can retrieve it using the keys:

Code: Select all

 "minprice", "avgprice", "maxprice"
You can check more keys in the wiki, although they are not all there, as a reference it's nice to have a starting point:
Link to egosoft wiki: https://www.egosoft.com:8444/confluence ... %0AReturns
ho thank you didn't realize I could use getwaredata() directly on say engine_ter_l_travel_01_mk1 for example
I guess that's much simpler then
also had to use getmacrodata() to get the wareID ("ware") from the macro

Thanks a ton. that simplified my work by a lot

Post Reply

Return to “X4: Foundations - Scripts and Modding”