After a more thorough look at your script i noticed a few things :
- You have made the price/kw increase through the years where it should be the other way around. A loc B with the same stat as loc A but available 10 years later will cost more. It seems to me that it make no sense for the reason i explained a few posts ago. As technology evolve, maintenance cost for the same power should decrease, or we are running backward.
- If you want an "universal" script it seems to me that you will have to avoid using the multiple unit condition. Because there is some mods with multiple units available as single units and the price would be wrong.
I think loc with capacity entry should not be treated differently than loc without. I mean, a loc with 4000kw, a vmax of 200 and 50 passengers should be treated as a loc with the same power + a coach with a capacity of 50.
It can be easily be done from your script with something like that :
local cost.price = 0
local maintenance.cost = 0
.......
if engineType
....
cost.price = cost.price + (Vmax * PriceMultiplier + Power * value.powerMultiplier) * priceFactor
maintenance.price = data.metadata.cost.price * CostMultiplier * costFactor
end
if transportType == "PASSENGERS"
.....
cost.price = cost.price + payload * PriceMultiplier * priceFactor
maintenance.price = maintenance.price + data.metadata.cost.price * CostMultiplier * costFactor
end
if cost.price != 0 and maintenance.price != 0 -- just in case we miss something
then
data.metadata.cost.price = cost.price
data.metadata.maintenance.runningCosts = maintenance.price
end
Alles anzeigen
You should exclude everything that is not vehicleType == "RAIL" from the start to avoid any error and accelerate script execution.
- The problem with the TGV price is not related to the fact that this is an EMU, but because of the max speed. If my quick calculation are right, having the max speed go from 200 to 300km/h make the maintenance cost skyrocket. And the TGV being nothing more than two loc with a bunch of coaches in between you double an already really high price. This is related to the fact that the major part of your cost calculation is based on speed instead of power. This mean that a 4400kw/300km/h loc will cost almost the same price as a 8800kw/300km/h loc.
An idea to solve this problem would be to use a ratio between power and max speed. A loc working alone would have high power / speed ratio while engine for EMU would have a low power / speed ratio. We would need a formula that tend toward 1 when the ratio is high and toward 0 when the ratio is low. The ideal would be that for the TGV example, the price of the two 4400kw / 300km/h loc cost a just a bit more than a single 8800kw/ 300km/h loc. In the case of my Z8100 the price of the 4x 700kw engine should also be a bit more than a single 2800kw loc.
Zitat von Xanos
At the end, a multiple unit is just a preconfigured "train"... So in fact it is like a normal train that you compose yourself. I don't see a problem in handling all parts of a multiple unit seperately. Especially, as some parts of multiple units can also be bought as a single parts.
It should not matter if you buy a multiple unit which consists of models A,B,C or create a train manually out of A,B,C. The file defining the multiple unit has no information about costs, power, etc of the multiple unit. These information are just taken from each individual model file.
I'm currently at work so I can't test it but isn't it possible to just loop through all models and calculate there prices regardless if there have a multipleUnitOnly tag or not?
Sorry i didn't see your post before posting mine. I agree with you. The problem in the current formula, as i tried to explain above, is that the part of the formula not proportionnal to power is too important, making multiple low power units a lot less interesting than a single high power unit. Multiple Unit being often in the first case, it make their price skyrocket very quickly.