Wow!
What version of TTD are you using?
I think this function was changed, now requires two parameters:
Code: Select all
CreateGroup()
static GroupID AIGroup::CreateGroup ( AIVehicle::VehicleType vehicle_type,
GroupID parent_group_id
)
static
Create a new group.
Parameters
vehicle_type The type of vehicle to create a group for.
parent_group_id The parent group id to create this group under, INVALID_GROUP for top-level.
Returns
The GroupID of the new group, or an invalid GroupID when it failed. Check the return value using IsValidGroup(). In test-mode 0 is returned if it was successful; any other value indicates failure.
In all versions of SuperSimpleAI they are called with only one parameter, like:
Code: Select all
jaume@shuttle-01:~/.openttd/content_download/ai/SuperSimpleAI-21$ grep CreateGroup *.nut
aircraft.nut: group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_ROAD);
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
main.nut: builder.group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
Code: Select all
jaume@shuttle-01:~/.openttd/content_download/ai/SuperSimpleAI-38$ grep CreateGroup *.nut mylib/*.nut
airbuilder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_ROAD);
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
main.nut: builder.group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
I don't know when changed. I think this change may crash other AIs like SimpleAI?
Code: Select all
jaume@shuttle-01:~/.openttd/content_download/ai/SimpleAI-12$ grep CreateGroup *.nut
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_ROAD);
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_RAIL);
builder.nut: group = AIGroup.CreateGroup(AIVehicle.VT_AIR);
This is now fixed in version 38.
And for AI Developers, you can create a class like this:
Code: Select all
/**
* This file is part of SuperSimpleAI: An OpenTTD AI.
*
* Author: Jaume Sabater
*
* It's free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* You should have received a copy of the GNU General Public License
* with it. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Define the MyAIGroup class which extends the AIGroup functions.
*/
class MyAIGroup /* extends AIGroup */
{
/**
* Create a new group.
* @param vehicle_type The type of vehicle to create a group for.
* @param parent_group_id The parent group id to create this group under,
* GROUP_INVALID for top-level (default).
* @return The GroupID of the new greup, or an invalid GroupID when it failed.
* Check the return value using AIGroup.IsValidGroup(). In test-mode 0
* is returned if it was successful; any other value indicates failure.
*/
static function CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID);
}
if ("GetParent" in AIGroup) {
function MyAIGroup::CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID)
{
return AIGroup.CreateGroup(vehicle_type, parent_group_id);
}
} else {
function MyAIGroup::CreateGroup(vehicle_type, parent_group_id = AIGroup.GROUP_INVALID)
{
return AIGroup.CreateGroup(vehicle_type);
}
}
And then, use it in your code:
Code: Select all
jaume@shuttle-01:~/.openttd/content_download/ai/SuperSimpleAI-38$ grep CreateGroup *.nut
airbuilder.nut: group = MyAIGroup.CreateGroup(AIVehicle.VT_AIR);
builder.nut: group = MyAIGroup.CreateGroup(AIVehicle.VT_ROAD);
builder.nut: group = MyAIGroup.CreateGroup(AIVehicle.VT_RAIL);
builder.nut: group = MyAIGroup.CreateGroup(AIVehicle.VT_AIR);
main.nut: builder.group = MyAIGroup.CreateGroup(AIVehicle.VT_RAIL);
Thank you!