I have an array of stations that my AI has used. I wrote a function that gets the ratings of the station (the AI only deals with passenger buses right now). The function call looks like this:
Code: Select all
function getStationRatings(stationArray, AICargo.CC_PASSENGERS) { blah, blah, blah }
Now, say I want to get the amount of such ware sitting in the station. Would I have to write a new function? Perhaps I can tweak "getStationRatings" to be more flexible. This would look something like:
Code: Select all
function getStationInfo(stationArray, AICargo.GetCargoWaiting ( ?, ? ) ){ blah, blah, blah }
I guess the main problem are the arguments in the GetCargoWaiting function. How can these be filled? Do they need to be filled? Perhaps I can pass the 2nd argument as a string and then use a SwitchCase in the actual function. This would be a messier function than I want, but would look like:
Code: Select all
function getStationInfo(stationArray, "GetWaiting") { blah, blah, blah }
Am I being clear? Eventually, I will have more arrays than just for stations. Depending on how flexible this can be perhaps I can have one function "getArrayInfo".
Thanks