I wrote a team:getColor() function to get the IFF color of a team and I'd like to see it committed to trunk.
Could someone with who knows the scripting system review the new code and maybe commit it?
I tested the patch and it works without any warnings/errors on Windows.
Patch is here against revision 6607:
Index: code/parse/lua.cpp
===================================================================
--- code/parse/lua.cpp (revision 6607)
+++ code/parse/lua.cpp (working copy)
@@ -2832,6 +2832,24 @@
return ade_set_args(L, "s", Iff_info[tdx].iff_name);
}
+ADE_FUNC(getColor, l_Team, NULL, "Gets the IFF color of the specified Team", "number, number, number", "grb color for the specified team or nil if invalid") {
+ int idx;
+ int r,g,b;
+ if(!ade_get_args(L, "o", l_Team.Get(&idx)))
+ return ade_set_error(L, "s", "");
+
+ if(idx < 0 || idx >= Num_iffs)
+ return ADE_RETURN_NIL;
+
+ color* col = iff_get_color_by_team(idx, 0, 0);
+
+ r = col->red;
+ g = col->green;
+ b = col->blue;
+
+ return ade_set_args(L, "iii", r, g, b);
+}
+
ADE_FUNC(isValid, l_Team, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs")
{
int idx;
Regards,
m!m