Industry Confusion
Moderator: OpenTTD Developers
Industry Confusion
Another question. I have decided to start playing with transporting some industries, and I have run into a little issue. At first I wanted to just transport some coal between stations, but remembered that with NewGRF, CargoID' could be overwritten. No problem then, I would start and develop something that handles that possibility. But here is my problem. How do you determine what kind of vehicle to use to deliver a CargoID from station to station?
For instance, the only CargoID I could find was for bulk. But that could be Coal or Ore, which use different vehicles and are accepted by very different locations. How do I determine the different bulk items? I do not want to look at the label, as that would cause more problems in the future.
What am I not seeing? I am sure I am overlooking it.
Thanks,
MarkS
For instance, the only CargoID I could find was for bulk. But that could be Coal or Ore, which use different vehicles and are accepted by very different locations. How do I determine the different bulk items? I do not want to look at the label, as that would cause more problems in the future.
What am I not seeing? I am sure I am overlooking it.
Thanks,
MarkS
Re: Industry Confusion
You can use AIEngine.CanRefitCargo (EngineID engine_id, CargoID cargo_id)
Re: Industry Confusion
Yexo wrote:You can use AIEngine.CanRefitCargo (EngineID engine_id, CargoID cargo_id)
But would the CargoID of Coal and Ore be the same? That is what is throwing me.
enum AICargo::CargoClass
The classes of cargo (from newgrf_cargo.h).
Enumerator:
CC_PASSENGERS Passengers.
CC_MAIL Mail.
CC_EXPRESS Express cargo (Goods, Food, Candy, but also possible for passengers).
CC_ARMOURED Armoured cargo (Valuables, Gold, Diamonds).
CC_BULK Bulk cargo (Coal, Grain etc., Ores, Fruit).
CC_PIECE_GOODS Piece goods (Livestock, Wood, Steel, Paper).
CC_LIQUID Liquids (Oil, Water, Rubber).
CC_REFRIGERATED Refrigerated cargo (Food, Fruit).
CC_HAZARDOUS Hazardous cargo (Nucleair Fuel, Explosives, etc.).
CC_COVERED Covered/Sheltered Freight (Transporation in Box Vans, Silo Wagons, etc.).
Thanks,
MarkS.
Re: Industry Confusion
You're confusing CargoClass and CargoID now. See http://devs.openttd.org/~noai/aidocs/classAICargo.html for CargoClass (the same list as you posted, but from the NoAI documentation). You can check whether a cargo is in a cargoclass with AICargo.HasCargoClass (CargoID cargo_type, CargoClass cargo_class). CargoID's are unique, there is exactly one CargoID per cargo in game. There can be multiple cargos with the same cargoclass, such as both coal (cargoid = 1) and ore (cargoid = something else) are in the CC_BULK cargo class.
Re: Industry Confusion
Oh, ok.. I get it now. This paragraph is exactly what I needed. I had already looked at the NoAI documentation, but I was not making the distinction between CargoClass and CargoID. So I will never care that it is coal, only that a station produces or accepts a cargoID. I may be hauling mulch as far as I know, only that it is a cargo.Yexo wrote:You're confusing CargoClass and CargoID now. See http://devs.openttd.org/~noai/aidocs/classAICargo.html for CargoClass (the same list as you posted, but from the NoAI documentation). You can check whether a cargo is in a cargoclass with AICargo.HasCargoClass (CargoID cargo_type, CargoClass cargo_class). CargoID's are unique, there is exactly one CargoID per cargo in game. There can be multiple cargos with the same cargoclass, such as both coal (cargoid = 1) and ore (cargoid = something else) are in the CC_BULK cargo class.
So may I ask as to the significance of CargoClass? Why would one care what class a cargo is? Is it safe to assume that if two cargoID's are in the same class, the vehicle can be retrofit?
And If I wanted to say start a coal trucking company (the area I live in is full of them) the only way to find coal cargo is to *search* on the cargo label?
Thanks Yexo, you have helped me a lot.
MarkS
-
- Engineer
- Posts: 72
- Joined: 09 Apr 2006 23:49
- Location: UK
- Contact:
Re: Industry Confusion
The CargoClass was introduced, as far as I'm aware, because of the need to at least distinguish passengers exactly - due to the separation of bus stations and truck stations on road transport, and because they are a "special case" generated by towns. The other categories are general categories too, and you could always add in some form of personality which decides to only want certain categories of stuff
Finaldeath
Re: Industry Confusion
People wanted a simple way to get all CargoIDs belonging to passengers, so we made a general function for that .. but as always, where one person sees the use, the other things it is utterly uselessreylas wrote: (..) So may I ask as to the significance of CargoClass? Why would one care what class a cargo is? Is it safe to assume that if two cargoID's are in the same class, the vehicle can be retrofit?
Don't. There is no promise a label is like it is. Also, you want your AI to work on other climates, don't you? So simply, don't. You can either use the CargoClass to get an idea of the type of cargo (I personally don't see how it can be useful), or you can use the AICargo::GetCargoIncome() to get the best cargo to transport, which is what I would advise to doreylas wrote: And If I wanted to say start a coal trucking company (the area I live in is full of them) the only way to find coal cargo is to *search* on the cargo label? (..)
Good luck!
The only thing necessary for the triumph of evil is for good men to do nothing.
Re: Industry Confusion
Thanks. That is what I assumed. The only need for it would be if someone decided they wanted to make a coal shipping company, but that is only personal preference nothing that should be supported per say. I only asked the question to try to get a better understanding of the Industry side.TrueLight wrote:People wanted a simple way to get all CargoIDs belonging to passengers, so we made a general function for that .. but as always, where one person sees the use, the other things it is utterly uselessreylas wrote: (..) So may I ask as to the significance of CargoClass? Why would one care what class a cargo is? Is it safe to assume that if two cargoID's are in the same class, the vehicle can be retrofit?
Don't. There is no promise a label is like it is. Also, you want your AI to work on other climates, don't you? So simply, don't. You can either use the CargoClass to get an idea of the type of cargo (I personally don't see how it can be useful), or you can use the AICargo::GetCargoIncome() to get the best cargo to transport, which is what I would advise to doreylas wrote: And If I wanted to say start a coal trucking company (the area I live in is full of them) the only way to find coal cargo is to *search* on the cargo label? (..)
Good luck!
All three of you have given me enough to understand what I need to and I thank you for it. The big problem was not seeing the distinction between CargoID and CargoClass. That helps tremendously.
Thanks,
MarkS
Who is online
Users browsing this forum: No registered users and 18 guests