Blustuff wrote:delegate settings and labels table for AIInfo seems to be rejected by OpenTTD as it doesn't find every fields. delegate settings and labels could be usefull to define common type of settings.
Thanks for the info.nut. I think the problem is that OpenTTD iterates over all items of the table. While doing so, it won't find the parent items, because they're not part of the table, but of the parent of the table. When getting the value of an index, if it can't be found in the table, the parent table is checked. But OpenTTD never asks for the value of an index, it just loops over all item/value pairs.
To work around this, you could ues a squirrel function like this:
Code: Select all
function CombineTables(parent, child)
{
local result = {};
foreach (a, b in parent) result[a] = b;
foreach (a, b in child) result[a] = b;
return result;
}
Not that I haven't tested this code at all.
Blustuff wrote:Yexo wrote:How to print a string when you throw a class object? If you say, just call a tostring fuctions, then what if your script crashes again in that handler?
If you catch an exception in Squirrel, you would probably like to print it and the rule in squirrel is that whenever an object is printed or used in a string expression call the delegate method _tostring. The problem of having another error/exception in the _tostring method is well known and scripting langages which use this pattern raises a fatal error which can't be customized by the user.
This requires changing squirrel code, which we tend to avoid if possible.
However, there is no such problem in the case where a standard (and included in API) AIException class is used since the message is generated before raising the exception and passed to the constructor of AIException which set a field with it.
This too requires changing squirrel code, but also makes squirrel depend on an API class, which would break all abstraction layers we currently have.