Community Forum

Getting the effective selling price of a fruit-type

Forum Overview >> Scripting

Created25.09.2019 18:12

Dennis Döring (Unknown) 25.09.2019 18:12
Hi everyone!

I am currently trying to write a little mod/script, that fiddles around with the current selling prices for all the fruit types available on a given map as shown on the game menu tab.

Since there isn't really any documentation on this subject and google wasn't of any help either I was hoping one of you guys can help me.

I found some scripts regarding this which were made for FS17 and sadly they don't work anymore because the structure of the global tables and functions seems to be different somehow.

So does anybody know how I can access the current selling price of a fruit-type at a given selling point?
And maybe also how to access all the available selling points on a given map. I tried fiddling around with "loadXMLFile" and then load stuff off of the "items.xml" file in the respective savegame folder which actually read all the selling points but I'm not sure if this is even of any use for what I want to do.

While testing and trying I found a function that seems to be exactly what I need "SellingStation:getEffectiveFillTypePrice()". Unfortunatelly it always spits out an error saying it would be a nil value.

Any help or info about this is greatly appreciated!


Bilbo Beutlin (BBeutlin) 25.09.2019 21:54
ahem - not very much experience, uh? *g*
Certainly you need a specified sellingStation before you can examine it.

Unluckily the g_currentMission table doesn't have a reference to sellingStations, so you must browse through the unloadingStations:
----- code -----
for _,station in pairs(g_currentMission.storageSystem.unloadingStations) do
- test for sellingStation
if station.isSellingPoint ~= nil and station.isSellingPoint == true then
- now you can examine the station, eg. to get the price for a certain fillType
local price = station.fillTypePrices[fillTypeIndex]
- or with concrete functions station:anyFunction(..)

There are much more interesting trade infos. I'd suggest you examine a few sellingStation tables.

Dennis Döring (Unknown) 25.09.2019 22:49
You got me, I'm a complete beginner when it comes to scripting or modding in FS. Also I never touched LUA before. But I do have quite a good understanding of coding in general and especially in C#.

I figured, that I'd need some kind of instance of the particular SellingStation in order to get my prices, since there can't be just one SellingStation-object when there are multiple in the ingame menu list with different prices.


you are my absolute hero! I have been trying to get something to work for the last week and just couldn't figure out how to get a working instance of a SellingStation. Now I got it working after 5 minutes ;)

Thank you sir!

Note: Log in to post. Create a new account here.