You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ADE_INDEXER(l_Tables_TeamColors, "number/string IndexOrName", "Array of team colors", "teamcolor", "Team color handle, or invalid handle if name is invalid")
348
+
{
349
+
constchar* name;
350
+
if (!ade_get_args(L, "*s", &name))
351
+
returnade_set_error(L, "o", l_TeamColor.Set(-1));
352
+
353
+
// look up by name
354
+
for (int i = 0; i < static_cast<int>(Team_Names.size()); ++i) {
355
+
if (!stricmp(Team_Names[i].c_str(), name)) {
356
+
returnade_set_args(L, "o", l_TeamColor.Set(i));
357
+
}
358
+
}
359
+
360
+
// look up by number
361
+
int idx = atoi(name);
362
+
if (idx > 0) {
363
+
idx--; // Lua --> C/C++
364
+
} else {
365
+
returnade_set_args(L, "o", l_TeamColor.Set(-1));
366
+
}
367
+
368
+
returnade_set_args(L, "o", l_TeamColor.Set(idx));
369
+
}
370
+
371
+
ADE_FUNC(__len, l_Tables_TeamColors, nullptr, "Number of team colors", "number", "Number of team colors")
ADE_VIRTVAR(TeamColor, l_ParseObject, "string", "The team color", "string", "The name of the team color or empty if not set or invalid.")
337
+
ADE_VIRTVAR(TeamColor, l_ParseObject, "teamcolor", "The team color. Setting the team color here will not be reflected in the mission if the ship is already created. You must do that on the Ship object instead.", "teamcolor", "The team color handle or nil if not set or invalid.")
337
338
{
338
339
parse_object_h* poh = nullptr;
339
-
constchar* team_color = nullptr;
340
-
if (!ade_get_args(L, "o|s", l_ParseObject.GetPtr(&poh), &team_color))
341
-
returnade_set_error(L, "s", "");
340
+
int idx = -1;
341
+
if (!ade_get_args(L, "o|o", l_ParseObject.GetPtr(&poh), l_TeamColor.Get(&idx)))
342
+
returnADE_RETURN_NIL;
342
343
343
344
if (!poh->isValid())
344
-
returnade_set_error(L, "s", "");
345
-
346
-
//Set team color
347
-
if (ADE_SETTING_VAR && team_color != nullptr) {
345
+
returnADE_RETURN_NIL;
348
346
347
+
// Set team color
348
+
if (ADE_SETTING_VAR && SCP_vector_inbounds(Team_Names, idx)) {
ADE_VIRTVAR(TeamColor, l_Ship, "teamcolor", "The team color. Note that setting the team color here is instant. If you need a fade, then use the sexp.", "teamcolor", "The team color handle or nil if not set or invalid.")
872
+
{
873
+
object_h* oh = nullptr;
874
+
int idx = -1;
875
+
if (!ade_get_args(L, "o|o", l_Ship.GetPtr(&oh), l_TeamColor.Get(&idx)))
876
+
returnADE_RETURN_NIL;
877
+
878
+
if (!oh->isValid())
879
+
returnADE_RETURN_NIL;
880
+
881
+
ship* shipp = &Ships[oh->objp()->instance];
882
+
883
+
//Set team color
884
+
if (ADE_SETTING_VAR && SCP_vector_inbounds(Team_Names, idx)) {
885
+
// Verify
886
+
constauto& it = Team_Colors.find(Team_Names[idx]);
887
+
if (it == Team_Colors.end()) {
888
+
mprintf(("Invalid team color specified in mission file for ship %s. Not setting!\n", shipp->ship_name));
889
+
} else {
890
+
shipp->team_name = Team_Names[idx];
891
+
}
892
+
}
893
+
894
+
// look up by name
895
+
for (int i = 0; i < static_cast<int>(Team_Names.size()); ++i) {
896
+
if (lcase_equal(Team_Names[i], shipp->team_name)) {
897
+
returnade_set_args(L, "o", l_TeamColor.Set(i));
898
+
}
899
+
}
900
+
901
+
returnADE_RETURN_NIL;
902
+
}
903
+
870
904
ADE_VIRTVAR_DEPRECATED(PersonaIndex, l_Ship, "number", "Persona index", "number", "The index of the persona from messages.tbl, 0 if no persona is set", gameversion::version(25, 0), "Deprecated in favor of Persona")
ADE_FUNC(renderTechModel2, l_Shipclass, "number X1, number Y1, number X2, number Y2, [orientation Orientation=nil, number Zoom=1.3, string TeamColor=nil]", "Draws ship model as if in techroom", "boolean", "Whether ship was rendered")
1165
+
ADE_FUNC(renderTechModel2, l_Shipclass, "number X1, number Y1, number X2, number Y2, [orientation Orientation=nil, number Zoom=1.3, teamcolor TeamColor=nil]", "Draws ship model as if in techroom", "boolean", "Whether ship was rendered")
"boolean restart, number x, number y, [number width = 629, number height = 355, number currentEffectSetting = default, number zoom = 1.3, string TeamColor=nil]",
1199
+
"boolean restart, number x, number y, [number width = 629, number height = 355, number currentEffectSetting = default, number zoom = 1.3, teamcolor TeamColor=nil]",
1183
1200
"Draws the 3D select ship model with the chosen effect at the specified coordinates. Restart should "
1184
1201
"be true on the first frame this is called and false on subsequent frames. Valid selection effects are 1 (fs1) or 2 (fs2), "
1185
1202
"defaults to the mod setting or the model's setting. Zoom is a multiplier to the model's closeup_zoom value.",
"number x, number y, [number width = 467, number height = 362, number|table /* selectedSlot = -1 or empty table */, number selectedWeapon = -1, number hoverSlot = -1, "
1261
1285
"number bank1_x = 170, number bank1_y = 203, number bank2_x = 170, number bank2_y = 246, number bank3_x = 170, number bank3_y = 290, "
1262
1286
"number bank4_x = 552, number bank4_y = 203, number bank5_x = 552, number bank5_y = 246, number bank6_x = 552, number bank6_y = 290, "
1263
-
"number bank7_x = 552, number bank7_y = 333, number style = 0, string TeamColor=nil]",
1287
+
"number bank7_x = 552, number bank7_y = 333, number style = 0, teamcolor TeamColor=nil]",
1264
1288
"Draws the 3D overhead ship model with the lines pointing from bank weapon selections to bank firepoints. SelectedSlot refers to loadout "
1265
1289
"ship slots 1-12 where wing 1 is 1-4, wing 2 is 5-8, and wing 3 is 9-12. SelectedWeapon is the index into weapon classes. HoverSlot refers "
1266
1290
"to the bank slots 1-7 where 1-3 are primaries and 4-6 are secondaries. Lines will be drawn from any bank containing the SelectedWeapon to "
0 commit comments