57 #define BMPMAN_INTERNAL
90 Ade_table_entries[parent->GetIdx()].AddSubentry(ate);
92 Ade_table_entries.push_back(ate);
93 LibIdx = Ade_table_entries.size()-1;
104 return Ade_table_entries[
GetIdx()].GetName();
123 Ade_table_entries[parent.
GetIdx()].AddSubentry(ate);
124 LibIdx = Ade_table_entries.size()-1;
142 Ade_table_entries[parent.
GetIdx()].AddSubentry(ate);
143 LibIdx = Ade_table_entries.size()-1;
153 ate.
Name =
"__indexer";
162 Ade_table_entries[parent.
GetIdx()].AddSubentry(ate);
163 LibIdx = Ade_table_entries.size()-1;
197 {
"__tostring",
"(string)"},
208 if(!strcmp(tablename, ade_Operators[
i].
src))
220 #define ADE_FUNC(name, parent, args, desc, ret_type, ret_desc) \
221 static int parent##_##name##_f(lua_State *L); \
222 ade_func parent##_##name(#name, parent##_##name##_f, parent, args, desc, ret_type, ret_desc); \
223 static int parent##_##name##_f(lua_State *L)
227 #define ADE_VIRTVAR(name, parent, args, desc, ret_type, ret_desc) \
228 static int parent##_##name##_f(lua_State *L); \
229 ade_virtvar parent##_##name(#name, parent##_##name##_f, parent, args, desc, ret_type, ret_desc); \
230 static int parent##_##name##_f(lua_State *L)
234 #define ADE_INDEXER(parent, args, desc, ret_type, ret_desc) \
235 static int parent##___indexer_f(lua_State *L); \
236 ade_indexer parent##___indexer(parent##___indexer_f, parent, args, desc, ret_type, ret_desc); \
237 static int parent##___indexer_f(lua_State *L)
240 #define ADE_FUNCNAME_UPVALUE_INDEX 1
241 #define ADE_SETTING_UPVALUE_INDEX 2
242 #define ADE_SETTING_VAR lua_toboolean(L,lua_upvalueindex(ADE_SETTING_UPVALUE_INDEX))
245 #define ADE_RETURN_NIL 0
246 #define ADE_RETURN_TRUE ade_set_args(L, "b", true)
247 #define ADE_RETURN_FALSE ade_set_args(L, "b", false)
248 #define ade_set_error ade_set_args
297 #define MH_MATRIX_OUTOFDATE 1
298 #define MH_ANGLES_OUTOFDATE 2
308 void ValidateAngles() {
315 void ValidateMatrix() {
328 this->ValidateAngles();
334 this->ValidateMatrix();
350 ADE_INDEXER(
l_Matrix,
"p,b,h or 1-9",
"Orientation component - pitch, bank, heading, or index into 3x3 matrix (1-9)",
"number",
"Number at the specified index, or 0 if index is invalid.")
357 if(!numargs || s[1] !=
'\0')
370 if(idx < -3 || idx==0 || idx > 9)
410 ADE_FUNC(__mul,
l_Matrix,
"orientation",
"Multiplies two matrix objects)",
"orientation",
"matrix, or empty matrix if unsuccessful")
423 ADE_FUNC(__tostring,
l_Matrix, NULL,
"Converts a matrix to a string with format \"[r1c1 r2c1 r3c1 | r1c2 r2c2 r3c2| r1c3 r2c3 r3c3]\"",
"string",
"Formatted string or \"<NULL\"")
431 sprintf(buf,
"[%f %f %f | %f %f %f | %f %f %f]", a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
436 ADE_FUNC(getInterpolated,
l_Matrix,
"orientation Final, number Factor",
"Returns orientation that has been interpolated to Final by Factor (0.0-1.0)",
"orientation",
"Interpolated orientation, or null orientation on failure")
449 for(
int i = 0;
i < 9;
i++)
457 ADE_FUNC(getTranspose,
l_Matrix, NULL,
"Returns a transpose version of the specified orientation",
"orientation",
"Transpose matrix, or null orientation on failure")
470 ADE_FUNC(rotateVector,
l_Matrix,
"vector Input",
"Returns rotated version of given vector",
"vector",
"Rotated vector, or empty vector on error")
483 ADE_FUNC(unrotateVector,
l_Matrix,
"vector Input",
"Returns unrotated version of given vector",
"vector",
"Unrotated vector, or empty vector on error")
496 ADE_FUNC(getUvec,
l_Matrix, NULL,
"Returns the vector that points up (0,1,0 unrotated by this matrix)",
"vector",
"Vector or null vector on error")
505 ADE_FUNC(getFvec,
l_Matrix, NULL,
"Returns the vector that points to the front (0,0,1 unrotated by this matrix)",
"vector",
"Vector or null vector on error")
514 ADE_FUNC(getRvec,
l_Matrix, NULL,
"Returns the vector that points to the right (1,0,0 unrotated by this matrix)",
"vector",
"Vector or null vector on error")
529 static const int ENUM_NEXT_INDEX = 74;
532 #define LE_ALPHABLEND_FILTER 14
535 #define LE_ALPHABLEND_NONE 27
538 #define LE_CFILE_TYPE_NORMAL 20
541 #define LE_CFILE_TYPE_MEMORY_MAPPED 21
544 #define LE_MOUSE_LEFT_BUTTON 1
547 #define LE_MOUSE_RIGHT_BUTTON 2
550 #define LE_MOUSE_MIDDLE_BUTTON 3
553 #define LE_ORDER_ATTACK 28
556 #define LE_ORDER_ATTACK_ANY 29
559 #define LE_ORDER_DEPART 30
562 #define LE_ORDER_DISABLE 31
565 #define LE_ORDER_DISARM 32
568 #define LE_ORDER_DOCK 33
571 #define LE_ORDER_EVADE 34
574 #define LE_ORDER_FLY_TO 35
577 #define LE_ORDER_FORM_ON_WING 36
580 #define LE_ORDER_GUARD 37
583 #define LE_ORDER_IGNORE 38
586 #define LE_ORDER_KEEP_SAFE_DISTANCE 39
589 #define LE_ORDER_PLAY_DEAD 40
592 #define LE_ORDER_REARM 41
595 #define LE_ORDER_STAY_NEAR 42
598 #define LE_ORDER_STAY_STILL 43
601 #define LE_ORDER_UNDOCK 44
604 #define LE_ORDER_WAYPOINTS 45
607 #define LE_ORDER_WAYPOINTS_ONCE 46
610 #define LE_ORDER_ATTACK_WING 69
613 #define LE_ORDER_GUARD_WING 70
616 #define LE_PARTICLE_DEBUG 4
619 #define LE_PARTICLE_BITMAP 5
622 #define LE_PARTICLE_FIRE 6
625 #define LE_PARTICLE_SMOKE 7
628 #define LE_PARTICLE_SMOKE2 8
631 #define LE_PARTICLE_PERSISTENT_BITMAP 9
634 #define LE_SEXPVAR_CAMPAIGN_PERSISTENT 22
637 #define LE_SEXPVAR_NOT_PERSISTENT 23
640 #define LE_SEXPVAR_PLAYER_PERSISTENT 24
643 #define LE_SEXPVAR_TYPE_NUMBER 25
646 #define LE_SEXPVAR_TYPE_STRING 26
649 #define LE_TEXTURE_STATIC 10
652 #define LE_TEXTURE_DYNAMIC 11
664 #define LE_SHIELD_FRONT 16
667 #define LE_SHIELD_LEFT 17
670 #define LE_SHIELD_RIGHT 18
673 #define LE_SHIELD_BACK 19
676 #define LE_MISSION_REPEAT 47
679 #define LE_NORMAL_CONTROLS 48
682 #define LE_LUA_STEERING_CONTROLS 49
685 #define LE_LUA_FULL_CONTROLS 50
688 #define LE_NORMAL_BUTTON_CONTROLS 51
691 #define LE_LUA_ADDITIVE_BUTTON_CONTROL 52
694 #define LE_LUA_OVERRIDE_BUTTON_CONTROL 53
697 #define LE_VM_INTERNAL 54
700 #define LE_VM_EXTERNAL 55
703 #define LE_VM_TRACK 56
706 #define LE_VM_DEAD_VIEW 57
709 #define LE_VM_CHASE 58
712 #define LE_VM_OTHER_SHIP 59
715 #define LE_VM_EXTERNAL_CAMERA_LOCKED 60
718 #define LE_VM_WARP_CHASE 61
721 #define LE_VM_PADLOCK_UP 62
724 #define LE_VM_PADLOCK_REAR 63
727 #define LE_VM_PADLOCK_LEFT 64
730 #define LE_VM_PADLOCK_RIGHT 65
733 #define LE_VM_WARPIN_ANCHOR 66
736 #define LE_VM_TOPDOWN 67
739 #define LE_VM_FREECAMERA 68
742 #define LE_MESSAGE_PRIORITY_LOW 71
745 #define LE_MESSAGE_PRIORITY_NORMAL 72
748 #define LE_MESSAGE_PRIORITY_HIGH 73
884 enum_h(
int n_index){index=n_index; is_constant=
false;}
886 bool IsValid(){
return (index > -1 && index < ENUM_NEXT_INDEX);}
890 ADE_FUNC(__newindex,
l_Enum,
"enumeration",
"Sets enumeration to specified value (if it is not a global",
"enumeration",
"enumeration")
892 enum_h *e1=NULL, *e2=NULL;
897 e1->
index = e2->index;
902 ADE_FUNC(__tostring,
l_Enum, NULL,
"Returns enumeration name",
"string",
"Enumeration name, or \"<INVALID>\" if invalid")
908 if(e->
index < 1 || e->
index >= ENUM_NEXT_INDEX)
912 for(i = 0; i < Num_enumerations; i++)
914 if(Enumerations[i].def == e->
index)
921 ADE_FUNC(__eq,
l_Enum,
"enumeration",
"Compares the two enumerations for equality",
"boolean",
"true if equal, false otherwise")
929 if (e1 == NULL || e2 == NULL)
951 strncpy(mep->
name, s,
sizeof(mep->
name) -
sizeof(
char));
982 ADE_VIRTVAR(DirectiveKeypressText,
l_Event,
"string",
"Raw directive keypress text, as seen in FRED.",
"string", NULL)
1007 ADE_VIRTVAR(Interval,
l_Event,
"number",
"Time for event to repeat (in seconds)",
"number",
"Repeat time, or 0 if invalid handle")
1026 ADE_VIRTVAR(ObjectCount,
l_Event,
"number",
"Number of objects left for event",
"number",
"Repeat count, or 0 if invalid handle")
1039 mep->
count = newobject;
1045 ADE_VIRTVAR(RepeatCount,
l_Event,
"number",
"Event repeat count",
"number",
"Repeat count, or 0 if invalid handle")
1077 mep->
score = newscore;
1083 ADE_FUNC(isValid,
l_Event, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
1099 ADE_FUNC(isValid,
l_File, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
1111 ADE_FUNC(close,
l_File, NULL,
"Instantly closes file and invalidates all file handles", NULL, NULL)
1123 LuaError(L,
"Attempt to close file resulted in error %d", rval);
1129 ADE_FUNC(flush,
l_File, NULL,
"Flushes file buffer to disk.",
"boolean",
"True for success, false on failure")
1139 int cf_result =
cflush(cfp);
1143 ADE_FUNC(getPath,
l_File, NULL,
"Determines path of the given file",
"string",
"Path string of the file handle, or an empty string if it doesn't have one, or the handle is invalid")
1161 "Reads part of or all of a file, depending on arguments passed. Based on basic Lua file:read function."
1162 "Returns nil when the end of the file is reached."
1163 "<br><ul><li>\"*n\" - Reads a number.</li>"
1164 "<li>\"*a\" - Reads the rest of the file and returns it as a string.</li>"
1165 "<li>\"*l\" - Reads a line. Skips the end of line markers.</li>"
1166 "<li>(number) - Reads given number of characters, then returns them as a string.</li></ul>",
1167 "number or string, ...",
1168 "Requested data, or nil if the function fails")
1178 int num_returned = 0;
1179 int type = LUA_TNONE;
1183 int lastarg = lua_gettop(L);
1184 for(i = 2; i <= lastarg; i++)
1186 type = lua_type(L, i);
1189 if(type == LUA_TSTRING)
1191 fmt = (
char*)lua_tostring(L, i);
1198 lua_pushnumber(L, d);
1203 int tell_res =
cftell(cfp);
1206 Error(
LOCATION,
"Critical error reading Lua file; could not cftell.");
1211 int final_len =
cfread(buf, 1, read_len, cfp);
1212 buf[final_len] =
'\0';
1214 lua_pushstring(L, buf);
1222 if(
cfgets(buf, (
int)(
sizeof(buf)/
sizeof(
char)), cfp) == NULL)
1231 for (idx = 0; idx < strlen(buf); idx++)
1233 if ( buf[idx] ==
'\n' || buf[idx] ==
'\r' )
1237 lua_pushstring(L, buf);
1242 if(type == LUA_TNUMBER || (type == LUA_TSTRING && strpbrk(fmt,
"1234567890")))
1245 if(type == LUA_TSTRING)
1248 num =
fl2i(lua_tonumber(L, i));
1253 lua_pushstring(L,
"");
1259 int total_read =
cfread(buf, 1, num, cfp);
1262 buf[total_read] =
'\0';
1263 lua_pushstring(L, buf);
1272 if(type != LUA_TNUMBER && type != LUA_TSTRING)
1273 LuaError(L,
"Invalid argument passed to file:read");
1276 return num_returned;
1280 "Changes position of file, or gets location."
1282 "<li>\"set\" - File start.</li>"
1283 "<li>\"cur\" - Current position in file.</li>"
1284 "<li>\"end\" - File end.</li></ul>",
1286 "new offset, or false or nil on failure")
1298 if(!(w == NULL || (!
stricmp(w,
"cur") && o != 0)))
1308 LuaError(L,
"Invalid where argument passed to seek() - '%s'", w);
1310 if(
cfseek(cfp, o, seek_type))
1322 "Writes a series of Lua strings or numbers to the current file.",
"number",
"Number of items successfully written.")
1332 int type = LUA_TNONE;
1334 int num_successful = 0;
1335 while((type = lua_type(L, l_pos)) != LUA_TNONE)
1337 if(type == LUA_TSTRING)
1339 char *s = (
char*)lua_tostring(L, l_pos);
1340 if(
cfwrite(s,
sizeof(
char), strlen(s), cfp))
1343 else if(type == LUA_TNUMBER)
1345 double d = lua_tonumber(L, l_pos);
1347 sprintf(buf, LUA_NUMBER_FMT, d);
1348 if(
cfwrite(buf,
sizeof(
char), strlen(buf), cfp))
1361 ADE_FUNC(__tostring,
l_Font, NULL,
"Filename of font",
"string",
"Font filename, or an empty string if the handle is invalid")
1367 if(font_num < 0 || font_num >=
Num_fonts)
1373 ADE_VIRTVAR(Filename,
l_Font,
"string",
"Filename of font (including extension)",
"string", NULL)
1380 if(font_num < 0 || font_num >=
Num_fonts)
1390 ADE_VIRTVAR(Height,
l_Font,
"number",
"Height of font (in pixels)",
"number",
"Font height, or 0 if the handle is invalid")
1397 if(font_num < 0 || font_num >=
Num_fonts)
1407 ADE_FUNC(isValid,
l_Font, NULL,
"True if valid, false or nil if not",
"boolean",
"Detects whether handle is valid")
1413 if(font_num < 0 || font_num >=
Num_fonts)
1435 ADE_FUNC(__tostring,
l_GameEvent, NULL,
"Game event name",
"string",
"Game event name, or empty string if handle is invalid")
1447 ADE_VIRTVAR(Name,
l_GameEvent,
"string",
"Game event name",
"string",
"Game event name, or empty string if handle is invalid")
1450 char *n_name = NULL;
1457 int edx = gh->
Get();
1483 ADE_FUNC(__tostring,
l_GameState, NULL,
"Game state name",
"string",
"Game state name, or empty string if handle is invalid")
1495 ADE_VIRTVAR(Name,
l_GameState,
"string",
"Game state name",
"string",
"Game state name, or empty string if handle is invalid")
1498 char *n_name = NULL;
1505 int sdx = gh->
Get();
1518 ADE_VIRTVAR(Name,
l_HudGauge,
"string",
"Custom HUD Gauge name",
"string",
"Custom HUD Gauge name, or nil if handle is invalid")
1557 eye_h(
int n_m,
int n_e){model=n_m; eye_idx=n_e;}
1563 && eye_idx < pm->n_view_positions);
1568 ADE_VIRTVAR(Normal,
l_Eyepoint,
"vector",
"Eyepoint normal",
"vector",
"Eyepoint normal, or null vector if handle is invalid")
1588 ADE_VIRTVAR(Position,
l_Eyepoint,
"vector",
"Eyepoint location (Local vector)",
"vector",
"Eyepoint location, or null vector if handle is invalid")
1608 ADE_FUNC(IsValid,
l_Eyepoint, NULL,
"Detect whether this handle is valid",
"boolean",
"true if valid false otherwise")
1642 return (model != NULL && mid > -1 &&
model_get(mid) == model);
1719 return bank != NULL;
1749 return point != NULL;
1765 ADE_VIRTVAR(Textures,
l_Model,
"modeltextures_h",
"Model textures",
"modeltextures_h",
"Model textures, or an invalid modeltextures handle if the model handle is invalid")
1778 LuaError(L,
"Attempt to use Incomplete Feature: Modeltextures copy");
1784 ADE_VIRTVAR(Thrusters,
l_Model,
"thrusters",
"Model thrusters",
"thrusters",
"Thrusters of the model or invalid handle")
1796 LuaError(L,
"Attempt to use Incomplete Feature: Thrusters copy");
1802 ADE_VIRTVAR(Eyepoints,
l_Model,
"eyepoints",
"Model eyepoints",
"eyepoints",
"Array of eyepoints or invalid handle on error")
1814 LuaError(L,
"Attempt to use Incomplete Feature: Eyepoints copy");
1820 ADE_VIRTVAR(Dockingbays,
l_Model,
"dockingbays",
"Docking bays handle of model",
"dockingbays",
"Array of docking bays on this model, or invalid handle on error")
1832 LuaError(L,
"Attempt to use Incomplete Feature: Docking bays copy");
1840 ADE_VIRTVAR(BoundingBoxMax,
l_Model,
"vector",
"Model bounding box maximum",
"vector",
"Model bounding box, or an empty vector if the handle is invalid")
1862 ADE_VIRTVAR(BoundingBoxMin,
l_Model,
"vector",
"Model bounding box minimum",
"vector",
"Model bounding box, or an empty vector if the handle is invalid")
1884 ADE_VIRTVAR(Filename,
l_Model,
"string",
"Model filename",
"string",
"Model filename, or an empty string if the handle is invalid")
1903 ADE_VIRTVAR(Mass,
l_Model,
"number",
"Model mass",
"number",
"Model mass, or 0 if the model handle is invalid")
1922 ADE_VIRTVAR(MomentOfInertia,
l_Model,
"orientation",
"Model moment of inertia",
"orientation",
"Moment of Inertia matrix or identity matrix if invalid" )
1936 memcpy(&pm->moment_of_inertia, mtx,
sizeof(*mtx));
1942 ADE_VIRTVAR(Radius,
l_Model,
"number",
"Model radius (Used for collision & culling detection)",
"number",
"Model Radius or 0 if invalid")
1961 ADE_FUNC(isValid,
l_Model, NULL,
"True if valid, false or nil if not",
"boolean",
"Detects whether handle is valid")
1971 ADE_FUNC(__len,
l_Eyepoints, NULL,
"Gets the number of eyepoints on this model",
"number",
"Number of eyepoints on this model or 0 on error")
2026 LuaError(L,
"Attempted to use incomplete feature: Eyepoint copy");
2032 ADE_FUNC(isValid,
l_Eyepoints, NULL,
"Detects whether handle is valid or not",
"boolean",
"true if valid false otherwise")
2042 ADE_FUNC(__len,
l_Thrusters, NULL,
"Number of thruster banks on the model",
"number",
"Number of thrusterbanks")
2059 ADE_INDEXER(
l_Thrusters,
"number Index",
"Array of all thrusterbanks on this thruster",
"thrusterbank",
"Handle to the thrusterbank or invalid handle if index is invalid")
2070 if (!trh->
IsValid() || s == NULL || pm == NULL)
2074 int idx = atoi(s) - 1;
2076 if (idx < 0 || idx >= pm->n_thrusters)
2085 pm->thrusters[
idx] = *(newThr.
Get());
2092 ADE_FUNC(isValid,
l_Thrusters, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
2102 ADE_FUNC(__len,
l_Thrusterbank, NULL,
"Number of thrusters on this thrusterbank",
"number",
"Number of thrusters on this bank or 0 if handle is invalid")
2125 if (!tbh->
isValid() || s==NULL)
2131 int idx = atoi(s) - 1;
2149 ADE_FUNC(isValid,
l_Thrusterbank, NULL,
"Detectes if this handle is valid",
"boolean",
"true if this handle is valid, false otherwise")
2162 ADE_VIRTVAR(Position,
l_Glowpoint, NULL,
"The (local) vector to the position of the glowpoint",
"vector",
"The local vector to the glowpoint or nil invalid")
2183 ADE_VIRTVAR(Radius,
l_Glowpoint, NULL,
"The radius of the glowpoint",
"number",
"The radius of the glowpoint or -1 of invalid")
2204 ADE_FUNC(isValid,
l_Glowpoint, NULL,
"Returns wether this handle is valid or not",
"boolean",
"True if handle is valid, false otherwise")
2231 return dock_id >= 0 && dock_id < this->
Get()->
n_docks;
2248 ADE_INDEXER(
l_Dockingbays,
"dockingbay",
"Gets a dockingbay handle from this model. If a string is given then a dockingbay with that name is searched.",
"dockingbay",
"Handle or invalid handle on error")
2254 if (lua_isnumber(L, 2))
2273 if (!dbhp->
IsValid() && name != NULL)
2289 ADE_FUNC(__len,
l_Dockingbays, NULL,
"Retrieves the number of dockingbays on this model",
"number",
"number of docking bays or 0 on error")
2303 ADE_FUNC(__len,
l_Dockingbay, NULL,
"Gets the number of docking points in this bay",
"number",
"The number of docking points or 0 on error")
2312 if (dbh == NULL || !dbh->
IsValid())
2320 ADE_FUNC(getName,
l_Dockingbay, NULL,
"Gets the name of this docking bay",
"string",
"The name or an empty string on error")
2328 if (dbh == NULL || !dbh->
IsValid())
2338 ADE_FUNC(getPoint,
l_Dockingbay,
"number index",
"Gets the location of a docking point in this bay",
"vector",
"The local location or null vector on error")
2350 if (dbh == NULL || !dbh->
IsValid())
2359 LuaError(L,
"Invalid dock bay index %d!", (index + 1));
2366 ADE_FUNC(getNormal,
l_Dockingbay,
"number index",
"Gets the normal of a docking point in this bay",
"vector",
"The normal vector or null vector on error")
2378 if (dbh == NULL || !dbh->
IsValid())
2387 LuaError(L,
"Invalid dock bay index %d!", (index + 1));
2394 ADE_FUNC(computeDocker,
l_Dockingbay,
"dockingbay",
"Computes the final position and orientation of a docker bay that docks with this bay.",
"vector, orientation",
"The local location and orientation of the docker vessel in the reference to the vessel of the docking bay handle, or a nil value on error")
2396 dockingbay_h *dockee_bay_h = NULL, *docker_bay_h = NULL;
2405 if (!dockee_bay_h->
IsValid() || !docker_bay_h->IsValid())
2411 dock_bay* docker_bay = docker_bay_h->getDockingBay();
2414 vec3d dockee_dock_pos, docker_dock_pos_local, docker_dock_pos;
2419 vm_vec_avg(&docker_dock_pos_local, &docker_bay->
pnt[0], &docker_bay->
pnt[1]);
2428 vm_vec_unrotate(&docker_dock_pos, &docker_dock_pos_local, &final_orient);
2434 vm_vec_add(&final_pos, &dockee_dock_pos, &docker_dock_pos);
2439 ADE_FUNC(isValid,
l_Dockingbay, NULL,
"Detects whether is valid or not",
"number",
"<i>true</i> if valid, <i>false</i> otherwise")
2481 ADE_VIRTVAR(AfterburnerAccelerationTime,
l_Physics,
"number",
"Afterburner acceleration time",
"number",
"Afterburner acceleration time, or 0 if handle is invalid")
2498 ADE_VIRTVAR(AfterburnerVelocityMax,
l_Physics,
"vector",
"Afterburner max velocity (Local vector)",
"vector",
"Afterburner max velocity, or null vector if handle is invalid")
2515 ADE_VIRTVAR(BankingConstant,
l_Physics,
"number",
"Banking constant",
"number",
"Banking constant, or 0 if handle is invalid")
2532 ADE_VIRTVAR(ForwardAccelerationTime,
l_Physics,
"number",
"Forward acceleration time",
"number",
"Forward acceleration time, or 0 if handle is invalid")
2549 ADE_VIRTVAR(ForwardDecelerationTime,
l_Physics,
"number",
"Forward deceleration time",
"number",
"Forward decleration time, or 0 if handle is invalid")
2566 ADE_VIRTVAR(ForwardThrust,
l_Physics,
"number",
"Forward thrust amount (0-1), used primarily for thruster graphics",
"number",
"Forward thrust, or 0 if handle is invalid")
2600 ADE_VIRTVAR(RotationalVelocity,
l_Physics,
"vector",
"Rotational velocity (Local vector)",
"vector",
"Rotational velocity, or null vector if handle is invalid")
2617 ADE_VIRTVAR(RotationalVelocityDamping,
l_Physics,
"number",
"Rotational damping, ie derivative of rotational speed",
"number",
"Rotational damping, or 0 if handle is invalid")
2634 ADE_VIRTVAR(RotationalVelocityDesired,
l_Physics,
"vector",
"Desired rotational velocity",
"vector",
"Desired rotational velocity, or null vector if handle is invalid")
2651 ADE_VIRTVAR(RotationalVelocityMax,
l_Physics,
"vector",
"Maximum rotational velocity (Local vector)",
"vector",
"Maximum rotational velocity, or null vector if handle is invalid")
2668 ADE_VIRTVAR(ShockwaveShakeAmplitude,
l_Physics,
"number",
"How much shaking from shockwaves is applied to object",
"number",
"Shockwave shake amplitude, or 0 if handle is invalid")
2685 ADE_VIRTVAR(SideThrust,
l_Physics,
"number",
"Side thrust amount (0-1), used primarily for thruster graphics",
"number",
"Side thrust amount, or 0 if handle is invalid")
2702 ADE_VIRTVAR(SlideAccelerationTime,
l_Physics,
"number",
"Time to accelerate to maximum slide velocity",
"number",
"Sliding acceleration time, or 0 if handle is invalid")
2719 ADE_VIRTVAR(SlideDecelerationTime,
l_Physics,
"number",
"Time to decelerate from maximum slide speed",
"number",
"Sliding deceleration time, or 0 if handle is invalid")
2736 ADE_VIRTVAR(Velocity,
l_Physics,
"vector",
"Object world velocity (World vector)",
"vector",
"Object velocity, or null vector if handle is invalid")
2753 ADE_VIRTVAR(VelocityDesired,
l_Physics,
"vector",
"Desired velocity (World vector)",
"vector",
"Desired velocity, or null vector if handle is invalid")
2770 ADE_VIRTVAR(VelocityMax,
l_Physics,
"vector",
"Object max local velocity (Local vector)",
"vector",
"Maximum velocity, or null vector if handle is invalid")
2787 ADE_VIRTVAR(VerticalThrust,
l_Physics,
"number",
"Vertical thrust amount (0-1), used primarily for thruster graphics",
"number",
"Vertical thrust amount, or 0 if handle is invalid")
2804 ADE_VIRTVAR(AfterburnerActive,
l_Physics,
"boolean",
"Specifies if the afterburner is active or not",
"boolean",
"true if afterburner is active false otherwise")
2829 ADE_FUNC(isValid,
l_Physics, NULL,
"True if valid, false or nil if not",
"boolean",
"Detects whether handle is valid")
2838 ADE_FUNC(getSpeed,
l_Physics, NULL,
"Gets total speed as of last frame",
"number",
"Total speed, or 0 if handle is invalid")
2850 ADE_FUNC(getForwardSpeed,
l_Physics, NULL,
"Gets total speed in the ship's 'forward' direction as of last frame",
"number",
"Total forward speed, or 0 if handle is invalid")
2863 ADE_FUNC(isAfterburnerActive,
l_Physics, NULL,
"True if Afterburners are on, false or nil if not",
"boolean",
"Detects whether afterburner is active")
2879 ADE_FUNC(isGliding,
l_Physics, NULL,
"True if glide mode is on, false or nil if not",
"boolean",
"Detects if ship is gliding")
2894 ADE_FUNC(applyWhack,
l_Physics,
"vector Impulse, [ vector Position]",
"Applies a whack to an object at a position (a local vector) based on impulse supplied (a world vector). If no position is supplied, an empty vector is used.",
"boolean",
"true if it succeeded, false otherwise")
2930 ADE_VIRTVAR(Persistence,
l_SEXPVariable,
"enumeration",
"SEXP Variable persistance, uses SEXPVAR_*_PERSISTENT enumerations",
"enumeration",
"SEXPVAR_*_PERSISTENT enumeration, or invalid numeration if handle is invalid")
2972 ADE_VIRTVAR(Type,
l_SEXPVariable,
"enumeration",
"SEXP Variable type, uses SEXPVAR_TYPE_* enumerations",
"enumeration",
"SEXPVAR_TYPE_* enumeration, or invalid numeration if handle is invalid")
3007 ADE_VIRTVAR(Value,
l_SEXPVariable,
"number/string",
"SEXP variable value",
"string",
"SEXP variable contents, or nil if the variable is of an invalid type or the handle is invalid")
3010 char *newvalue = NULL;
3013 if(lua_type(L, 2) == LUA_TNUMBER)
3019 sprintf(number_as_str,
"%d", newnumber);
3020 newvalue = number_as_str;
3058 ADE_FUNC(isValid,
l_SEXPVariable, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
3070 ADE_FUNC(
delete,
l_SEXPVariable, NULL,
"Deletes a SEXP Variable",
"boolean",
"True if successful, false if the handle is invalid")
3087 ADE_FUNC(__len,
l_Shields, NULL,
"Number of shield segments",
"number",
"Number of shield segments or 0 if handle is invalid")
3100 ADE_INDEXER(
l_Shields,
"enumeration/number",
"Gets or sets shield segment strength. Use \"SHIELD_*\" enumerations (for standard 4-quadrant shields) or index of a specific segment, or NONE for the entire shield",
"number",
"Segment/shield strength, or 0 if handle is invalid")
3108 if(lua_isstring(L, 2))
3123 else if((qdi = atoi(qd)) > 0 && qdi <= objp->
n_quadrants)
3178 ADE_VIRTVAR(CombinedLeft,
l_Shields,
"number",
"Total shield hitpoints left (for all segments combined)",
"number",
"Combined shield strength, or 0 if handle is invalid")
3195 ADE_VIRTVAR(CombinedMax,
l_Shields,
"number",
"Maximum shield hitpoints (for all segments combined)",
"number",
"Combined maximum shield strength, or 0 if handle is invalid")
3212 ADE_FUNC(isValid,
l_Shields, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
3225 ADE_VIRTVAR(Name,
l_Shiptype,
"string",
"Ship type name",
"string",
"Ship type name, or empty string if handle is invalid")
3227 if(!Species_initted)
3245 ADE_FUNC(isValid,
l_Shiptype, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
3261 ADE_VIRTVAR(Name,
l_Species,
"string",
"Species name",
"string",
"Species name, or empty string if handle is invalid")
3263 if(!Species_initted)
3281 ADE_FUNC(isValid,
l_Species, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
3296 ADE_FUNC(__eq,
l_Team,
"team, team",
"Checks whether two teams are the same team",
"boolean",
"true if equal")
3305 ADE_VIRTVAR(Name,
l_Team,
"string",
"Team name",
"string",
"Team name, or empty string if handle is invalid")
3322 ADE_FUNC(getColor,
l_Team, NULL,
"Gets the IFF color of the specified Team",
"number, number, number",
"rgb color for the specified team or nil if invalid") {
3340 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")
3356 static float lua_Opacity = 1.0f;
3376 ADE_FUNC(__eq,
l_Texture,
"texture, texture",
"Checks if two texture handles refer to the same texture",
"boolean",
"True if textures are equal")
3390 "Returns texture handle to specified frame number in current texture's animation."
3391 "This means that [1] will always return the first frame in an animation, no matter what frame an animation is."
3392 "You cannot change a texture animation frame.",
3394 "Texture handle, or invalid texture handle if index is invalid")
3417 frame = first + frame;
3422 ADE_FUNC(isValid,
l_Texture, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
3449 ADE_FUNC(getFilename,
l_Texture, NULL,
"Returns filename for texture",
"string",
"Filename, or empty string if handle is invalid")
3461 ADE_FUNC(getWidth,
l_Texture, NULL,
"Gets texture width",
"number",
"Texture width, or 0 if handle is invalid")
3478 ADE_FUNC(getHeight,
l_Texture, NULL,
"Gets texture height",
"number",
"Texture height, or 0 if handle is invalid")
3495 ADE_FUNC(getFPS,
l_Texture, NULL,
"Gets frames-per-second of texture",
"number",
"Texture FPS, or 0 if handle is invalid")
3506 if(
bm_get_info(idx, NULL, NULL, NULL, NULL, &fps) < 0)
3512 ADE_FUNC(getFramesLeft,
l_Texture, NULL,
"Gets number of frames left, from handle's position in animation",
"number",
"Frames left, or 0 if handle is invalid")
3532 ADE_INDEXER(
l_Vector,
"x,y,z or 1-3",
"Vector component",
"number",
"Value at index, or 0 if vector handle is invalid")
3536 float newval = 0.0f;
3539 if(!numargs || s[1] !=
'\0')
3543 if(s[0]==
'x' || s[0] ==
'1')
3545 else if(s[0]==
'y' || s[0] ==
'2')
3547 else if(s[0]==
'z' || s[0] ==
'3')
3550 if(idx < 0 || idx > 3)
3560 ADE_FUNC(__add,
l_Vector,
"number/vector",
"Adds vector by another vector, or adds all axes by value",
"vector",
"Final vector, or null vector if error occurs")
3563 if(lua_isnumber(L, 1) || lua_isnumber(L, 2))
3586 ADE_FUNC(__sub,
l_Vector,
"number/vector",
"Subtracts vector from another vector, or subtracts all axes by value",
"vector",
"Final vector, or null vector if error occurs")
3589 if(lua_isnumber(L, 1) || lua_isnumber(L, 2))
3613 ADE_FUNC(__mul,
l_Vector,
"number/vector",
"Scales vector object (Multiplies all axes by number), or multiplies each axes by the other vector's axes.",
"vector",
"Final vector, or null vector if error occurs")
3616 if(lua_isnumber(L, 1) || lua_isnumber(L, 2))
3640 ADE_FUNC(__div,
l_Vector,
"number/vector",
"Scales vector object (Divide all axes by number), or divides each axes by the dividing vector's axes.",
"vector",
"Final vector, or null vector if error occurs")
3643 if(lua_isnumber(L, 1) || lua_isnumber(L, 2))
3668 ADE_FUNC(__tostring,
l_Vector, NULL,
"Converts a vector to string with format \"(x,y,z)\"",
"string",
"Vector as string, or empty string if handle is invalid")
3681 "Returns orientation object representing the direction of the vector. Does not require vector to be normalized.",
3683 "Orientation object, or null orientation object if handle is invalid")
3698 ADE_FUNC(getMagnitude,
l_Vector, NULL,
"Returns the magnitude of a vector (Total regardless of direction)",
"number",
"Magnitude of vector, or 0 if handle is invalid")
3707 ADE_FUNC(getDistance,
l_Vector,
"Vector",
"Distance",
"number",
"Returns distance from another vector")
3716 ADE_FUNC(getDotProduct,
l_Vector,
"vector OtherVector",
"Returns dot product of vector object with vector argument",
"number",
"Dot product, or 0 if a handle is invalid")
3725 ADE_FUNC(getCrossProduct,
l_Vector,
"vector OtherVector",
"Returns cross product of vector object with vector argument",
"vector",
"Cross product, or null vector if a handle is invalid")
3737 ADE_FUNC(getScreenCoords,
l_Vector, NULL,
"Gets screen cordinates of a world vector",
"number,number",
"X (number), Y (number), or false if off-screen")
3760 ADE_FUNC(getNormalized,
l_Vector, NULL,
"Returns a normalized version of the vector",
"vector",
"Normalized Vector, or NIL if invalid")
3772 static const int THT_INDEPENDENT = 0;
3773 static const int THT_OBJECT = 1;
3774 static const int THT_MODEL = 2;
3786 type = THT_INDEPENDENT;
3838 case THT_INDEPENDENT:
3852 ADE_VIRTVAR(BaseMap,
l_TextureMap,
"texture",
"Base texture",
"texture",
"Base texture, or invalid texture handle if material handle is invalid")
3870 ADE_VIRTVAR(GlowMap,
l_TextureMap,
"texture",
"Glow texture",
"texture",
"Glow texture, or invalid texture handle if material handle is invalid")
3888 ADE_VIRTVAR(SpecularMap,
l_TextureMap,
"texture",
"Specular texture",
"texture",
"Texture handle, or invalid texture handle if material handle is invalid")
3909 ADE_FUNC(__tostring,
l_Weaponclass, NULL,
"Weapon class name",
"string",
"Weapon class name, or an empty string if handle is invalid")
3922 ADE_FUNC(__eq,
l_Weaponclass,
"weaponclass, weaponclass",
"Checks if the two classes are equal",
"boolean",
"true if equal false otherwise")
3955 ADE_VIRTVAR(Title,
l_Weaponclass,
"string",
"Weapon class title",
"string",
"Weapon class title, or empty string if handle is invalid")
3972 ADE_VIRTVAR(Description,
l_Weaponclass,
"string",
"Weapon class description string",
"string",
"Description string, or empty string if handle is invalid")
3988 strcpy(wip->
desc, s);
3994 if(wip->
desc != NULL)
4000 ADE_VIRTVAR(TechTitle,
l_Weaponclass,
"string",
"Weapon class tech title",
"string",
"Tech title, or empty string if handle is invalid")
4017 ADE_VIRTVAR(TechAnimationFilename,
l_Weaponclass,
"string",
"Weapon class animation filename",
"string",
"Filename, or empty string if handle is invalid")
4034 ADE_VIRTVAR(TechDescription,
l_Weaponclass,
"string",
"Weapon class tech description string",
"string",
"Description string, or empty string if handle is invalid")
4062 ADE_VIRTVAR(Model,
l_Weaponclass,
"model",
"Model",
"model",
"Weapon class model, or invalid model handle if weaponclass handle is invalid")
4064 int weapon_info_idx=-1;
4074 int mid = (mdl ? mdl->
GetID() : -1);
4083 ADE_VIRTVAR(ArmorFactor,
l_Weaponclass,
"number",
"Amount of weapon damage applied to ship hull (0-1.0)",
"number",
"Armor factor, or empty string if handle is invalid")
4100 ADE_VIRTVAR(Damage,
l_Weaponclass,
"number",
"Amount of damage that weapon deals",
"number",
"Damage amount, or 0 if handle is invalid")
4117 ADE_VIRTVAR(FireWait,
l_Weaponclass,
"number",
"Weapon fire wait (cooldown time) in seconds",
"number",
"Fire wait time, or 0 if handle is invalid")
4134 ADE_VIRTVAR(FreeFlightTime,
l_Weaponclass,
"number",
"The time the weapon will fly before turing onto its target",
"number",
"Free flight time or emty string if invalid")
4202 ADE_VIRTVAR(ShieldFactor,
l_Weaponclass,
"number",
"Amount of weapon damage applied to ship shields (0-1.0)",
"number",
"Shield damage factor, or 0 if handle is invalid")
4219 ADE_VIRTVAR(SubsystemFactor,
l_Weaponclass,
"number",
"Amount of weapon damage applied to ship subsystems (0-1.0)",
"number",
"Subsystem damage factor, or 0 if handle is invalid")
4236 ADE_VIRTVAR(TargetLOD,
l_Weaponclass,
"number",
"LOD used for weapon model in the targeting computer",
"number",
"LOD number, or 0 if handle is invalid")
4253 ADE_VIRTVAR(Speed,
l_Weaponclass,
"number",
"Weapon max speed, aka $Velocity in weapons.tbl",
"number",
"Weapon speed, or 0 if handle is invalid")
4321 LuaError(L,
"Cargo size must be bigger than zero, got %f!", newVal);
4328 ADE_FUNC(isValid,
l_Weaponclass, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
4340 ADE_FUNC(getWeaponClassIndex,
l_Weaponclass, NULL,
"Gets the index value of the weapon class",
"number",
"index value of the weapon class")
4352 ADE_FUNC(isLaser,
l_Weaponclass, NULL,
"Return true if the weapon is a primary weapon (this includes Beams). This function is deprecated, use isPrimary instead.",
"boolean",
"true if the weapon is a primary, false otherwise")
4367 ADE_FUNC(isMissile,
l_Weaponclass, NULL,
"Return true if the weapon is a secondary weapon. This function is deprecated, use isSecondary instead.",
"boolean",
"true if the weapon is a secondary, false otherwise")
4382 ADE_FUNC(isPrimary,
l_Weaponclass, NULL,
"Return true if the weapon is a primary weapon (this includes Beams)",
"boolean",
"true if the weapon is a primary, false otherwise")
4397 ADE_FUNC(isSecondary,
l_Weaponclass, NULL,
"Return true if the weapon is a secondary weapon",
"boolean",
"true if the weapon is a secondary, false otherwise")
4412 ADE_FUNC(isBeam,
l_Weaponclass, NULL,
"Return true if the weapon is a beam",
"boolean",
"true if the weapon is a beam, false otherwise")
4453 return info != NULL;
4499 ADE_FUNC(getCollisionDistance,
l_ColInfo, NULL,
"The distance to the closest collision point",
"number",
"distance or -1 on error")
4521 ADE_FUNC(getCollisionPoint,
l_ColInfo,
"[boolean local]",
"The collision point of this information (local to the object if boolean is set to <i>true</i>)",
"vector",
"The collision point or nil of none")
4547 ADE_FUNC(getCollisionNormal,
l_ColInfo,
"[boolean local]",
"The collision normal of this information (local to object if boolean is set to <i>true</i>)",
"vector",
"The collision normal or nil of none")
4581 ADE_FUNC(isValid,
l_ColInfo, NULL,
"Detects if this handle is valid",
"boolean",
"true if valid false otherwise")
4612 ADE_INDEXER(
l_ModelTextures,
"texture",
"number Index/string TextureName",
"texture",
"Model textures, or invalid modeltextures handle if model handle is invalid")
4623 if (!mth->
IsValid() || s == NULL || pm == NULL)
4629 if(strspn(s,
"0123456789") == strlen(s))
4632 int idx = atoi(s) - 1;
4634 if (idx < 0 || idx >= num_textures)
4643 for (
int i = 0;
i < pm->n_textures;
i++)
4645 tmap = &pm->maps[
i];
4663 ADE_FUNC(isValid,
l_ModelTextures, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
4678 ADE_FUNC(__eq,
l_Object,
"object, object",
"Checks whether two object handles are for the same object",
"boolean",
"True if equal, false if not or a handle is invalid")
4690 ADE_FUNC(__tostring,
l_Object, NULL,
"Returns name of object (if any)",
"string",
"Object name, or empty string if handle is invalid")
4716 ADE_VIRTVAR(Parent,
l_Object,
"object",
"Parent of the object. Value may also be a deriviative of the 'object' class, such as 'ship'.",
"object",
"Parent handle, or invalid handle if object is invalid")
4728 if(newparenth != NULL && newparenth->
IsValid())
4748 ADE_VIRTVAR(Position,
l_Object,
"vector",
"Object world position (World vector)",
"vector",
"World position, or null vector if handle is invalid")
4769 ADE_VIRTVAR(LastPosition,
l_Object,
"vector",
"Object world position as of last frame (World vector)",
"vector",
"World position, or null vector if handle is invalid")
4786 ADE_VIRTVAR(Orientation,
l_Object,
"orientation",
"Object world orientation (World orientation)",
"orientation",
"Orientation, or null orientation if handle is invalid")
4803 ADE_VIRTVAR(LastOrientation,
l_Object,
"orientation",
"Object world orientation as of last frame (World orientation)",
"orientation",
"Orientation, or null orientation if handle is invalid")
4820 ADE_VIRTVAR(Physics,
l_Object,
"physics",
"Physics data used to move ship between frames",
"physics",
"Physics data, or invalid physics handle if object handle is invalid")
4837 ADE_VIRTVAR(HitpointsLeft,
l_Object,
"number",
"Hitpoints an object has left",
"number",
"Hitpoints left, or 0 if handle is invalid")
4855 ADE_VIRTVAR(Shields,
l_Object,
"shields",
"Shields",
"shields",
"Shields handle, or invalid shields handle if object handle is invalid")
4875 ADE_FUNC(getSignature,
l_Object, NULL,
"Gets the object's unique signature",
"number",
"Returns the object's unique numeric signature, or -1 if invalid. Useful for creating a metadata system")
4890 ADE_FUNC(isValid,
l_Object, NULL,
"Detects whether handle is valid",
"boolean",
"true if handle is valid, false if handle is invalid, nil if a syntax/type error occurs")
4899 ADE_FUNC(getBreedName,
l_Object, NULL,
"Gets object type",
"string",
"Object type name, or empty string if handle is invalid")
4911 ADE_VIRTVAR(CollisionGroups,
l_Object,
"number",
"Collision group data",
"number",
"Current collision group signature. NOTE: This is a bitfield, NOT a normal number.")
4929 ADE_FUNC(getfvec,
l_Object,
"[boolean normalize]",
"Returns the objects' current fvec.",
"vector",
"Objects' forward vector, or nil if invalid. If called with a true argument, vector will be normalized.")
4933 bool normalize =
false;
4950 ADE_FUNC(getuvec,
l_Object,
"[boolean normalize]",
"Returns the objects' current uvec.",
"vector",
"Objects' up vector, or nil if invalid. If called with a true argument, vector will be normalized.")
4954 bool normalize =
false;
4971 ADE_FUNC(getrvec,
l_Object,
"[boolean normalize]",
"Returns the objects' current rvec.",
"vector",
"Objects' rvec, or nil if invalid. If called with a true argument, vector will be normalized.")
4975 bool normalize =
false;
4992 ADE_FUNC(checkRayCollision,
l_Object,
"vector Start Point, vector End Point, [boolean Local]",
"Checks the collisions between the polygons of the current object and a ray",
"vector, collision info",
"World collision point (local if boolean is set to true) and the specific collsision info, nil if no collisions")
5068 ADE_VIRTVAR(Target,
l_Asteroid,
"object",
"Asteroid target object; may be object derivative, such as ship.",
"object",
"Target object, or invalid handle if asteroid handle is invalid")
5094 ADE_FUNC(kill,
l_Asteroid,
"[ship killer=nil, wvector hitpos=nil]",
"Kills the asteroid. Set \"killer\" to designate a specific ship as having been the killer, and \"hitpos\" to specify the world position of the hit location; if nil, the asteroid center is used.",
"boolean",
"True if successful, false or nil otherwise")
5104 if(killer != NULL && !killer->
IsValid())
5123 size_t m_display_num;
5130 this->m_display_num = display_num;
5138 return &m_sip->
displays[m_display_num];
5148 if (m_display_num == INVALID_ID)
5153 if ( m_display_num >= m_sip->
displays.size())
5169 ADE_FUNC(getName,
l_DisplayInfo, NULL,
"Gets the name of this cockpit display as defined in ships.tbl",
"string",
"Name string or empty string on error")
5187 ADE_FUNC(getFileName,
l_DisplayInfo, NULL,
"Gets the file name of the target texture of this cockpit display",
"string",
"Texture name string or empty string on error")
5205 ADE_FUNC(getForegroundFileName,
l_DisplayInfo, NULL,
"Gets the file name of the foreground texture of this cockpit display",
"string",
"Foreground texture name string or nil if texture is not set or on error")
5226 ADE_FUNC(getBackgroundFileName,
l_DisplayInfo, NULL,
"Gets the file name of the background texture of this cockpit display",
"string",
"Background texture name string or nil if texture is not set or on error")
5247 ADE_FUNC(getSize,
l_DisplayInfo, NULL,
"Gets the size of this cockpit display",
"number, number",
"Width and height of the display or -1, -1 on error")
5265 ADE_FUNC(getOffset,
l_DisplayInfo, NULL,
"Gets the offset of this cockpit display",
"number, number",
"x and y offset of the display or -1, -1 on error")
5283 ADE_FUNC(isValid,
l_DisplayInfo, NULL,
"Detects whether this handle is valid",
"boolean",
"true if valid false otherwise")
5299 size_t m_display_num;
5306 this->m_objp =
objp;
5308 this->m_display_num = display_num;
5328 return m_display_num;
5338 if (m_objp == NULL ||
OBJ_INDEX(m_objp) != obj_num)
5349 if (m_display_num == INVALID_ID)
5363 ADE_FUNC(startRendering,
l_CockpitDisplay,
"[boolean setClip = true]",
"Starts rendering to this cockpit display. That means if you get a valid texture handle from this function then the rendering system is ready to do a render to texture. If setClip is true then the clipping region will be set to the region of the cockpit display.<br><b>Important:</b> You have to call stopRendering after you're done or this render target will never be released!",
"texture",
"texture handle that is being drawn to or invalid handle on error")
5366 bool setClip =
true;
5385 ADE_FUNC(stopRendering,
l_CockpitDisplay, NULL,
"Stops rendering to this cockpit display",
"boolean",
"true if successfull, false otherwise")
5401 ADE_FUNC(getBackgroundTexture,
l_CockpitDisplay, NULL,
"Gets the background texture handle of this cockpit display",
"texture",
"texture handle or invalid handle if no background texture or an error happened")
5420 "<b>Important:</b> If you want to do render to texture then you have to use startRendering/stopRendering",
"texture",
"texture handle or invalid handle if no foreground texture or an error happened")
5438 ADE_FUNC(getSize,
l_CockpitDisplay, NULL,
"Gets the size of this cockpit display",
"number, number",
"Width and height of the display or -1, -1 on error")
5456 ADE_FUNC(getOffset,
l_CockpitDisplay, NULL,
"Gets the offset of this cockpit display",
"number, number",
"x and y offset of the display or -1, -1 on error")
5488 int m_ship_info_idx;
5493 this->m_ship_info_idx = ship_info_idx;
5506 if (m_ship_info_idx < 0 || m_ship_info_idx >= static_cast<int>(
Ship_info.size()))
5511 if (!
Ship_info[m_ship_info_idx].hud_enabled)
5533 ADE_INDEXER(
l_CockpitDisplayInfos,
"number/string",
"Returns the handle at the requested index or the handle with the specified name",
"display info",
"display handle or invalid handle on error")
5535 if (lua_isnumber(L, 2))
5585 if (!strcmp(name, iter->name))
5597 LuaError(L,
"Couldn't find cockpit display info with name \"%s\"", name);
5617 ADE_FUNC(__tostring,
l_Shipclass, NULL,
"Ship class name",
"string",
"Ship class name, or an empty string if handle is invalid")
5624 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5630 ADE_FUNC(__eq,
l_Shipclass,
"shipclass, shipclass",
"Checks if the two classes are equal",
"boolean",
"true if equal false otherwise")
5636 if(idx1 < 0 || idx1 >= static_cast<int>(
Ship_info.size()))
5639 if(idx2 < 0 || idx2 >= static_cast<int>(
Ship_info.size()))
5645 ADE_VIRTVAR(Name,
l_Shipclass,
"string",
"Ship class name",
"string",
"Ship class name, or an empty string if handle is invalid")
5652 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5662 ADE_VIRTVAR(ShortName,
l_Shipclass,
"string",
"Ship class short name",
"string",
"Ship short name, or empty string if handle is invalid")
5669 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5679 ADE_VIRTVAR(TypeString,
l_Shipclass,
"string",
"Ship class type string",
"string",
"Type string, or empty string if handle is invalid")
5686 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5707 ADE_VIRTVAR(ManeuverabilityString,
l_Shipclass,
"string",
"Ship class maneuverability string",
"string",
"Maneuverability string, or empty string if handle is invalid")
5714 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5735 ADE_VIRTVAR(ArmorString,
l_Shipclass,
"string",
"Ship class armor string",
"string",
"Armor string, or empty string if handle is invalid")
5742 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5763 ADE_VIRTVAR(ManufacturerString,
l_Shipclass,
"string",
"Ship class manufacturer",
"string",
"Manufacturer, or empty string if handle is invalid")
5770 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5792 ADE_VIRTVAR(Description,
l_Shipclass,
"string",
"Ship class description",
"string",
"Description, or empty string if handle is invalid")
5799 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5808 strcpy(sip->
desc, s);
5814 if(sip->
desc != NULL)
5820 ADE_VIRTVAR(TechDescription,
l_Shipclass,
"string",
"Ship class tech description",
"string",
"Tech description, or empty string if handle is invalid")
5827 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5848 ADE_VIRTVAR(AfterburnerFuelMax,
l_Shipclass,
"number",
"Afterburner fuel capacity",
"number",
"Afterburner capacity, or 0 if handle is invalid")
5855 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5864 ADE_VIRTVAR(CountermeasuresMax,
l_Shipclass,
"number",
"Maximum number of countermeasures the ship can carry",
"number",
"Countermeasure capacity, or 0 if handle is invalid")
5871 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5881 ADE_VIRTVAR(Model,
l_Shipclass,
"model",
"Model",
"model",
"Ship class model, or invalid model handle if shipclass handle is invalid")
5883 int ship_info_idx=-1;
5888 if(ship_info_idx < 0 || ship_info_idx >= static_cast<int>(
Ship_info.size()))
5893 int mid = (mdl ? mdl->
GetID() : -1);
5896 sip->model_num = mid;
5904 int ship_info_idx=-1;
5909 if(ship_info_idx < 0 || ship_info_idx >= static_cast<int>(
Ship_info.size()))
5914 int mid = (mdl ? mdl->
GetID() : -1);
5917 sip->cockpit_model_num = mid;
5923 ADE_VIRTVAR(CockpitDisplays,
l_Shipclass,
"cockpitdisplays",
"Gets the cockpit display information array of this ship class",
"cockpitdisplays",
"Array handle containing the information or invalid handle on error")
5925 int ship_info_idx=-1;
5930 if(ship_info_idx < 0 || ship_info_idx >= static_cast<int>(
Ship_info.size()))
5934 LuaError(L,
"Attempted to use incomplete feature: Cockpit display information copy");
5947 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5957 ADE_VIRTVAR(Species,
l_Shipclass,
"Species",
"Ship class species",
"species",
"Ship class species, or invalid species handle if shipclass handle is invalid")
5964 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5974 ADE_VIRTVAR(Type,
l_Shipclass,
"shiptype",
"Ship class type",
"shiptype",
"Ship type, or invalid handle if shipclass handle is invalid")
5981 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
5991 ADE_VIRTVAR(AltName,
l_Shipclass,
"string",
"Alternate name for ship class",
"string",
"Alternate string or empty string if handle is invalid")
5993 char* newName = NULL;
5998 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
6004 LuaError(L,
"Cannot set alternate name value to '%s' because it is too long, maximum length is %d!", newName,
NAME_LENGTH - 1);
6014 ADE_FUNC(isValid,
l_Shipclass, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
6020 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
6026 ADE_FUNC(isInTechroom,
l_Shipclass, NULL,
"Gets whether or not the ship class is available in the techroom",
"boolean",
"Whether ship has been revealed in the techroom, false if handle is invalid")
6032 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
6045 ADE_FUNC(renderTechModel,
l_Shipclass,
"X1, Y1, X2, Y2, [Rotation %=0, Pitch %=0, Bank %=40, number Zoom=1.3]",
"Draws ship model as if in techroom",
"boolean",
"Whether ship was rendered")
6048 angles rot_angles = {0.0f, 0.0f, 40.0f};
6051 if(!
ade_get_args(L,
"oiiii|ffff",
l_Shipclass.Get(&idx), &x1, &y1, &x2, &y2, &rot_angles.
h, &rot_angles.
p, &rot_angles.
b, &zoom))
6054 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
6057 if(x2 < x1 || y2 < y1)
6060 CLAMP(rot_angles.
p, 0.0f, 100.0f);
6061 CLAMP(rot_angles.
b, 0.0f, 100.0f);
6062 CLAMP(rot_angles.
h, 0.0f, 100.0f);
6079 angles view_angles = {-0.6f, 0.0f, 0.0f};
6082 rot_angles.
p = (rot_angles.
p*0.01f) *
PI2;
6083 rot_angles.
b = (rot_angles.
b*0.01f) *
PI2;
6084 rot_angles.
h = (rot_angles.
h*0.01f) *
PI2;
6100 light_dir.
xyz.y = 1.0f;
6129 ADE_FUNC(renderTechModel2,
l_Shipclass,
"X1, Y1, X2, Y2, [orientation Orientation=nil, number Zoom=1.3]",
"Draws ship model as if in techroom",
"boolean",
"Whether ship was rendered")
6138 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
6141 if(x2 < x1 || y2 < y1)
6173 light_dir.
xyz.y = 1.0f;
6201 ADE_FUNC(isModelLoaded,
l_Shipclass,
"[boolean Load = false]",
"Checks if the model used for this shipclass is loaded or not and optionally loads the model, which might be a slow operation.",
"boolean",
"If the model is loaded or not")
6204 bool load_check =
false;
6223 ADE_FUNC(getShipClassIndex,
l_Shipclass, NULL,
"Gets the index valus of the ship class",
"number",
"index value of the ship class")
6229 if(idx < 0 || idx >= static_cast<int>(
Ship_info.size()))
6238 ADE_VIRTVAR(IsHull,
l_Debris,
"boolean",
"Whether or not debris is a piece of hull",
"boolean",
"Whether debris is a hull fragment, or false if handle is invalid")
6258 ADE_VIRTVAR(OriginClass,
l_Debris,
"shipclass",
"The shipclass of the ship this debris originates from",
"shipclass",
"The shipclass of the ship that created this debris")
6271 if (shipIdx >= 0 && shipIdx < static_cast<int>(
Ship_info.size()))
6278 ADE_FUNC(getDebrisRadius,
l_Debris, NULL,
"The radius of this debris piece",
"number",
"The radius of this debris piece or -1 if invalid")
6300 ADE_FUNC(isValid,
l_Debris, NULL,
"Return if this debris handle is valid",
"boolean",
"true if valid false otherwise")
6325 if ( wlname != NULL ) {
6331 return (wlp != NULL && !strcmp(wlp->
get_name(),
name));
6337 ADE_INDEXER(
l_WaypointList,
"number Index",
"Array of waypoints that are part of the waypoint list",
"waypoint",
"Waypoint, or invalid handle if the index or waypointlist handle is invalid")
6354 if( (idx >= 0) && ((
uint) idx < wlh->wlp->get_waypoints().size()) && (wpt != NULL) && (wpt->get_objnum() >= 0) ) {
6363 "Number of waypoints in the list. "
6364 "Note that the value returned cannot be relied on for more than one frame.",
6366 "Number of waypoints in the list, or 0 if handle is invalid")
6391 ADE_FUNC(isValid,
l_WaypointList, NULL,
"Return if this waypointlist handle is valid",
"boolean",
"true if valid false otherwise")
6443 ADE_FUNC(getList,
l_Waypoint, NULL,
"Returns the waypoint list",
"waypointlist",
"waypointlist handle or invalid handle if waypoint was invalid")
6466 #define SWH_PRIMARY 1
6467 #define SWH_SECONDARY 2
6468 #define SWH_TERTIARY 3
6522 ADE_VIRTVAR(WeaponClass,
l_WeaponBank,
"weaponclass",
"Class of weapon mounted in the bank",
"weaponclass",
"Weapon class, or an invalid weaponclass handle if bank handle is invalid")
6595 "<b>Note:</b> Setting this value actually sets the <i>capacity</i> of the weapon bank. To set the actual maximum ammunition use <tt>AmmoMax = <amount> * class.CargoSize</tt>",
"number",
"Ammo capacity, or 0 if handle is invalid")
6642 ADE_VIRTVAR(Armed,
l_WeaponBank,
"boolean",
"Weapon armed status. Does not take linking into account.",
"boolean",
"True if armed, false if unarmed or handle is invalid")
6652 int new_armed_bank = -1;
6654 new_armed_bank = bh->
bank;
6678 ADE_VIRTVAR(Capacity,
l_WeaponBank,
"number",
"The actual capacity of a weapon bank as specified in the table",
"number",
"The capacity or -1 if handle is invalid")
6681 int newCapacity = -1;
6710 ADE_FUNC(isValid,
l_WeaponBank, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
6771 Error(
LOCATION,
"Tertiary bank support is still in progress");
6782 ADE_VIRTVAR(Linked,
l_WeaponBankType,
"boolean",
"Whether bank is in linked or unlinked fire mode (Primary-only)",
"boolean",
"Link status, or false if handle is invalid")
6814 ADE_VIRTVAR(DualFire,
l_WeaponBankType,
"boolean",
"Whether bank is in dual fire mode (Secondary-only)",
"boolean",
"Dual fire status, or false if handle is invalid")
6846 ADE_FUNC(isValid,
l_WeaponBankType, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
6855 ADE_FUNC(__len,
l_WeaponBankType, NULL,
"Number of weapons in the mounted bank",
"number",
"Number of bank weapons, or 0 if handle is invalid")
6892 ADE_FUNC(__tostring,
l_Subsystem, NULL,
"Returns name of subsystem",
"string",
"Subsystem name, or empty string if handle is invalid")
6904 ADE_VIRTVAR(ArmorClass,
l_Subsystem,
"string",
"Current Armor class",
"string",
"Armor class name, or empty string if none is set")
6932 ADE_VIRTVAR(AWACSIntensity,
l_Subsystem,
"number",
"Subsystem AWACS intensity",
"number",
"AWACS intensity, or 0 if handle is invalid")
6948 ADE_VIRTVAR(AWACSRadius,
l_Subsystem,
"number",
"Subsystem AWACS radius",
"number",
"AWACS radius, or 0 if handle is invalid")
6964 ADE_VIRTVAR(Orientation,
l_Subsystem,
"orientation",
"Orientation of subobject or turret base",
"orientation",
"Subsystem orientation, or null orientation if handle is invalid")
6982 ADE_VIRTVAR(GunOrientation,
l_Subsystem,
"orientation",
"Orientation of turret gun",
"orientation",
"Gun orientation, or null orientation if handle is invalid")
7000 ADE_VIRTVAR(HitpointsLeft,
l_Subsystem,
"number",
"Subsystem hitpoints left",
"number",
"Hitpoints left, or 0 if handle is invalid. Setting a value of 0 will disable it - set a value of -1 or lower to actually blow it up.")
7025 ADE_VIRTVAR(HitpointsMax,
l_Subsystem,
"number",
"Subsystem hitpoints max",
"number",
"Max hitpoints, or 0 if handle is invalid")
7045 ADE_VIRTVAR(Position,
l_Subsystem,
"vector",
"Subsystem position with regards to main ship (Local Vector)",
"vector",
"Subsystem position, or null vector if subsystem handle is invalid")
7063 ADE_VIRTVAR(GunPosition,
l_Subsystem,
"vector",
"Subsystem gun position with regards to main ship (Local vector)",
"vector",
"Gun position, or null vector if subsystem handle is invalid")
7087 ADE_VIRTVAR(Name,
l_Subsystem,
"string",
"Subsystem name",
"string",
"Subsystem name, or an empty string if handle is invalid")
7105 ADE_FUNC(getModelName,
l_Subsystem, NULL,
"Returns the original name of the subsystem in the model file",
"string",
"name or empty string on error")
7117 ADE_VIRTVAR(PrimaryBanks,
l_Subsystem,
"weaponbanktype",
"Array of primary weapon banks",
"weaponbanktype",
"Primary banks, or invalid weaponbanktype handle if subsystem handle is invalid")
7147 ADE_VIRTVAR(SecondaryBanks,
l_Subsystem,
"weaponbanktype",
"Array of secondary weapon banks",
"weaponbanktype",
"Secondary banks, or invalid weaponbanktype handle if subsystem handle is invalid")
7179 ADE_VIRTVAR(Target,
l_Subsystem,
"object",
"Object targeted by this subsystem. If used to set a new target, AI targeting will be switched off.",
"object",
"Targeted object, or invalid object handle if subsystem handle is invalid")
7202 ADE_VIRTVAR(TurretResets,
l_Subsystem,
"boolean",
"Specifies wether this turrets resets after a certain time of inactivity",
"boolean",
"true if turret resets, false otherwise")
7230 ADE_VIRTVAR(TurretResetDelay,
l_Subsystem,
"number",
"The time (in milliseconds) after that the turret resets itself",
"number",
"Reset delay")
7255 float newVal = -1.0f;
7270 ADE_VIRTVAR(Targetable,
l_Subsystem,
"boolean",
"Targetability of this subsystem",
"boolean",
"true if targetable, false otherwise or on error")
7273 bool newVal =
false;
7302 LuaError(L,
"Setting radius for subsystems is not allowed!");
7308 ADE_VIRTVAR(TurretLocked,
l_Subsystem,
"boolean",
"Whether the turret is locked. Setting to true locks the turret, setting to false frees it.",
"boolean",
"True if turret is locked, false otherwise")
7311 bool newVal =
false;
7330 ADE_VIRTVAR(NextFireTimestamp,
l_Subsystem,
"number",
"The next time the turret may attempt to fire",
"number",
"Mission time (seconds) or -1 on error")
7333 float newVal = -1.0f;
7348 ADE_FUNC(targetingOverride,
l_Subsystem,
"boolean",
"If set to true, AI targeting for this turret is switched off. If set to false, the AI will take over again.",
"boolean",
"Returns true if successful, false otherwise")
7350 bool targetOverride =
false;
7364 ADE_FUNC(hasFired,
l_Subsystem, NULL,
"Determine if a subsystem has fired",
"boolean",
"true if if fired, false if not fired, or nil if invalid. resets fired flag when called.")
7380 ADE_FUNC(isTurret,
l_Subsystem, NULL,
"Determines if this subsystem is a turret",
"boolean",
"true if subsystem is turret, false otherwise or nil on error")
7392 ADE_FUNC(isTargetInFOV,
l_Subsystem,
"object Target",
"Determines if the object is in the turrets FOV",
"boolean",
"true if in FOV, false if not, nil on error or if subsystem is not a turret ")
7414 ADE_FUNC(fireWeapon,
l_Subsystem,
"[Turret weapon index = 1, Flak range = 100]",
"Fires weapon on turret", NULL, NULL)
7418 float flak_range = 100.0f;
7444 ADE_FUNC(rotateTurret,
l_Subsystem,
"vector Pos[, boolean reset=false",
"Rotates the turret to face Pos or resets the turret to its original state",
"boolean",
"true on success false otherwise")
7455 object *objp = sso->
objp;
7474 ADE_FUNC(getTurretHeading,
l_Subsystem, NULL,
"Returns the turrets forward vector",
"vector",
"Returns a normalized version of the forward vector or null vector on error")
7484 object *objp = sso->
objp;
7494 ADE_FUNC(getFOVs,
l_Subsystem, NULL,
"Returns current turrets FOVs",
"number, number, number",
"Standard FOV, maximum barrel elevation, turret base fov.")
7497 float fov, fov_e, fov_y;
7513 ADE_FUNC(getNextFiringPosition,
l_Subsystem, NULL,
"Retrieves the next position and firing normal this turret will fire from. This function returns a world position",
"vector, vector",
"vector or null vector on error")
7529 ADE_FUNC(getTurretMatrix,
l_Subsystem, NULL,
"Returns current subsystems turret matrix",
"matrix",
"Turret matrix.")
7546 ADE_FUNC(getParent,
l_Subsystem, NULL,
"The object parent of this subsystem, is of type ship",
"object",
"object handle or invalid handle on error")
7559 ADE_FUNC(isValid,
l_Subsystem, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
7602 if (objh.
objp == NULL || aigp == NULL)
7611 ADE_VIRTVAR(Priority,
l_Order,
"number",
"Priority of the given order",
"number",
"Order priority or 0 if invalid")
7629 ADE_FUNC(
remove,
l_Order, NULL,
"Removes the given order from the ship's priority queue.",
"boolean",
"True if order was successfully removed, otherwise false or nil.")
7645 ADE_FUNC(getType,
l_Order, NULL,
"Gets the type of the order.",
"enumeration",
"The type of the order as one of the ORDER_* enumerations.")
7727 ADE_VIRTVAR(Target,
l_Order,
"object",
"Target of the order. Value may also be a deriviative of the 'object' class, such as 'ship'.",
"object",
"Target object or invalid object handle if order handle is invalid or order requires no target.")
7733 int shipnum = -1, objnum = -1;
7839 objnum = Ships[shipnum].objnum;
7856 objnum = Ships[shipnum].objnum;
7862 if (
Wings[wingnum].current_count > 0){
7864 objnum = Ships[shipnum].objnum;
7873 ADE_VIRTVAR(TargetSubsystem,
l_Order,
"subsystem",
"Target subsystem of the order.",
"subsystem",
"Target subsystem, or invalid subsystem handle if order handle is invalid or order requires no subsystem target.")
7878 object *objp = NULL;
7917 ADE_FUNC(isValid,
l_Order, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
7929 ADE_FUNC(__len,
l_ShipOrders, NULL,
"Number of ship orders",
"number",
"Number of ship orders, or 0 if handle is invalid")
7962 ADE_FUNC(isValid,
l_ShipOrders, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
7976 ADE_FUNC(__len,
l_ShipTextures, NULL,
"Number of textures on ship",
"number",
"Number of textures on ship, or 0 if handle is invalid")
7993 ADE_INDEXER(
l_ShipTextures,
"number Index/string TextureFilename",
"Array of ship textures",
"texture",
"Texture, or invalid texture handle on failure")
8001 if (!oh->
IsValid() || s==NULL)
8006 int final_index = -1;
8036 if (final_index < 0)
8038 final_index = atoi(s) - 1;
8064 ADE_FUNC(isValid,
l_ShipTextures, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
8082 this->m_objp =
objp;
8110 ADE_FUNC(__len,
l_CockpitDisplays, NULL,
"Gets the number of cockpit displays for the player ship",
"number",
"number of displays or -1 on error")
8122 ADE_INDEXER(
l_CockpitDisplays,
"number/string",
"Gets a cockpit display from the present player displays by either the index or the name of the display",
"display",
"Display handle or invalid handle on error")
8124 if (lua_isnumber(L, 2))
8167 if (!strcmp(name, iter->name))
8179 LuaError(L,
"Couldn't find cockpit display info with name \"%s\"", name);
8221 if (idx < 0 || idx >= (
int)
Snds.size())
8245 ADE_VIRTVAR(DefaultVolume,
l_SoundEntry,
"number",
"The default volume of this game sound",
"number",
"Volume in the range from 1 to 0 or -1 on error")
8248 float newVal = -1.0f;
8253 if (seh == NULL || !seh->
IsValid())
8258 if (seh->
Get() != NULL)
8260 CAP(newVal, 0.0f, 1.0f);
8269 ADE_FUNC(getFilename,
l_SoundEntry, NULL,
"Returns the filename of this sound",
"string",
"filename or empty string on error")
8276 if (seh == NULL || !seh->
IsValid())
8282 ADE_FUNC(getDuration,
l_SoundEntry, NULL,
"Gives the length of the sound in seconds.",
"number",
"the length, or -1 on error")
8289 if (seh == NULL || !seh->
IsValid())
8295 ADE_FUNC(get3DValues,
l_SoundEntry,
"vector Postion[, number radius=0.0]",
"Computes the volume and the panning of the sound when it would be played from the specified position.<br>"
8296 "If range is given then the volume will diminish when the listener is withing that distance to the source.<br>"
8297 "The position of the listener is always the the current viewing position.",
"number, number",
"The volume and the panning, in that sequence, or both -1 on error")
8300 vec3d *sourcePos = NULL;
8301 float radius = 0.0f;
8309 if (seh == NULL || !seh->
IsValid())
8324 ADE_FUNC(isValid,
l_SoundEntry, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
8378 ADE_VIRTVAR(Pitch,
l_Sound,
"number",
"Pitch of sound, from 100 to 100000",
"number",
"Pitch, or 0 if handle is invalid")
8392 if(newpitch > 100000)
8401 ADE_FUNC(getRemainingTime,
l_Sound, NULL,
"The remaining time of this sound handle",
"number",
"Remaining time, or -1 on error")
8415 ADE_FUNC(setVolume,
l_Sound,
"number",
"Sets the volume of this sound instance",
"boolean",
"true if succeeded, false otherwise")
8418 float newVol = -1.0f;
8425 CAP(newVol, 0.0f, 1.0f);
8432 ADE_FUNC(setPanning,
l_Sound,
"number",
"Sets the panning of this sound. Argument ranges from -1 for left to 1 for right",
"boolean",
"true if succeeded, false otherwise")
8435 float newPan = -1.0f;
8442 CAP(newPan, -1.0f, 1.0f);
8451 "Sets the absolute position of the sound. If boolean argument is true then the value is given as a percentage<br>"
8452 "This operation fails if there is no backing soundentry!",
8453 "boolean",
"true if successfull, false otherwise")
8457 bool percent =
true;
8472 ADE_FUNC(rewind,
l_Sound,
"number",
"Rewinds the sound by the given number of seconds<br>"
8473 "This operation fails if there is no backing soundentry!",
"boolean",
"true if succeeded, false otherwise")
8492 "This operation fails if there is no backing soundentry!",
"boolean",
"true if succeeded, false otherwise")
8510 ADE_FUNC(isPlaying,
l_Sound, NULL,
"Specifies if this handle is currently playing",
"boolean",
"true if playing, false if otherwise")
8522 ADE_FUNC(stop,
l_Sound, NULL,
"Stops the sound of this handle",
"boolean",
"true if succeeded, false otherwise")
8536 ADE_FUNC(isValid,
l_Sound, NULL,
"Detects whether the whole handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
8545 ADE_FUNC(isSoundValid,
l_Sound, NULL,
"Checks if only the sound is valid, should be used for non soundentry sounds",
8546 "boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
8557 ADE_FUNC(updatePosition,
l_Sound3D,
"vector Position[, number radius = 0.0]",
"Updates the given 3D sound with the specified position and an optional range value",
"boolean",
"true if succeesed, false otherwise")
8560 vec3d *newPos = NULL;
8561 float radius = 0.0f;
8566 if (!sh->
IsValid() || newPos == NULL)
8577 ADE_VIRTVAR(Duration,
l_Soundfile,
"number",
"The duration of the sound file, in seconds",
"number",
"The duration or -1 on error")
8608 ADE_FUNC(play,
l_Soundfile,
"[number volume = 1.0[, number panning = 0.0]]",
"Plays the sound",
"sound",
"A sound handle or invalid handle on error")
8611 float volume = 1.0f;
8612 float panning = 0.0f;
8622 LuaError(L,
"Invalid volume value of %f specified!", volume);
8631 ADE_FUNC(isValid,
l_Soundfile, NULL,
"Checks if the soundfile handle is valid",
"boolean",
"true if valid, false otherwise")
8659 ADE_FUNC(isValid,
l_Persona, NULL,
"Detect if the handle is valid",
"boolean",
"true if valid, false otherwise")
8672 ADE_VIRTVAR(Name,
l_Message,
"string",
"The name of the message as specified in the mission file",
"string",
"The name or an empty string if handle is invalid")
8678 if (idx < 0 && idx >= (
int)
Messages.size())
8684 ADE_VIRTVAR(Message,
l_Message,
"string",
"The unaltered text of the message, see getMessage() for options to replace variables<br>"
8685 "<b>NOTE:</b> Changing the text will also change the text for messages not yet played but already in the message queue!",
8686 "string",
"The message or an empty string if handle is invalid")
8689 char* newText = NULL;
8693 if (idx < 0 && idx >= (
int)
Messages.size())
8708 extern int add_wave(
const char *wave_name );
8709 ADE_VIRTVAR(VoiceFile,
l_Message,
"soundfile",
"The voice file of the message",
"soundfile",
"The voice file handle or invalid handle when not present")
8717 if (idx < 0 && idx >= (
int)
Messages.size())
8753 int newPersona = -1;
8758 if (idx < 0 && idx >= (
int)
Messages.size())
8769 ADE_FUNC(getMessage,
l_Message,
"[boolean replaceVars = true]",
"Gets the text of the message and optionally replaces SEXP variables with their respective values.",
"string",
"The message or an empty string if handle is invalid")
8772 bool replace =
true;
8776 if (idx < 0 && idx >= (
int)
Messages.size())
8792 ADE_FUNC(isValid,
l_Message, NULL,
"Checks if the message handle is valid",
"boolean",
"true if valid, false otherwise")
8804 ADE_INDEXER(
l_Wing,
"number Index",
"Array of ships in the wing",
"ship",
"Ship handle, or invalid ship handle if index is invalid or wing handle is invalid")
8812 if(wdx < 0 || wdx >=
Num_wings || sdx < 1 || sdx >
Wings[wdx].current_count) {
8826 ADE_FUNC(__len,
l_Wing, NULL,
"Gets the number of ships in the wing",
"number",
"Number of ships in wing, or 0 if invalid handle")
8835 ADE_VIRTVAR(Name,
l_Wing,
"string",
"Name of Wing",
"string",
"Wing name, or empty string if handle is invalid")
8849 ADE_FUNC(isValid,
l_Wing, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
8864 ADE_INDEXER(
l_Ship,
"string Name/number Index",
"Array of ship subsystems",
"subsystem",
"Subsystem handle, or invalid subsystem handle if index or ship handle is invalid")
8894 ADE_FUNC(__len,
l_Ship, NULL,
"Number of subsystems on ship",
"number",
"Subsystem number, or 0 if handle is invalid")
8906 ADE_VIRTVAR(ShieldArmorClass,
l_Ship,
"string",
"Current Armor class of the ships' shield",
"string",
"Armor class name, or empty string if none is set")
8933 ADE_VIRTVAR(ArmorClass,
l_Ship,
"string",
"Current Armor class",
"string",
"Armor class name, or empty string if none is set")
8960 ADE_VIRTVAR(Name,
l_Ship,
"string",
"Ship name",
"string",
"Ship name, or empty string if handle is invalid")
8979 ADE_VIRTVAR(AfterburnerFuelLeft,
l_Ship,
"number",
"Afterburner fuel left",
"number",
"Afterburner fuel left, or 0 if handle is invalid")
8997 ADE_VIRTVAR(AfterburnerFuelMax,
l_Ship,
"number",
"Afterburner fuel capacity",
"number",
"Afterburner fuel capacity, or 0 if handle is invalid")
9015 ADE_VIRTVAR(Class,
l_Ship,
"shipclass",
"Ship class",
"shipclass",
"Ship class, or invalid shipclass handle if ship handle is invalid")
9040 ADE_VIRTVAR(CountermeasuresLeft,
l_Ship,
"number",
"Number of countermeasures left",
"number",
"Countermeasures left, or 0 if ship handle is invalid")
9058 ADE_VIRTVAR(CockpitDisplays,
l_Ship,
"displays",
"An array of the cockpit displays on this ship.<br>NOTE: Only the ship of the player has these",
"displays",
"displays handle or invalid handle on error")
9070 LuaError(L,
"Attempted to use incomplete feature: Cockpit displays copy");
9076 ADE_VIRTVAR(CountermeasureClass,
l_Ship,
"weaponclass",
"Weapon class mounted on this ship's countermeasure point",
"weaponclass",
"Countermeasure hardpoint weapon class, or invalid weaponclass handle if no countermeasure class or ship handle is invalid")
9098 ADE_VIRTVAR(HitpointsMax,
l_Ship,
"number",
"Total hitpoints",
"number",
"Ship maximum hitpoints, or 0 if handle is invalid")
9116 ADE_VIRTVAR(WeaponEnergyLeft,
l_Ship,
"number",
"Current weapon energy reserves",
"number",
"Ship current weapon energy reserve level, or 0 if invalid")
9134 ADE_VIRTVAR(WeaponEnergyMax,
l_Ship,
"number",
"Maximum weapon energy",
"number",
"Ship maximum weapon energy reserve level, or 0 if invalid")
9152 ADE_VIRTVAR(AutoaimFOV,
l_Ship,
"number",
"FOV of ship's autoaim, if any",
"number",
"FOV (in degrees), or 0 if ship uses no autoaim or if handle is invalid")
9174 ADE_VIRTVAR(PrimaryTriggerDown,
l_Ship,
"boolean",
"Determines if primary trigger is pressed or not",
"boolean",
"True if pressed, false if not, nil if ship handle is invalid")
9201 ADE_VIRTVAR(PrimaryBanks,
l_Ship,
"weaponbanktype",
"Array of primary weapon banks",
"weaponbanktype",
"Primary weapon banks, or invalid weaponbanktype handle if ship handle is invalid")
9232 ADE_VIRTVAR(SecondaryBanks,
l_Ship,
"weaponbanktype",
"Array of secondary weapon banks",
"weaponbanktype",
"Secondary weapon banks, or invalid weaponbanktype handle if ship handle is invalid")
9264 ADE_VIRTVAR(TertiaryBanks,
l_Ship,
"weaponbanktype",
"Array of tertiary weapon banks",
"weaponbanktype",
"Tertiary weapon banks, or invalid weaponbanktype handle if ship handle is invalid")
9292 ADE_VIRTVAR(Target,
l_Ship,
"object",
"Target of ship. Value may also be a deriviative of the 'object' class, such as 'ship'.",
"object",
"Target object, or invalid object handle if no target or ship handle is invalid")
9336 ADE_VIRTVAR(TargetSubsystem,
l_Ship,
"subsystem",
"Target subsystem of ship.",
"subsystem",
"Target subsystem, or invalid subsystem handle if no target or ship handle is invalid")
9382 ADE_VIRTVAR(Team,
l_Ship,
"team",
"Ship's team",
"team",
"Ship team, or invalid team handle if ship handle is invalid")
9401 ADE_VIRTVAR(Textures,
l_Ship,
"shiptextures",
"Gets ship textures",
"shiptextures",
"Ship textures, or invalid shiptextures handle if ship handle is invalid")
9427 ADE_VIRTVAR(FlagAffectedByGravity,
l_Ship,
"boolean",
"Checks for the \"affected-by-gravity\" flag",
"boolean",
"True if flag is set, false if flag is not set and nil on error")
9455 ADE_VIRTVAR(Disabled,
l_Ship,
"boolean",
"The disabled state of this ship",
"boolean",
"true if ship is diabled, false otherwise")
9488 ADE_VIRTVAR(Stealthed,
l_Ship,
"boolean",
"Stealth status of this ship",
"boolean",
"true if stealthed, false otherwise or on error")
9491 bool stealthed =
false;
9519 ADE_VIRTVAR(HiddenFromSensors,
l_Ship,
"boolean",
"Hidden from sensors status of this ship",
"boolean",
"true if invisible to hidden from sensors, false otherwise or on error")
9522 bool hidden =
false;
9550 ADE_VIRTVAR(Gliding,
l_Ship,
"boolean",
"Specifies whether this ship is currently gliding or not.",
"boolean",
"true if gliding, false otherwise or in case of error")
9553 bool gliding =
false;
9577 ADE_VIRTVAR(EtsEngineIndex,
l_Ship,
"number",
"(not implemented)",
"number",
"Ships ETS Engine index value, 0 to MAX_ENERGY_INDEX")
9589 LuaError(L,
"Attempted to set incomplete feature: ETS Engine Index (see EtsSetIndexes)");
9594 ADE_VIRTVAR(EtsShieldIndex,
l_Ship,
"number",
"(not implemented)",
"number",
"Ships ETS Shield index value, 0 to MAX_ENERGY_INDEX")
9606 LuaError(L,
"Attempted to set incomplete feature: ETS Shield Index (see EtsSetIndexes)");
9611 ADE_VIRTVAR(EtsWeaponIndex,
l_Ship,
"number",
"(not implemented)",
"number",
"Ships ETS Weapon index value, 0 to MAX_ENERGY_INDEX")
9623 LuaError(L,
"Attempted to set incomplete feature: ETS Weapon Index (see EtsSetIndexes)");
9628 ADE_VIRTVAR(Orders,
l_Ship,
"shiporders",
"Array of ship orders",
"shiporders",
"Ship orders, or invalid handle if ship handle is invalid")
9640 LuaError(L,
"Attempted to use incomplete feature: Ai orders copy. Use giveOrder instead");
9646 ADE_FUNC(kill,
l_Ship,
"[object Killer]",
"Kills the ship. Set \"Killer\" to the ship you are killing to self-destruct",
"boolean",
"True if successful, false or nil otherwise")
9655 if(!killer || !killer->
IsValid())
9660 if (percent_killed > 1.0f){
9661 percent_killed = 1.0f;
9669 ADE_FUNC(addShipEffect,
l_Ship,
"string name, int duration (in milliseconds)",
"Activates an effect for this ship. Effect names are defined in Post_processing.tbl, and need to be implemented in the main shader. This functions analogous to the ship-effect sexp. NOTE: only one effect can be active at any time, adding new effects will override effects already in progress.\n",
"boolean",
"Returns true if the effect was successfully added, false otherwise") {
9671 char* effect = NULL;
9682 if (effect_num == -1)
9695 ADE_FUNC(hasShipExploded,
l_Ship, NULL,
"Checks if the ship explosion event has already happened",
"number",
"Returns 1 if first explosion timestamp is passed, 2 if second is passed, 0 otherwise")
9719 ADE_FUNC(fireCountermeasure,
l_Ship, NULL,
"Launches a countermeasure from the ship",
"boolean",
"Whether countermeasure was launched or not")
9731 ADE_FUNC(firePrimary,
l_Ship, NULL,
"Fires ship primary bank(s)",
"number",
"Number of primary banks fired")
9747 ADE_FUNC(fireSecondary,
l_Ship, NULL,
"Fires ship secondary bank(s)",
"number",
"Number of secondary banks fired")
9759 ADE_FUNC(getAnimationDoneTime,
l_Ship,
"number Type, number Subtype",
"Gets time that animation will be done",
"number",
"Time (seconds), or 0 if ship handle is invalid")
9780 ADE_FUNC(clearOrders,
l_Ship, NULL,
"Clears a ship's orders list",
"boolean",
"True if successful, otherwise false or nil")
9794 ADE_FUNC(giveOrder,
l_Ship,
"enumeration Order, [object Target=nil, subsystem TargetSubsystem=nil, number Priority=1.0]",
"Uses the goal code to execute orders",
"boolean",
"True if order was given, otherwise false or nil")
9798 float priority = 1.0f;
9814 bool tgh_valid = tgh && tgh->
IsValid();
9815 bool tgsh_valid = tgsh && tgsh->
IsValid();
9817 int ai_submode = -1234567;
9818 char *ai_shipname = NULL;
10048 ADE_FUNC(doManeuver,
l_Ship,
"number Duration, number Heading, number Pitch, number Bank, boolean Force Rotation, number Vertical, number Horizontal, number Forward, boolean Force Movement",
"Sets ship maneuver over the defined time period",
"boolean",
"True if maneuver order was given, otherwise false or nil")
10052 bool f_rot =
false, f_move =
false;
10054 if(!
ade_get_args(L,
"oifffbfffb",
l_Ship.GetPtr(&objh), &
t, &arr[0], &arr[1], &arr[2], &f_rot, &arr[3], &arr[4], &arr[5], &f_move))
10067 for(i = 0; i < 6; i++) {
10068 if((arr[i] < -1.0f) || (arr[i] > 1.0f))
10075 cip->
pitch = arr[1];
10076 cip->
bank = arr[2];
10083 cip->
pitch = arr[1];
10087 cip->
bank = arr[2];
10114 "Triggers an animation. Type is the string name of the animation type, "
10115 "Subtype is the subtype number, such as weapon bank #, and Forwards is boolean."
10116 "<br><strong>IMPORTANT: Function is in testing and should not be used with official mod releases</strong>",
10118 "True if successful, false or nil otherwise")
10143 ADE_FUNC(warpIn,
l_Ship, NULL,
"Warps ship in",
"boolean",
"True if successful, or nil if ship handle is invalid")
10157 ADE_FUNC(warpOut,
l_Ship, NULL,
"Warps ship out",
"boolean",
"True if successful, or nil if ship handle is invalid")
10171 ADE_FUNC(canWarp,
l_Ship, NULL,
"Checks whether ship has a working subspace drive and is allowed to use it",
"boolean",
"True if successful, or nil if ship handle is invalid")
10189 ADE_FUNC(isWarpingIn,
l_Ship, NULL,
"Checks if ship is warping in",
"boolean",
"True if the ship is warping in, false or nil otherwise")
10206 ADE_FUNC(getEMP,
l_Ship, NULL,
"Returns the current emp effect strength acting on the object",
"number",
"Current EMP effect strength or NIL if object is invalid")
10209 object *obj = NULL;
10225 ADE_FUNC(getTimeUntilExplosion,
l_Ship, NULL,
"Returns the time in seconds until the ship explodes",
"number",
"Time until explosion or -1, if invalid handle or ship isn't exploding")
10248 ADE_FUNC(getCallsign,
l_Ship, NULL,
"Gets the callsign of the ship in the current mission",
"string",
"The callsign or an empty string if the ship doesn't have a callsign or an error occurs")
10266 *temp_callsign = 0;
10269 if (*temp_callsign)
10275 ADE_FUNC(getAltClassName,
l_Ship, NULL,
"Gets the alternate class name of the ship",
"string",
"The alternate class name or an empty string if the ship doesn't have such a thing or an error occurs")
10302 ADE_FUNC(getMaximumSpeed,
l_Ship,
"[number energy = 0.333]",
"Gets the maximum speed of the ship with the given energy on the engines",
"number",
"The maximum speed or -1 on error")
10305 float energy = 0.333f;
10314 if (energy < 0.0f || energy > 1.0f)
10316 LuaError(L,
"Invalid energy level %f! Needs to be in [0, 1].", energy);
10326 ADE_FUNC(EtsSetIndexes,
l_Ship,
"number Engine Index, number Shield Index, number Weapon Index",
10327 "Sets ships ETS systems to specified values",
10329 "True if successful, false if target ships ETS was missing, or only has one system")
10353 ADE_FUNC(getWing,
l_Ship, NULL,
"Returns the ship's wing",
"wing",
"Wing handle, or invalid wing handle if ship is not part of a wing")
10356 ship *shipp = NULL;
10371 ADE_VIRTVAR(Class,
l_Weapon,
"weaponclass",
"Weapon's class",
"weaponclass",
"Weapon class, or invalid weaponclass handle if weapon handle is invalid")
10390 ADE_VIRTVAR(DestroyedByWeapon,
l_Weapon,
"boolean",
"Whether weapon was destroyed by another weapon",
"boolean",
"True if weapon was destroyed by another weapon, false if weapon was destroyed by another object or if weapon handle is invalid")
10415 ADE_VIRTVAR(LifeLeft,
l_Weapon,
"number",
"Weapon life left (in seconds)",
"number",
"Life left (seconds) or 0 if weapon handle is invalid")
10434 ADE_VIRTVAR(FlakDetonationRange,
l_Weapon,
"number",
"Range at which flak will detonate (meters)",
"number",
"Detonation range (meters) or 0 if weapon handle is invalid")
10453 ADE_VIRTVAR(Target,
l_Weapon,
"object",
"Target of weapon. Value may also be a deriviative of the 'object' class, such as 'ship'.",
"object",
"Weapon target, or invalid object handle if weapon handle is invalid")
10487 ADE_VIRTVAR(ParentTurret,
l_Weapon,
"subsystem",
"Turret which fired this weapon.",
"subsystem",
"Turret subsystem handle, or an invalid handle if the weapon not fired from a turret")
10524 ADE_VIRTVAR(HomingObject,
l_Weapon,
"object",
"Object that weapon will home in on. Value may also be a deriviative of the 'object' class, such as 'ship'",
"object",
"Object that weapon is homing in on, or an invalid object handle if weapon is not homing or the weapon handle is invalid")
10561 ADE_VIRTVAR(HomingPosition,
l_Weapon,
"vector",
"Position that weapon will home in on (World vector), setting this without a homing object in place will not have any effect!",
10562 "vector",
"Homing point, or null vector if weapon handle is invalid")
10565 vec3d *v3 =
nullptr;
10593 ADE_VIRTVAR(HomingSubsystem,
l_Weapon,
"subsystem",
"Subsystem that weapon will home in on.",
"subsystem",
"Homing subsystem, or invalid subsystem handle if weapon is not homing or weapon handle is invalid")
10631 ADE_VIRTVAR(Team,
l_Weapon,
"team",
"Weapon's team",
"team",
"Weapon team, or invalid team handle if weapon handle is invalid")
10650 ADE_FUNC(isArmed,
l_Weapon,
"[boolean Hit target]",
"Checks if the weapon is armed.",
"boolean",
"boolean value of the weapon arming status")
10653 bool hit_target =
false;
10668 ADE_FUNC(getCollisionInformation,
l_Weapon, NULL,
"Returns the collision information for this weapon",
"collision info",
"The collision information or invalid handle if none")
10689 ADE_VIRTVAR(Class,
l_Beam,
"weaponclass",
"Weapon's class",
"weaponclass",
"Weapon class, or invalid weaponclass handle if beam handle is invalid")
10708 ADE_VIRTVAR(LastShot,
l_Beam,
"vector",
"End point of the beam",
"vector",
"vector or null vector if beam handle is not valid")
10711 vec3d *vec3 =
nullptr;
10727 ADE_VIRTVAR(LastStart,
l_Beam,
"vector",
"Start point of the beam",
"vector",
"vector or null vector if beam handle is not valid")
10730 vec3d *v3 =
nullptr;
10746 ADE_VIRTVAR(Target,
l_Beam,
"object",
"Target of beam. Value may also be a deriviative of the 'object' class, such as 'ship'.",
"object",
"Beam target, or invalid object handle if beam handle is invalid")
10782 ADE_VIRTVAR(TargetSubsystem,
l_Beam,
"subsystem",
"Subsystem that beam is targeting.",
"subsystem",
"Target subsystem, or invalid subsystem handle if beam handle is invalid")
10819 ADE_VIRTVAR(ParentShip,
l_Beam,
"object",
"Parent of the beam.",
"object",
"Beam parent, or invalid object handle if beam handle is invalid")
10839 if(bp->
sig != newh->
sig)
10855 ADE_VIRTVAR(ParentSubsystem,
l_Beam,
"subsystem",
"Subsystem that beam is fired from.",
"subsystem",
"Parent subsystem, or invalid subsystem handle if beam handle is invalid")
10875 if(bp->
sig != newh->
sig)
10891 ADE_FUNC(getCollisionCount,
l_Beam, NULL,
"Get the number of collisions in frame.",
"number",
"Number of beam collisions")
10906 ADE_FUNC(getCollisionPosition,
l_Beam,
"number",
"Get the position of the defined collision.",
"vector",
"World vector")
10928 ADE_FUNC(getCollisionInformation,
l_Beam,
"number",
"Get the collision information of the specified collision",
"collision info",
"handle to information or invalid handle on error")
10950 ADE_FUNC(getCollisionObject,
l_Beam,
"number",
"Get the target of the defined collision.",
"object",
"Object the beam collided with")
10972 ADE_FUNC(isExitCollision,
l_Beam,
"number",
"Checks if the defined collision was exit collision.",
"boolean",
"True if the collision was exit collision, false if entry, nil otherwise")
10997 ADE_FUNC(getStartDirectionInfo,
l_Beam, NULL,
"Gets the start information about the direction. The vector is a normalized vector from LastStart showing the start direction of a slashing beam",
"vector",
"The start direction or null vector if invalid")
11014 ADE_FUNC(getEndDirectionInfo,
l_Beam, NULL,
"Gets the end information about the direction. The vector is a normalized vector from LastStart showing the end direction of a slashing beam",
"vector",
"The start direction or null vector if invalid")
11034 ADE_FUNC(isValid,
l_Player, NULL,
"Detects whether handle is valid",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
11046 ADE_FUNC(getName,
l_Player, NULL,
"Gets current player name",
"string",
"Player name, or empty string if handle is invalid")
11058 ADE_FUNC(getCampaignFilename,
l_Player, NULL,
"Gets current player campaign filename",
"string",
"Campaign name, or empty string if handle is invalid")
11070 ADE_FUNC(getImageFilename,
l_Player, NULL,
"Gets current player image filename",
"string",
"Player image filename, or empty string if handle is invalid")
11082 ADE_FUNC(getMainHallName,
l_Player, NULL,
"Gets player's current main hall name",
"string",
"Main hall name, or name of first mainhall in campaign if something goes wrong")
11096 ADE_FUNC(getMainHallIndex,
l_Player, NULL,
"Gets player's current main hall number",
"number",
"Main hall index, or index of first mainhall in campaign if something goes wrong")
11109 ADE_FUNC(getSquadronName,
l_Player, NULL,
"Gets current player squad name",
"string",
"Squadron name, or empty string if handle is invalid")
11121 ADE_FUNC(getMultiSquadronName,
l_Player, NULL,
"Gets current player multi squad name",
"string",
"Squadron name, or empty string if handle is invalid")
11146 ADE_FUNC(__tostring,
l_Camera, NULL,
"Camera name",
"string",
"Camera name, or an empty string if handle is invalid")
11158 ADE_FUNC(isValid,
l_Camera, NULL,
"True if valid, false or nil if not",
"boolean",
"true if valid, false if handle is invalid, nil if a syntax/type error occurs")
11259 ADE_VIRTVAR(SelfSubsystem,
l_Camera,
"subsystem",
"New mount object subsystem",
"subsystem",
"Subsystem that the camera is mounted on")
11314 ADE_VIRTVAR(TargetSubsystem,
l_Camera,
"subsystem",
"New target subsystem",
"subsystem",
"Subsystem that the camera is pointed at")
11352 ADE_FUNC(setFOV,
l_Camera,
"[number FOV, number Zoom Time, number Zoom Acceleration Time, number Zoom deceleration Time]",
11354 "<br>FOV is the final field of view, in radians, of the camera."
11355 "<br>Zoom Time is the total time to take zooming in or out."
11356 "<br>Acceleration Time is the total time it should take the camera to get up to full zoom speed."
11357 "<br>Deceleration Time is the total time it should take the camera to slow down from full zoom speed.",
11358 "boolean",
"true if successful, false or nil otherwise")
11363 float acc_time=0.0f;
11364 float dec_time=0.0f;
11376 ADE_FUNC(setOrientation,
l_Camera,
"[world orientation Orientation, number Rotation Time, number Acceleration Time, number Deceleration time]",
11377 "Sets camera orientation and velocity data."
11378 "<br>Orientation is the final orientation for the camera, after it has finished moving. If not specified, the camera will simply stop at its current orientation."
11379 "<br>Rotation time (seconds) is how long total, including acceleration, the camera should take to rotate. If it is not specified, the camera will jump to the specified orientation."
11380 "<br>Acceleration time (seconds) is how long it should take the camera to get 'up to speed'. If not specified, the camera will instantly start moving."
11381 "<br>Deceleration time (seconds) is how long it should take the camera to slow down. If not specified, the camera will instantly stop moving.",
11382 "boolean",
"true if successful, false or nil otherwise")
11387 float acc_time=0.0f;
11388 float dec_time=0.0f;
11409 ADE_FUNC(setPosition,
l_Camera,
"[wvector Position, number Translation Time, number Acceleration Time, number Deceleration Time]",
11410 "Sets camera position and velocity data."
11411 "<br>Position is the final position for the camera. If not specified, the camera will simply stop at its current position."
11412 "<br>Translation time (seconds) is how long total, including acceleration, the camera should take to move. If it is not specified, the camera will jump to the specified position."
11413 "<br>Acceleration time (seconds) is how long it should take the camera to get 'up to speed'. If not specified, the camera will instantly start moving."
11414 "<br>Deceleration time (seconds) is how long it should take the camera to slow down. If not specified, the camera will instantly stop moving.",
11415 "boolean",
"true if successful, false or nil otherwise")
11420 float acc_time=0.0f;
11421 float dec_time=0.0f;
11439 float new_ci = 0.0f;
11454 float new_ci = 0.0f;
11469 float new_ci = 0.0f;
11484 float new_ci = 0.0f;
11499 float new_ci = 0.0f;
11514 float new_ci = 0.0f;
11529 float new_ci = 0.0f;
11541 ADE_VIRTVAR(PrimaryCount,
l_Control_Info,
"number",
"Number of primary weapons that will fire",
"number",
"Number of weapons to fire, or 0 if handle is invalid")
11556 ADE_VIRTVAR(SecondaryCount,
l_Control_Info,
"number",
"Number of secondary weapons that will fire",
"number",
"Number of weapons to fire, or 0 if handle is invalid")
11571 ADE_VIRTVAR(CountermeasureCount,
l_Control_Info,
"number",
"Number of countermeasures that will launch",
"number",
"Number of countermeasures to launch, or 0 if handle is invalid")
11593 ADE_FUNC(getButtonInfo,
l_Control_Info, NULL,
"Access the four bitfields containing the button info",
"number, number, number,number",
"Four bitfields")
11601 return ade_set_args(L,
"iiii", bi_status[0], bi_status[1], bi_status[2], bi_status[3]);
11604 ADE_FUNC(accessButtonInfo,
l_Control_Info,
"number, number, number, number",
"Access the four bitfields containing the button info",
"number, number, number,number",
"Four bitfields")
11612 if(!
ade_get_args(L,
"|iiii", &bi_status[0], &bi_status[1], &bi_status[2], &bi_status[3]))
11623 return ade_set_args(L,
"iiii", bi_status[0], bi_status[1], bi_status[2], bi_status[3]);
11626 ADE_FUNC(useButtonControl,
l_Control_Info,
"number, string",
"Adds the defined button control to lua button control data, if number is -1 it tries to use the string", NULL, NULL)
11636 if (index > (4 * 32))
11645 }
else if (buf != NULL) {
11648 if(!(strcmp(buf, plr_commands[i].
name))) {
11650 a = plr_commands[
i].
def / 32;
11660 ADE_FUNC(getButtonControlName,
l_Control_Info,
"number",
"Gives the name of the command corresponding with the given number",
"string",
"Name of the command")
11667 if((index < 0) || (index > num_plr_commands))
11673 ADE_FUNC(getButtonControlNumber,
l_Control_Info,
"string",
"Gives the number of the command corresponding with the given string",
"number",
"Number of the command")
11682 if (!(strcmp(buf, plr_commands[i].
name))) {
11690 ADE_VIRTVAR(AllButtonPolling,
l_Control_Info,
"boolean",
"Toggles the all button polling for lua",
"boolean",
"If the all button polling is enabled or not")
11711 ADE_FUNC(pollAllButtons,
l_Control_Info, NULL,
"Access the four bitfields containing the button info",
"number, number, number,number",
"Four bitfields")
11722 return ade_set_args(L,
"iiii", bi_status[0], bi_status[1], bi_status[2], bi_status[3]);
11738 this->part = part_p;
11739 if (part_p != NULL)
11764 ADE_VIRTVAR(Position,
l_Particle,
"vector",
"The current position of the particle (world vector)",
"vector",
"The current position")
11785 ADE_VIRTVAR(Velocity,
l_Particle,
"vector",
"The current velocity of the particle (world vector)",
"vector",
"The current velocity")
11809 float newAge = -1.0f;
11822 ph->
Get()->
age = newAge;
11828 ADE_VIRTVAR(MaximumLife,
l_Particle,
"number",
"The time this particle can live",
"number",
"The maximal life or -1 on error")
11831 float newLife = -1.0f;
11853 float newRadius = -1.0f;
11865 if (newRadius >= 0)
11875 float newTracer = -1.0f;
11887 if (newTracer >= 0)
11894 ADE_VIRTVAR(AttachedObject,
l_Particle,
"object",
"The object this particle is attached to. If valid the position will be relativ to this object and the velocity will be ignored.",
"object",
"Attached object or invalid object handle on error")
11909 if (newObj && newObj->
IsValid())
11916 ADE_FUNC(isValid,
l_Particle, NULL,
"Detects whether this handle is valid",
"boolean",
"true if valid false if not")
11931 ADE_FUNC(getSoundentry,
l_Audio,
"string/number",
"Return a sound entry matching the specified index or name. If you are using a number then the first valid index is 1",
"soundentry",
"soundentry or invalid handle on error")
11935 if (lua_isnumber(L, 1))
11965 ADE_FUNC(loadSoundfile,
l_Audio,
"string filename",
"Loads the specified sound file",
"soundfile",
"A soundfile handle")
11967 char* fileName = NULL;
11973 strcpy_s( tmp_gs.filename, fileName );
11979 ADE_FUNC(playSound,
l_Audio,
"soundentry",
"Plays the specified sound entry handle",
"sound",
"A handle to the playing sound")
11986 if (seh == NULL || !seh->
IsValid())
12001 ADE_FUNC(playLoopingSound,
l_Audio,
"soundentry",
"Plays the specified sound as a looping sound",
"sound",
"A handle to the playing sound or invalid handle if playback failed")
12008 if (seh == NULL || !seh->
IsValid())
12023 ADE_FUNC(play3DSound,
l_Audio,
"soundentry[, vector source[, vector listener]]",
"Plays the specified sound entry handle. Source if by default 0, 0, 0 and listener is by default the current viewposition",
"3Dsound",
"A handle to the playing sound")
12032 if (seh == NULL || !seh->
IsValid())
12047 ADE_FUNC(playGameSound,
l_Audio,
"Sound index, [Panning (-1.0 left to 1.0 right), Volume %, Priority 0-3, Voice Message?]",
"Plays a sound from #Game Sounds in sounds.tbl. A priority of 0 indicates that the song must play; 1-3 will specify the maximum number of that sound that can be played",
"boolean",
"True if sound was played, false if not (Replaced with a sound instance object in the future)")
12049 int idx, gamesnd_idx;
12053 bool voice_msg =
false;
12054 if(!
ade_get_args(L,
"i|ffib", &idx, &pan, &vol, &pri, &voice_msg))
12060 if(pri < 0 || pri > 3)
12063 CLAMP(pan, -1.0f, 1.0f);
12064 CLAMP(vol, 0.0f, 100.0f);
12068 if (gamesnd_idx >= 0) {
12069 int sound_handle =
snd_play(&
Snds[gamesnd_idx], pan, vol*0.01f, pri, voice_msg);
12072 LuaError(L,
"Invalid sound index %i (Snds[%i]) in playGameSound()", idx, gamesnd_idx);
12077 ADE_FUNC(playInterfaceSound,
l_Audio,
"Sound index",
"Plays a sound from #Interface Sounds in sounds.tbl",
"boolean",
"True if sound was played, false if not")
12079 int idx, gamesnd_idx;
12085 if (gamesnd_idx >= 0) {
12089 LuaError(L,
"Invalid sound index %i (Snds[%i]) in playInterfaceSound()", idx, gamesnd_idx);
12095 ADE_FUNC(playMusic,
l_Audio,
"string Filename, [float volume = 1.0, bool looping = true]",
"Plays a music file using FS2Open's builtin music system. Volume is currently ignored, uses players music volume setting. Files passed to this function are looped by default.",
"number",
"Audiohandle of the created audiostream, or -1 on failure")
12098 float volume = 1.0f;
12114 ADE_FUNC(stopMusic,
l_Audio,
"int audiohandle, [bool fade = false], [string 'briefing|credits|mainhall']",
"Stops a playing music file, provided audiohandle is valid. If the 3rd arg is set to one of briefing,credits,mainhall then that music will be stopped despite the audiohandle given.", NULL, NULL)
12118 char *music_type = NULL;
12126 if (music_type == NULL) {
12129 if (!
stricmp(music_type,
"briefing")) {
12131 }
else if (!
stricmp(music_type,
"credits")) {
12133 }
else if (!
stricmp(music_type,
"mainhall")) {
12136 LuaError(L,
"Invalid music type (%s) passed to stopMusic", music_type);
12143 ADE_FUNC(pauseMusic,
l_Audio,
"int audiohandle, bool pause",
"Pauses or unpauses a playing music file, provided audiohandle is valid. The boolean argument should be true to pause and false to unpause. If the audiohandle is -1, *all* audio streams are paused or unpaused.", NULL, NULL)
12171 ade_lib l_Base(
"Base", NULL,
"ba",
"Base FreeSpace 2 functions");
12175 mprintf((
"%s", lua_tostring(L, -1)));
12180 ADE_FUNC(warning,
l_Base,
"string Message",
"Displays a FreeSpace warning (debug build-only) message with the string provided", NULL, NULL)
12187 ADE_FUNC(error,
l_Base,
"string Message",
"Displays a FreeSpace error message with the string provided", NULL, NULL)
12194 ADE_FUNC(createOrientation,
l_Base,
"[p/r1c1, b/r1c2, h/r1c3, r2c1, r2c2, r2c3, r3c1, r3c2, r3c3]",
"Given 0, 3, or 9 arguments, creates an orientation object with that orientation.",
"orientation",
"New orientation object, or null orientation on failure")
12197 int numargs =
ade_get_args(L,
"|fffffffff", &m.
a1d[0], &m.
a1d[1], &m.
a1d[2], &m.
a1d[3], &m.
a1d[4], &m.
a1d[5], &m.
a1d[6], &m.
a1d[7], &m.
a1d[8]);
12202 else if(numargs == 3)
12207 else if(numargs == 9)
12215 ADE_FUNC(createVector,
l_Base,
"[x, y, z]",
"Creates a vector object",
"vector",
"Vector object")
12223 ADE_FUNC(getFrametimeOverall,
l_Base, NULL,
"The overall frame time in seconds since the engine has started",
"number",
"Overall time (seconds)")
12228 ADE_FUNC(getFrametime,
l_Base,
"[Do not adjust for time compression (Boolean)]",
"Gets how long this frame is calculated to take. Use it to for animations, physics, etc to make incremental changes.",
"number",
"Frame time (seconds)")
12236 ADE_FUNC(getCurrentGameState,
l_Base,
"[Depth (number)]",
"Gets current FreeSpace state; if a depth is specified, the state at that depth is returned. (IE at the in-game options game, a depth of 1 would give you the game state, while the function defaults to 0, which would be the options screen.",
"gamestate",
"Current game state at specified depth, or invalid handle if no game state is active yet")
12247 ADE_FUNC(getCurrentMPStatus,
l_Base,
"NIL",
"Gets this computers current MP status",
"string",
"Current MP status" )
12259 return ade_set_args(L,
"s",
"MULTIPLAYER_STANDALONE");
12264 ADE_FUNC(getCurrentPlayer,
l_Base, NULL,
"Gets a handle of the currently used player.<br><b>Note:</b> If there is no current player then the first player will be returned, check the game state to make sure you have a valid player handle.",
"player",
"Player handle")
12269 ADE_FUNC(setControlMode,
l_Base,
"NIL or enumeration LE_*_CONTROL",
"Sets the current control mode for the game.",
"string",
"Current control mode")
12287 switch (e->
index) {
12305 ADE_FUNC(setButtonControlMode,
l_Base,
"NIL or enumeration LE_*_BUTTON_CONTROL",
"Sets the current control mode for the game.",
"string",
"Current control mode")
12323 switch (e->
index) {
12331 return ade_set_args(L,
"s",
"LUA OVERRIDE BUTTON CONTROL");
12335 return ade_set_args(L,
"s",
"LUA ADDITIVE BUTTON CONTROL");
12341 ADE_FUNC(getControlInfo,
l_Base, NULL,
"Gets the control info handle.",
"control info",
"control info handle")
12346 ADE_FUNC(setTips,
l_Base,
"True or false",
"Sets whether to display tips of the day the next time the current pilot enters the mainhall.", NULL, NULL)
12363 ADE_FUNC(getGameDifficulty,
l_Base, NULL,
"Returns the difficulty level from 1-5, 1 being the lowest, (Very Easy) and 5 being the highest (Insane)",
"integer",
"Difficulty level as integer")
12368 ADE_FUNC(postGameEvent,
l_Base,
"gameevent Event",
"Sets current game event. Note that you can crash FreeSpace 2 by posting an event at an improper time, so test extensively if you use it.",
"boolean",
"True if event was posted, false if passed event was invalid")
12389 ADE_INDEXER(
l_Base_Events,
"number Index/string Name",
"Array of game events",
"gameevent",
"Game event, or invalid gameevent handle if index is invalid")
12419 ADE_INDEXER(
l_Base_States,
"number Index/string Name",
"Array of game states",
"gamestate",
"Game state, or invalid gamestate handle if index is invalid")
12450 ade_lib l_CFile(
"CFile", NULL,
"cf",
"CFile FS2 filesystem access");
12455 int path_len = strlen(n_path);
12457 char *buf = (
char*)
vm_malloc((path_len+1) *
sizeof(char));
12462 strcpy(buf, n_path);
12466 while(i >= 0 && (buf[i] ==
'\\' || buf[i] ==
'/'))
12471 while(i < path_len && (buf[i] ==
'\\' || buf[i] ==
'/'))
12475 for(i = 0; i < path_len; i++)
12477 if(buf[i] ==
'\\' || buf[i] ==
'/')
12494 ADE_FUNC(deleteFile,
l_CFile,
"string Filename, string Path",
"Deletes given file. Path must be specified. Use a slash for the root directory.",
"boolean",
"True if deleted, false")
12496 char *n_filename = NULL;
12502 if(n_path != NULL && strlen(n_path))
12511 ADE_FUNC(fileExists,
l_CFile,
"string Filename, [string Path = \"\", boolean CheckVPs = false]",
"Checks if a file exists. Use a blank string for path for any directory, or a slash for the root directory.",
"boolean",
"True if file exists, false or nil otherwise")
12513 char *n_filename = NULL;
12515 bool check_vps =
false;
12516 if(!
ade_get_args(L,
"s|sb", &n_filename, &n_path, &check_vps))
12520 if(n_path != NULL && strlen(n_path))
12533 "Opens a file. 'Mode' uses standard C fopen arguments. Use a blank string for path for any directory, or a slash for the root directory."
12534 "Be EXTREMELY CAREFUL when using this function, as you may PERMANENTLY delete any file by accident",
12536 "File handle, or invalid file handle if the specified file couldn't be opened")
12538 char *n_filename = NULL;
12539 char *n_mode =
"r";
12541 if(!
ade_get_args(L,
"s|ss", &n_filename, &n_mode, &n_path))
12547 if(n_path != NULL && strlen(n_path))
12561 ADE_FUNC(openTempFile,
l_CFile, NULL,
"Opens a temp file that is automatically deleted when closed",
"file",
"File handle, or invalid file handle if tempfile couldn't be created")
12566 ADE_FUNC(renameFile,
l_CFile,
"string CurrentFilename, string NewFilename, string Path",
"Renames given file. Path must be specified. Use a slash for the root directory.",
"boolean",
"True if file was renamed, otherwise false")
12568 char *n_filename = NULL;
12569 char *n_new_filename = NULL;
12571 if(!
ade_get_args(L,
"ss|s", &n_filename, &n_new_filename, &n_path))
12575 if(n_path != NULL && strlen(n_path))
12589 ADE_FUNC(getMouseX,
l_Mouse, NULL,
"Gets Mouse X pos",
"number",
"Mouse x position, or 0 if mouse is not initialized yet")
12601 ADE_FUNC(getMouseY,
l_Mouse, NULL,
"Gets Mouse Y pos",
"number",
"Mouse y position, or 0 if mouse is not initialized yet")
12613 ADE_FUNC(isMouseButtonDown,
l_Mouse,
"{MOUSE_*_BUTTON enumeration}, [..., ...]",
"Returns whether the specified mouse buttons are up or down",
"boolean",
"Whether specified mouse buttons are down, or false if mouse is not initialized yet")
12618 enum_h *e[3] = {NULL, NULL, NULL};
12622 int check_flags = 0;
12624 for(
int i = 0;
i < 3;
i++)
12643 ADE_FUNC(setCursorImage,
l_Mouse,
"Image filename, [LOCK or UNLOCK]",
"Sets mouse cursor image, and allows you to lock/unlock the image. (A locked cursor may only be changed with the unlock parameter)", NULL, NULL)
12667 ADE_FUNC(setCursorHidden,
l_Mouse,
"True to hide mouse, false to show it",
"Shows or hides mouse cursor", NULL, NULL)
12683 ADE_FUNC(forceMousePosition,
l_Mouse,
"number, number (coordinates)",
"function to force mouse position",
"boolean",
"if the operation succeeded or not")
12706 ADE_VIRTVAR(MouseControlStatus,
l_Mouse,
"boolean",
"Gets and sets the retail mouse control status",
"boolean",
"if the retail mouse is on or off")
12711 bool newVal =
false;
12733 ADE_FUNC(getMouseSensitivity,
l_Mouse, NULL,
"Gets mouse sensitivity setting",
"number",
"Mouse sensitivity in range of 0-9")
12738 ADE_FUNC(getJoySensitivity,
l_Mouse, NULL,
"Gets joystick sensitivity setting",
"number",
"Joystick sensitivity in range of 0-9")
12743 ADE_FUNC(getJoyDeadzone,
l_Mouse, NULL,
"Gets joystick deadzone setting",
"number",
"Joystick deadzone in range of 0-9")
12749 ADE_FUNC(updateTrackIR,
l_Mouse, NULL,
"Updates Tracking Data. Call before using get functions",
"boolean",
"Checks if trackir is available and updates variables, returns true if successful, otherwise false")
12760 ADE_FUNC(getTrackIRPitch,
l_Mouse, NULL,
"Gets pitch axis from last update",
"number",
"Pitch value -1 to 1, or 0 on failure")
12768 ADE_FUNC(getTrackIRYaw,
l_Mouse, NULL,
"Gets yaw axis from last update",
"number",
"Yaw value -1 to 1, or 0 on failure")
12776 ADE_FUNC(getTrackIRRoll,
l_Mouse, NULL,
"Gets roll axis from last update",
"number",
"Roll value -1 to 1, or 0 on failure")
12784 ADE_FUNC(getTrackIRX,
l_Mouse, NULL,
"Gets x position from last update",
"number",
"X value -1 to 1, or 0 on failure")
12792 ADE_FUNC(getTrackIRY,
l_Mouse, NULL,
"Gets y position from last update",
"number",
"Y value -1 to 1, or 0 on failure")
12800 ADE_FUNC(getTrackIRZ,
l_Mouse, NULL,
"Gets z position from last update",
"number",
"Z value -1 to 1, or 0 on failure")
12811 ADE_VIRTVAR(HUDDrawn,
l_HUD,
"boolean",
"Current HUD draw status",
"boolean",
"If the HUD is drawn or not")
12813 bool to_draw =
false;
12832 ADE_VIRTVAR(HUDDisabledExceptMessages,
l_HUD,
"boolean",
"Specifies if only the messages gauges of the hud are drawn",
"boolean",
"true if only the message gauges are drawn, false otherwise")
12834 bool to_draw =
false;
12850 ADE_FUNC(setHUDGaugeColor,
l_HUD,
"number (index number of the gauge), [integer red, number green, number blue, number alpha]",
"Color used to draw the gauge",
"boolean",
"If the operation was successful")
12869 ADE_FUNC(getHUDGaugeColor,
l_HUD,
"number (index number of the gauge)",
"Color used to draw the gauge",
"number, number, number, number",
"Red, green, blue, and alpha of the gauge")
12884 ADE_FUNC(getHUDGaugeHandle,
l_HUD,
"string Name",
"Returns a handle to a specified HUD gauge",
"HudGauge",
"HUD Gauge handle, or nil if invalid")
12997 if (index >= (
int) names.size())
13000 return ade_set_args(L,
"s", const_cast<char*>(names[index].c_str()));
13009 return ade_set_args(L,
"i", ((
int) names.size()) + 1);
13012 ADE_FUNC(setPostEffect,
l_Graphics,
"string name, [number value=0]",
"Sets the intensity of the specified post processing effect",
"boolean",
"true when successful, false otherwise")
13020 if (name == NULL || intensity < 0)
13028 ADE_FUNC(resetPostEffects,
l_Graphics, NULL,
"Resets all post effects to their default values",
"boolean",
"true if successful, false otherwise")
13035 ADE_VIRTVAR(CurrentOpacityType,
l_Graphics,
"enumeration",
"Current alpha blending type; uses ALPHABLEND_* enumerations",
"enumeration", NULL)
13037 enum_h *alphatype = NULL;
13051 switch(lua_Opacity_type)
13063 ADE_VIRTVAR(CurrentRenderTarget,
l_Graphics,
"texture",
"Current rendering target",
"texture",
"Current rendering target, or invalid texture handle if screen is render target")
13089 ADE_FUNC(clearScreen,
l_Graphics,
"[integer red, number green, number blue, number alpha]",
"Clears the screen to black, or the color specified.", NULL, NULL)
13097 if(r != 0 || g != 0 || b != 0 || a!= 255)
13116 "string Name, [wvector Position, orientation Orientation]",
13117 "Creates a new camera using the specified position and orientation (World)",
13119 "Camera handle, or invalid camera handle if camera couldn't be created")
13136 ADE_FUNC(isMenuStretched,
l_Graphics, NULL,
"Returns whether the standard interface is stretched",
"boolean",
"True if stretched, false if aspect ratio is maintained")
13144 ADE_FUNC(getScreenWidth,
l_Graphics, NULL,
"Gets screen width",
"number",
"Width in pixels, or 0 if graphics are not initialized yet")
13152 ADE_FUNC(getScreenHeight,
l_Graphics, NULL,
"Gets screen height",
"number",
"Height in pixels, or 0 if graphics are not initialized yet")
13160 ADE_FUNC(getCenterWidth,
l_Graphics, NULL,
"Gets width of center monitor (should be used in conjuction with getCenterOffsetX)",
"number",
"Width of center monitor in pixels, or 0 if graphics are not initialized yet")
13168 ADE_FUNC(getCenterHeight,
l_Graphics, NULL,
"Gets height of center monitor (should be used in conjuction with getCenterOffsetY)",
"number",
"Height of center monitor in pixels, or 0 if graphics are not initialized yet")
13176 ADE_FUNC(getCenterOffsetX,
l_Graphics, NULL,
"Gets X offset of center monitor",
"number",
"X offset of center monitor in pixels")
13184 ADE_FUNC(getCenterOffsetY,
l_Graphics, NULL,
"Gets Y offset of center monitor",
"number",
"Y offset of center monitor in pixels")
13192 ADE_FUNC(getCurrentCamera,
l_Graphics,
"[boolean]",
"Gets the current camera handle, if argument is <i>true</i> then it will also return the main camera when no custom camera is in use",
"camera",
"camera handle or invalid handle on error")
13196 bool rtnMain =
false;
13209 "[number X=center, number Y=center, number Depth, boolean normalize = false]",
13210 "Returns a vector through screen coordinates x and y. "
13211 "If depth is specified, vector is extended to Depth units into space"
13212 "If normalize is true, vector will be normalized.",
13214 "Vector, or zero vector on failure")
13218 float depth = 0.0f;
13219 bool normalize =
false;
13240 cam->
get_info(&cam_pos, &cam_orient);
13270 "If texture is specified, sets current rendering surface to a texture."
13271 "Otherwise, sets rendering surface back to screen.",
13273 "True if successful, false otherwise")
13284 ADE_FUNC(setCamera,
l_Graphics,
"[camera handle Camera]",
"Sets current camera, or resets camera if none specified",
"boolean",
"true if successful, false or nil otherwise")
13301 ADE_FUNC(setColor,
l_Graphics,
"integer Red, number Green, number Blue, [integer Alpha]",
"Sets 2D drawing color; each color number should be from 0 (darkest) to 255 (brightest)", NULL, NULL)
13318 ADE_FUNC(setLineWidth,
l_Graphics,
"[number width=1.0]",
"Sets the line width for lines. This call might fail if the specified width is not supported by the graphics implementation. Then the width will be the nearest supported value.",
"boolean",
"true if succeeded, false otherwise")
13323 float width = 1.0f;
13337 ADE_FUNC(drawCircle,
l_Graphics,
"number Radius, number X, number Y, [boolean Filled=true]",
"Draws a circle", NULL, NULL)
13358 ADE_FUNC(drawArc,
l_Graphics,
"number Radius, number X, number Y, number StartAngle, number EndAngle, [boolean Filled=true]",
"Draws an arc", NULL, NULL)
13364 float ra,angle_start,angle_end;
13367 if(!
ade_get_args(L,
"fiiff|b", &ra,&x,&y,&angle_start,&angle_end,&fill)) {
13393 ADE_FUNC(drawGradientLine,
l_Graphics,
"number X1, number Y1, number X2, number Y2",
"Draws a line from (x1,y1) to (x2,y2) with the CurrentColor that steadily fades out", NULL, NULL)
13408 ADE_FUNC(drawLine,
l_Graphics,
"number X1, number Y1, number X2, number Y2",
"Draws a line from (x1,y1) to (x2,y2) with CurrentColor", NULL, NULL)
13438 ADE_FUNC(drawPolygon,
l_Graphics,
"texture Texture, [vector Position={0,0,0}, orientation Orientation=nil, number Width=1.0, number Height=1.0]",
"Draws a polygon. May not work properly in hooks other than On Object Render.", NULL, NULL)
13443 float width = 1.0f;
13469 ADE_FUNC(drawRectangle,
l_Graphics,
"number X1, number Y1, number X2, number Y2, [boolean Filled=true]",
"Draws a rectangle with CurrentColor", NULL, NULL)
13477 if(!
ade_get_args(L,
"iiii|b", &x1, &y1, &x2, &y2, &f))
13496 ADE_FUNC(drawSphere,
l_Graphics,
"[number Radius = 1.0, vector Position]",
"Draws a sphere with radius Radius at world vector Position. May not work properly in hooks other than On Object Render.",
"boolean",
"True if successful, false or nil otherwise")
13519 cam->
get_info(&cam_pos, &cam_orient);
13543 ADE_FUNC(drawModel,
l_Graphics,
"model, position, orientation",
"Draws the given model with the specified position and orientation - Use with extreme care, may not work properly in all scripting hooks.",
"int",
"Zero if successful, otherwise an integer error code")
13554 int model_num = mdl->
GetID();
13579 cam->
get_info(&cam_pos, &cam_orient);
13609 ADE_FUNC(drawModelOOR,
l_Graphics,
"model Model, vector Position, matrix Orientation, [integer Flags]",
"Draws the given model with the specified position and orientation - Use with extreme care, designed to operate properly only in On Object Render hooks.",
"int",
"Zero if successful, otherwise an integer error code")
13626 int model_num = pm->
id;
13647 "Gets the edge positions of targeting brackets for the specified object. The brackets will only be drawn if draw is true or the default value of draw is used. Brackets are drawn with the current color. The brackets will have a padding (distance from the actual bounding box); the default value (used elsewhere in FS2) is 5.",
13648 "number,number,number,number",
13649 "Left, top, right, and bottom positions of the brackets, or nil if invalid")
13656 bool draw_box =
true;
13671 object *targetp = objh->
objp;
13676 bool entered_frame =
false;
13682 entered_frame =
true;
13686 switch ( targetp->
type ) {
13690 if ( bound_rc != 0 ) {
13691 if ( entered_frame )
13699 if ( bound_rc != 0 ) {
13700 if ( entered_frame )
13717 if(jnp->GetSCPObject() == targetp)
13721 modelnum = jnp->GetModelNumber();
13725 if ( entered_frame )
13738 if ( entered_frame )
13744 ADE_FUNC(drawSubsystemTargetingBrackets,
l_Graphics,
"subsystem subsys, [boolean draw=true, boolean setColor=false]",
13745 "Gets the edge position of the targeting brackets drawn for a subsystem as if they were drawn on the HUD. Only actually draws the brackets if <i>draw</i> is true, optionally sets the color the as if it was drawn on the HUD",
13746 "number,number,number,number",
13747 "Left, top, right, and bottom positions of the brackets, or nil if invalid or off-screen")
13755 bool set_color =
false;
13766 bool entered_frame =
false;
13771 entered_frame =
true;
13778 if ( entered_frame )
13783 return ade_set_args(L,
"iiii", coords[0], coords[1], coords[2], coords[3]);
13792 "Draws an off-screen indicator for the given object. The indicator will not be drawn if draw=false, but the coordinates will be returned in either case. The indicator will be drawn using the current color if setColor=true and using the IFF color of the object if setColor=false.",
13794 "Coordinates of the indicator (at the very edge of the screen), or nil if object is on-screen")
13798 bool setcolor =
false;
13799 vec2d outpoint = { -1.0f, -1.0f };
13813 object *targetp = objh->
objp;
13826 if(target_point.
codes == 0)
13832 size_t j, num_gauges;
13835 for(j = 0; j < num_gauges; j++) {
13849 float tri_separation;
13851 offscreengauge->
calculatePosition(&target_point, &targetp->
pos, &outpoint, &dir, &tri_separation);
13862 offscreengauge->
resize(&outpoint.
x, &outpoint.
y);
13868 if (outpoint.
x >= 0 && outpoint.
y >=0)
13874 #define MAX_TEXT_LINES 256
13875 static char *BooleanValues[] = {
"False",
"True"};
13876 static const int NextDrawStringPosInitial[] = {0, 0};
13877 static int NextDrawStringPos[] = {NextDrawStringPosInitial[0], NextDrawStringPosInitial[1]};
13879 "Draws a string. Use x1/y1 to control position, x2/y2 to limit textbox size."
13880 "Text will automatically move onto new lines, if x2/y2 is specified."
13881 "Additionally, calling drawString with only a string argument will automatically"
13882 "draw that string below the previously drawn string (or 0,0 if no strings"
13883 "have been drawn yet",
13885 "Number of lines drawn, or 0 on failure")
13890 int x=NextDrawStringPos[0];
13891 int y = NextDrawStringPos[1];
13893 char *s =
"(null)";
13897 if(lua_isboolean(L, 1))
13904 s = BooleanValues[1];
13906 s = BooleanValues[0];
13908 else if(lua_isstring(L, 1))
13918 NextDrawStringPos[0] =
x;
13926 NextDrawStringPos[1] = y+
height;
13933 if (y2 >= 0 && y2 < y)
13936 Warning(
LOCATION,
"Illegal y2 value passed to drawString. Got %d y2 value but %d for y.", y2, y);
13947 num_lines =
MIN(num_lines, (y2 - y) / line_ht);
13950 for(
int i = 0;
i < num_lines;
i++)
13953 int len = linelengths[
i];
13954 char *buf =
new char[len+1];
13955 strncpy(buf, linestarts[
i], len);
13968 if (num_lines <= 0)
13975 NextDrawStringPos[1] = curr_y;
13980 ADE_FUNC(getStringWidth,
l_Graphics,
"string String",
"Gets string width",
"number",
"String width, or 0 on failure")
13996 ADE_FUNC(createTexture,
l_Graphics,
"[number Width=512, number Height=512, enumeration Type=TEXTURE_DYNAMIC]",
13997 "Creates a texture for rendering to."
13998 "Types are TEXTURE_STATIC - for infrequent rendering - and TEXTURE_DYNAMIC - for frequent rendering.",
14000 "New texture handle, or invalid texture handle if texture couldn't be created")
14027 "Gets a handle to a texture. If second argument is set to true, animations will also be loaded."
14028 "If third argument is set to true, every other animation frame will not be loaded if system has less than 48 MB memory."
14029 "<br><strong>IMPORTANT:</strong> Textures will not be unload themselves unless you explicitly tell them to do so."
14030 "When you are done with a texture, call the Unload() function to free up memory.",
14032 "Texture handle, or invalid texture handle if texture couldn't be loaded")
14053 ADE_FUNC(drawImage,
l_Graphics,
"string Filename/texture Texture, [number X1=0, Y1=0, number X2, number Y2, number UVX1 = 0.0, number UVY1 = 0.0, number UVX2=1.0, number UVY2=1.0, number alpha=1.0]",
14054 "Draws an image or texture. Any image extension passed will be ignored."
14055 "The UV variables specify the UV value for each corner of the image. "
14056 "In UV coordinates, (0,0) is the top left of the image; (1,1) is the lower right.",
14058 "Whether image was drawn")
14074 if(lua_isstring(L, 1))
14077 if(!
ade_get_args(L,
"s|iiiifffff", &s,&x1,&y1,&x2,&y2,&uv_x1,&uv_y1,&uv_x2,&uv_y2,&alpha))
14087 if(!
ade_get_args(L,
"o|iiiifffff",
l_Texture.Get(&idx),&x1,&y1,&x2,&y2,&uv_x1,&uv_y1,&uv_x2,&uv_y2,&
alpha))
14111 ADE_FUNC(drawMonochromeImage,
l_Graphics,
"string Filename/texture Texture, number X1, number Y1, [number X2, number Y2, number alpha=1.0]",
"Draws a monochrome image using the current color",
"boolean",
"Whether image was drawn")
14125 if(lua_isstring(L, 1))
14128 if(!
ade_get_args(L,
"sii|iif", &s,&x,&y,&x2,&y2,&alpha))
14167 ADE_FUNC(getImageWidth,
l_Graphics,
"string Filename",
"Gets image width",
"number",
"Image width, or 0 if filename is invalid")
14184 ADE_FUNC(getImageHeight,
l_Graphics,
"Image name",
"Gets image height",
"number",
"Image height, or 0 if filename is invalid")
14216 ADE_FUNC(loadModel,
l_Graphics,
"string Filename",
"Loads the model - will not setup subsystem data, DO NOT USE FOR LOADING SHIP MODELS",
"model",
"Handle to a model")
14219 int model_num = -1;
14232 ADE_FUNC(hasViewmode,
l_Graphics,
"enumeration",
"Specifies if the current viemode has the specified flag, see VM_* enumeration",
"boolean",
"true if flag is present, false otherwise")
14239 if (type == NULL || !type->
IsValid())
14244 switch(type->
index)
14307 LuaError(L,
"Attempted to use hasViewmode with an invalid enumeration! Only VM_* enumerations are allowed!");
14315 ADE_FUNC(setClip,
l_Graphics,
"x, y, width, height",
"Sets the clipping region to the specified rectangle. Most drawing functions are able to handle the offset.",
"boolean",
"true if successful, false otherwise")
14319 if (!
ade_get_args(L,
"iiii", &x, &y, &width, &height))
14327 ADE_FUNC(resetClip,
l_Graphics, NULL,
"Resets the clipping region that might have been set",
"boolean",
"true if successful, false otherwise")
14335 ade_lib l_HookVar(
"HookVariables", NULL,
"hv",
"Hook variables repository");
14345 ADE_INDEXER(
l_HookVar_Globals,
"number Index",
"Array of current HookVariable names",
"string",
"Hookvariable name, or empty string if invalid index specified")
14353 int lib_ldx = lua_gettop(L);
14354 if(!lua_isuserdata(L, lib_ldx))
14361 lua_getmetatable(L, lib_ldx);
14362 int mtb_ldx = lua_gettop(L);
14363 if(!lua_istable(L, mtb_ldx))
14370 lua_pushstring(L,
"__ademembers");
14371 lua_rawget(L, mtb_ldx);
14372 int amt_ldx = lua_gettop(L);
14373 if(!lua_istable(L, amt_ldx))
14380 char *keyname = NULL;
14383 while(lua_next(L, amt_ldx))
14386 lua_pushvalue(L, -2);
14387 keyname = (
char *)lua_tostring(L, -1);
14388 if(strcmp(keyname,
"Globals"))
14410 int lib_ldx = lua_gettop(L);
14411 if(!lua_isuserdata(L, lib_ldx))
14417 lua_getmetatable(L, lib_ldx);
14418 int mtb_ldx = lua_gettop(L);
14419 if(!lua_istable(L, mtb_ldx))
14426 lua_pushstring(L,
"__ademembers");
14427 lua_rawget(L, mtb_ldx);
14428 int amt_ldx = lua_gettop(L);
14429 if(!lua_istable(L, amt_ldx))
14437 while(lua_next(L, amt_ldx))
14454 ADE_FUNC(getObjectFromSignature,
l_Mission,
"number Signature",
"Gets a handle of an object from its signature",
"object",
"Handle of object with signaure, invalid handle if signature is not in use")
14470 ADE_FUNC(evaluateSEXP,
l_Mission,
"string",
"Runs the defined SEXP script",
"boolean",
"if the operation was successful")
14486 ADE_FUNC(runSEXP,
l_Mission,
"string",
"Runs the defined SEXP script",
"boolean",
"if the operation was successful")
14499 static bool Warned_about_runSEXP_parentheses =
false;
14500 if (!Warned_about_runSEXP_parentheses)
14502 Warned_about_runSEXP_parentheses =
true;
14503 Warning(
LOCATION,
"Invalid SEXP syntax: SEXPs must be surrounded by parentheses. For backwards compatibility, the string has been enclosed in parentheses. This may not be correct in all use cases.");
14506 snprintf(buf, 8191,
"( when ( true ) ( %s ) )", s);
14511 snprintf(buf, 8191,
"( when ( true ) %s )", s);
14540 "Number of asteroids in mission. Note that the value returned is only good until an asteroid is destroyed, and so cannot be relied on for more than one frame.",
14542 "Number of asteroids in the mission, or 0 if asteroids are not enabled")
14553 ADE_INDEXER(
l_Mission_Debris,
"number Index",
"Array of debris in the current mission",
"debris",
"Debris handle, or invalid debris handle if index wasn't valid")
14561 if (
Debris[idx].objnum == -1)
14570 "Number of debris pieces in the mission. "
14571 "Note that the value returned is only good until a piece of debris is destroyed, and so cannot be relied on for more than one frame.",
14573 "Current number of debris particles")
14624 if(i < 1 || i > Num_mission_events)
14641 ADE_INDEXER(
l_Mission_SEXPVariables,
"number Index/string Name",
"Array of SEXP variables. Note that you can set a sexp variable using the array, eg \'SEXPVariables[\"newvariable\"] = \"newvalue\"\'",
"sexpvariable",
"Handle to SEXP variable, or invalid sexpvariable handle if index was invalid")
14644 char *newval = NULL;
14727 "Number of ships in the mission. "
14728 "This function is somewhat slow, and should be set to a variable for use in looping situations. "
14729 "Note that the value returned is only good until a ship is destroyed, and so cannot be relied on for more than one frame.",
14731 "Number of ships in the mission, or 0 if ships haven't been initialized yet")
14742 ADE_INDEXER(
l_Mission_Waypoints,
"number Index",
"Array of waypoints in the current mission",
"waypoint",
"Waypoint handle, or invalid waypoint handle if index was invalid")
14767 ADE_FUNC(__len,
l_Mission_Waypoints, NULL,
"Gets number of waypoints in mission. Note that this is only accurate for one frame.",
"number",
"Number of waypoints in the mission")
14791 if (!wpl.IsValid()) {
14792 int idx = atoi(name) - 1;
14796 if (wpl.IsValid()) {
14803 ADE_FUNC(__len,
l_Mission_WaypointLists, NULL,
"Number of waypoint lists in mission. Note that this is only accurate for one frame.",
"number",
"Number of waypoint lists in the mission")
14811 ADE_INDEXER(
l_Mission_Weapons,
"number Index",
"Gets handle to a weapon object in the mission.",
"weapon",
"Weapon handle, or invalid weapon handle if index is invalid")
14834 ADE_FUNC(__len,
l_Mission_Weapons, NULL,
"Number of weapon objects in mission. Note that this is only accurate for one frame.",
"number",
"Number of weapon objects in mission")
14842 ADE_INDEXER(
l_Mission_Beams,
"number Index",
"Gets handle to a beam object in the mission.",
"beam",
"Beam handle, or invalid beam handle if index is invalid")
14865 ADE_FUNC(__len,
l_Mission_Beams, NULL,
"Number of beam objects in mission. Note that this is only accurate for one frame.",
"number",
"Number of beam objects in mission")
14873 ADE_FUNC(getNextMissionFilename,
l_Campaign, NULL,
"Gets next mission filename",
"string",
"Next mission filename, or nil if the next mission is invalid")
14881 ADE_FUNC(getPrevMissionFilename,
l_Campaign, NULL,
"Gets previous mission filename",
"string",
"Previous mission filename, or nil if the previous mission is invalid")
14890 ADE_FUNC(jumpToMission,
l_Campaign,
"string filename, [boolean hub]",
"Jumps to a mission based on the filename. Optionally, the player can be sent to a hub mission without setting missions to skipped.",
"boolean",
"Jumps to a mission, or returns nil.")
14908 ADE_INDEXER(
l_Mission_Wings,
"number Index/string WingName",
"Wings in the mission",
"wing",
"Wing handle, or invalid wing handle if index or name was invalid")
14937 ADE_INDEXER(
l_Mission_Teams,
"number Index/string TeamName",
"Teams in the mission",
"team",
"Team handle or invalid team handle if the requested team could not be found")
14970 if (lua_isnumber(L, 2))
14999 if (idx < Num_builtin_messages || idx >= (
int)
Messages.size())
15017 if (lua_isnumber(L, 2))
15062 if (lua_isnumber(L, 2))
15093 ADE_FUNC(addMessage,
l_Mission,
"string name, string text[, persona persona]",
"Adds a message",
"message",
"The new message or invalid handle on error")
15097 int personaIdx = -1;
15102 if (name == NULL || text == NULL)
15113 ADE_FUNC(sendMessage,
l_Mission,
"string sender, message message[, number delay=0.0[, enumeration priority = MESSAGE_PRIORITY_NORMAL[, boolean fromCommand = false]]]",
15114 "Sends a message from the given source (not from a ship!) with the given priority or optionally sends it from the missions command source.<br>"
15115 "If delay is specified the message will be delayed by the specified time in seconds<br>"
15116 "If you pass <i>nil</i> as the sender then the message will not have a sender.",
15117 "boolean",
"true if successfull, false otherwise")
15119 char* sender = NULL;
15120 int messageIdx = -1;
15122 bool fromCommand =
false;
15124 float delay = 0.0f;
15129 if (lua_isnil(L, 1))
15141 if (sender == NULL)
15148 if (messageIdx < 0 || messageIdx >= (
int)
Messages.size())
15153 LuaError(L,
"Cannot send built-in messages!");
15159 LuaError(L,
"Invalid negative delay of %f!", delay);
15177 LuaError(L,
"Invalid enumeration used! Must be one of MESSAGE_PRIORITY_*.");
15191 "Sends a training message to the player. <i>time</i> is the amount in seconds to display the message, only whole seconds are used!",
15192 "boolean",
"true if successfull, false otherwise")
15194 int messageIdx = -1;
15195 float delay = 0.0f;
15201 if (messageIdx < 0 || messageIdx >= (
int)
Messages.size())
15206 LuaError(L,
"Got invalid delay of %f seconds!", delay);
15212 LuaError(L,
"Got invalid time of %d seconds!", time);
15221 ADE_FUNC(createShip,
l_Mission,
"[string Name, shipclass Class=Shipclass[1], orientation Orientation=null, vector Position={0,0,0}]",
"Creates a ship and returns a handle to it using the specified name, class, world orientation, and world position",
"ship",
"Ship handle, or invalid ship handle if ship couldn't be created")
15235 int obj_idx =
ship_create(real_orient, &pos, sclass, name);
15246 "Creates a waypoint",
15248 "Waypoint handle, or invalid waypoint handle if waypoint couldn't be created")
15256 int waypoint_instance = -1;
15271 ADE_FUNC(createWeapon,
l_Mission,
"[weaponclass Class=WeaponClass[1], orientation Orientation=null, world vector Position={0,0,0}, object Parent = nil, number Group = -1",
15272 "Creates a weapon and returns a handle to it. 'Group' is used for lighting grouping purposes;"
15273 " for example, quad lasers would only need to act as one light source.",
15275 "Weapon handle, or invalid weapon handle if weapon couldn't be created.")
15292 int obj_idx =
weapon_create(&pos, real_orient, wclass, parent_idx, group);
15300 ADE_FUNC(getMissionFilename,
l_Mission, NULL,
"Gets mission filename",
"string",
"Mission filename, or empty string if game is not in a mission")
15305 ADE_FUNC(startMission,
l_Mission,
"[Filename or MISSION_* enumeration, Briefing = true]",
"Starts the defined mission",
"boolean",
"True, or false if the function fails")
15311 if(lua_isstring(L, 1))
15340 file_ext = strrchr(str,
'.');
15373 ADE_FUNC(getMissionTime,
l_Mission, NULL,
"Game time in seconds since the mission was started; is affected by time compression",
"number",
"Mission time (seconds), or 0 if game is not in a mission")
15382 ADE_FUNC(loadMission,
l_Mission,
"Mission name",
"Loads a mission",
"boolean",
"True if mission was loaded, otherwise false")
15435 ADE_FUNC(applyShudder,
l_Mission,
"number time, number intesity",
"Applies a shudder effects to the camera. Time is in seconds. Intensity specifies the shudder effect strength, the Maxim has a value of 1440.",
"boolean",
"true if successfull, false otherwise")
15437 float time = -1.0f;
15438 float intensity = -1.0f;
15443 if (time < 0.0f || intensity < 0.0f)
15445 LuaError(L,
"Illegal shudder values given. Must be bigger than zero, got time of %f and intensity of %f.", time, intensity);
15449 int int_time =
fl2i(time * 1000.0f);
15456 ADE_FUNC(isInCampaign,
l_Mission, NULL,
"Get whether or not the current mission being played in a campaign (as opposed to the tech room's simulator)",
"boolean",
"true if in campaign, false if not")
15468 ade_lib l_BitOps(
"BitOps", NULL,
"bit",
"Bitwise Operations library");
15470 ADE_FUNC(AND,
l_BitOps,
"number, number",
"Values for which bitwise boolean AND operation is performed",
"number",
"Result of the AND operation")
15481 ADE_FUNC(OR,
l_BitOps,
"number, number",
"Values for which bitwise boolean OR operation is performed",
"number",
"Result of the OR operation")
15492 ADE_FUNC(XOR,
l_BitOps,
"number, number",
"Values for which bitwise boolean XOR operation is performed",
"number",
"Result of the XOR operation")
15503 ADE_FUNC(toggleBit,
l_BitOps,
"number, number (bit)",
"Toggles the value of the set bit in the given number for 32 bit integer",
"number",
"Result of the operation")
15509 if (!((b >= 0) && (b < 32)))
15520 ADE_FUNC(checkBit,
l_BitOps,
"number, number (bit)",
"Checks the value of the set bit in the given number for 32 bit integer",
"boolean",
"Was the bit true of false")
15526 if (!((b >= 0) && (b < 32)))
15535 ADE_FUNC(addBit,
l_BitOps,
"number, number (bit)",
"Performs inclusive or (OR) operation on the set bit of the value",
"number",
"Result of the operation")
15541 if (!((b >= 0) && (b < 32)))
15568 if(idx < 1 || idx >= static_cast<int>(
Ship_info.size()))
15592 if(!Weapons_inited)
15620 if(!Weapons_inited)
15628 ade_lib l_Testing(
"Testing", NULL,
"ts",
"Experimental or testing stuff");
15632 static bool initialized =
false;
15637 avd.
setAVD(10.0f, 3.0f, 1.0f, 1.0f, 0.0f);
15638 initialized =
true;
15640 for(
int i = 0;
i < 3000;
i++)
15643 avd.
get((
float)
i/1000.0f, &Pc, &Vc);
15658 ADE_FUNC(createParticle,
l_Testing,
"vector Position, vector Velocity, number Lifetime, number Radius, enumeration Type, [number Tracer length=-1, boolean Reverse=false, texture Texture=Nil, object Attached Object=Nil]",
15659 "Creates a particle. Use PARTICLE_* enumerations for type."
15660 "Reverse reverse animation, if one is specified"
15661 "Attached object specifies object that Position will be (and always be) relative to.",
15663 "Handle to the created particle")
15676 if(!
ade_get_args(L,
"ooffo|fboo",
l_Vector.Get(&pi.
pos),
l_Vector.Get(&pi.
vel), &pi.
lifetime, &pi.
rad,
l_Enum.GetPtr(&type), &pi.
tracer_length, &rev,
l_Texture.Get((
int*)&pi.
optional_data),
l_Object.GetPtr(&objh)))
15681 switch(type->
index)
15698 LuaError(L,
"Invalid texture specified for createParticle()!");
15709 if(objh != NULL && objh->
IsValid())
15725 char buf[10240] = {
'\0'};
15730 ADE_FUNC(isCurrentPlayerMulti,
l_Testing, NULL,
"Returns whether current player is a multiplayer pilot or not.",
"boolean",
"Whether current player is a multiplayer pilot or not")
15744 ADE_FUNC(isPXOEnabled,
l_Testing, NULL,
"Returns whether PXO is currently enabled in the configuration.",
"boolean",
"Whether PXO is enabled or not")
15746 if(!(Om_tracker_flag))
15752 ADE_FUNC(playCutscene,
l_Testing, NULL,
"Forces a cutscene by the specified filename string to play. Should really only be used in a non-gameplay state (i.e. start of GS_STATE_BRIEFING) otherwise odd side effects may occur. Highly Experimental.",
"string", NULL)
15775 object *objp = &
Objects[obj_idx];
15814 lua_getstack(L, 1, ar);
15815 lua_getinfo(L,
"nSlu", ar);
15816 memcpy(&Ade_debug_info, ar,
sizeof(lua_Debug));
15819 for (n = 0; n < 4; n++) {
15820 debug_stack[
n][0] =
'\0';
15823 for (n = 0; n < 4; n++) {
15824 if (lua_getstack(L,n+1, ar) == 0)
15826 lua_getinfo(L,
"n", ar);
15827 if (ar->name == NULL)
15829 strcpy_s(debug_stack[n],ar->name);
15837 lua_getstack(L, 1, ar);
15838 lua_getinfo(L,
"nSlu", ar);
15839 memcpy(&Ade_debug_info, ar,
sizeof(lua_Debug));
15842 for (n = 0; n < 4; n++) {
15843 debug_stack[
n][0] =
'\0';
15846 for (n = 0; n < 4; n++) {
15847 if (lua_getstack(L,n+1, ar) == 0)
15849 lua_getinfo(L,
"n", ar);
15850 if (ar->name == NULL)
15852 strcpy_s(debug_stack[n],ar->name);
15858 static int ade_return_hack(lua_State *L)
15861 int num = lua_gettop(L);
15862 for(i = 0; i <
num; i++)
15864 lua_pushvalue(L, i+1);
15874 mprintf((
"LUA: Opening LUA state...\n"));
15875 lua_State *L = lua_open();
15884 mprintf((
"LUA: Initializing base Lua libraries...\n"));
15888 lua_pushstring(L,
"os");
15889 lua_rawget(L, LUA_GLOBALSINDEX);
15890 int os_ldx = lua_gettop(L);
15891 if(lua_istable(L, os_ldx))
15893 lua_pushstring(L,
"execute");
15895 lua_rawset(L, os_ldx);
15896 lua_pushstring(L,
"remove");
15898 lua_rawset(L, os_ldx);
15899 lua_pushstring(L,
"rename");
15901 lua_rawset(L, os_ldx);
15912 mprintf((
"LUA: Beginning ADE initialization\n"));
15913 for(i = 0; i < Ade_table_entries.size(); i++)
15916 if(Ade_table_entries[i].ParentIdx == UINT_MAX)
15917 Ade_table_entries[
i].SetTable(L, LUA_GLOBALSINDEX, LUA_GLOBALSINDEX);
15921 lua_pushstring(L,
"ade_return_hack");
15922 lua_pushboolean(L, 0);
15923 lua_pushcclosure(L, ade_return_hack, 2);
15924 lua_setglobal(L,
"ade_return_hack");
15927 mprintf((
"ADE: Initializing enumeration constants...\n"));
15929 for(i = 0; i < Num_enumerations; i++)
15935 lua_setglobal(L, Enumerations[i].
name);
15939 mprintf((
"ADE: Assigning Lua session...\n"));
15945 void script_state::EndLuaFrame()
15947 memcpy(NextDrawStringPos, NextDrawStringPosInitial,
sizeof(NextDrawStringPos));
15956 int stacksize = lua_gettop(L);
15962 for(
int argnum = 1; argnum <= stacksize; argnum++)
15964 int type = lua_type(L, argnum);
15965 sprintf(buf,
"\r\n%d: ", argnum);
15966 strcat(stackdump, buf);
15970 strcat(stackdump,
"NIL");
15973 d = lua_tonumber(L, argnum);
15974 sprintf(buf,
"Number [%f]",d);
15975 strcat(stackdump, buf);
15978 b = lua_toboolean(L, argnum);
15979 sprintf(buf,
"Boolean [%d]",b);
15980 strcat(stackdump, buf);
15983 s = (
char *)lua_tostring(L, argnum);
15984 sprintf(buf,
"String [%s]",s);
15985 strcat(stackdump, buf);
15989 if(lua_getmetatable(L, argnum))
15991 lua_pushstring(L,
"__adeid");
15993 if(lua_isnumber(L, -1))
15995 sprintf(buf,
"Table [%s]", Ade_table_entries[(
uint)lua_tonumber(L, -1)].Name);
15996 strcat(stackdump, buf);
15999 strcat(stackdump,
"non-default Table");
16003 strcat(stackdump,
"Table w/ no metatable");
16006 char *firstkey = NULL;
16008 if(lua_next(L, argnum))
16010 firstkey = (
char *)lua_tostring(L, -2);
16011 if(firstkey != NULL)
16013 strcat(stackdump,
", First key: [");
16014 strcat(stackdump, firstkey);
16015 strcat(stackdump,
"]");
16022 case LUA_TFUNCTION:
16023 strcat(stackdump,
"Function");
16028 strcat(stackdump,
" ");
16029 strcat(stackdump, lua_tostring(L, -1));
16030 strcat(stackdump,
"()");
16035 case LUA_TUSERDATA:
16036 if(lua_getmetatable(L, argnum))
16038 lua_pushstring(L,
"__adeid");
16040 if(lua_isnumber(L, -1))
16042 sprintf(buf,
"Userdata [%s]", Ade_table_entries[(
uint)lua_tonumber(L, -1)].Name);
16045 sprintf(buf,
"non-default Userdata");
16050 sprintf(buf,
"Userdata w/ no metatable");
16051 strcat(stackdump, buf);
16055 strcat(stackdump, buf);
16057 case LUA_TLIGHTUSERDATA:
16058 sprintf(buf,
"Light userdata");
16059 strcat(stackdump, buf);
16062 sprintf(buf,
"<UNKNOWN>: %s (%f) (%s)", lua_typename(L, type), lua_tonumber(L, argnum), lua_tostring(L, argnum));
16063 strcat(stackdump, buf);
16070 static const char *Lua_type_names[] = {
16082 static int Lua_type_names_num =
sizeof(Lua_type_names)/
sizeof(
char*);
16087 int type = lua_type(L, argnum);
16092 return Lua_type_names[
type];
16117 int needed_args = strlen(fmt);
16120 if(strchr(fmt,
'|') != NULL) {
16121 needed_args = strchr(fmt,
'|') - fmt;
16124 char funcname[128] =
"\0";
16127 memset(&ar, 0,
sizeof(ar));
16128 if(lua_getstack(L, 0, &ar))
16130 lua_getinfo(L,
"nl", &ar);
16132 if(ar.name != NULL) {
16135 if(ar.currentline > -1) {
16137 sprintf(buf,
"%d", ar.currentline);
16144 if(!strlen(funcname)) {
16154 if(!strlen(funcname)) {
16158 if(total_args < needed_args) {
16159 LuaError(L,
"Not enough arguments for '%s' - need %d, had %d. If you are using objects or handles, make sure that you are using \":\" to access member functions, rather than \".\"", funcname, needed_args, total_args);
16166 int counted_args = 0;
16169 bool optional_args =
false;
16174 while(*fmt && nargs <= total_args)
16177 while(lua_type(L, nargs) == LUA_TFUNCTION && nargs <= total_args)
16180 if(nargs > total_args)
16186 if(lua_isboolean(L, nargs)) {
16187 *va_arg(vl,
bool*) = lua_toboolean(L, nargs) > 0 ?
true :
false;
16190 if(!optional_args)
return 0;
16194 if(lua_isnumber(L, nargs)) {
16195 *va_arg(vl,
double*) = (double)lua_tonumber(L, nargs);
16198 if(!optional_args)
return 0;
16202 if(lua_isnumber(L, nargs)) {
16203 *va_arg(vl,
float*) = (
float)lua_tonumber(L, nargs);
16206 if(!optional_args)
return 0;
16210 if(lua_isnumber(L, nargs)) {
16211 *va_arg(vl,
int*) = (
int)lua_tonumber(L, nargs);
16214 if(!optional_args)
return 0;
16218 if(lua_isstring(L, nargs)) {
16219 *va_arg(vl,
const char **) = lua_tostring(L, nargs);
16222 if(!optional_args)
return 0;
16226 if(lua_isnumber(L, nargs)) {
16227 *va_arg(vl,
fix*) =
fl2f((
float)lua_tonumber(L, nargs));
16230 if(!optional_args)
return 0;
16236 if(lua_isuserdata(L, nargs))
16239 lua_getmetatable(L, nargs);
16240 int mtb_ldx = lua_gettop(L);
16241 Assert(!lua_isnil(L, -1));
16244 lua_pushstring(L,
"__adeid");
16245 lua_rawget(L, mtb_ldx);
16247 if(lua_tonumber(L, -1) != od.
idx)
16249 lua_pushstring(L,
"__adederivid");
16250 lua_rawget(L, mtb_ldx);
16251 if((
uint)lua_tonumber(L, -1) != od.
idx)
16253 LuaError(L,
"%s: Argument %d is the wrong type of userdata; '%s' given, but '%s' expected", funcname, nargs, Ade_table_entries[(
uint)lua_tonumber(L, -2)].Name, Ade_table_entries[od.
idx].GetName());
16254 if(!optional_args)
return 0;
16261 memcpy(od.
buf, lua_touserdata(L, nargs), od.
size);
16262 if(od.
sig != NULL) {
16264 Assert(
sizeof(
char) == 1);
16270 (*(
void**)od.
buf) = lua_touserdata(L, nargs);
16273 else if(lua_isnil(L, nargs) && optional_args)
16279 LuaError(L,
"%s: Argument %d is an invalid type '%s'; type '%s' expected", funcname, nargs,
ade_get_type_string(L, nargs), Ade_table_entries[od.
idx].GetName());
16280 if(!optional_args)
return 0;
16287 optional_args =
true;
16293 Error(
LOCATION,
"%s: Bad character passed to ade_get_args; (%c)", funcname, *(fmt-1));
16300 return counted_args;
16323 while(*fmt !=
'\0')
16331 lua_pushboolean(L, va_arg(vl,
int) ? 1 : 0);
16334 lua_pushnumber(L, va_arg(vl,
double));
16337 lua_pushnumber(L, va_arg(vl,
double));
16340 lua_pushnumber(L, va_arg(vl,
int));
16345 char *s = va_arg(vl,
char*);
16346 lua_pushstring(L, s);
16350 lua_pushnumber(L,
f2fl(va_arg(vl,
fix)));
16355 Assert(
sizeof(
char)==1);
16363 luaL_getmetatable(L, Ade_table_entries[od.
idx].Name);
16365 lua_setmetatable(L, -2);
16368 memcpy(newod, od.
buf, od.
size);
16382 Error(
LOCATION,
"Bad character passed to ade_set_args; (%c)", *(fmt-1));
16408 int err_ldx = lua_gettop(L);
16410 if(lua_isstring(L, obj_ldx))
16412 rtn = (
char*)lua_tostring(L, obj_ldx);
16414 else if(lua_isuserdata(L, obj_ldx))
16416 if(lua_getmetatable(L, obj_ldx))
16418 int mtb_ldx = lua_gettop(L);
16420 lua_pushstring(L,
"__tostring");
16421 lua_rawget(L, mtb_ldx);
16423 if(lua_iscfunction(L, -1))
16425 lua_pushvalue(L, obj_ldx);
16426 if(!lua_pcall(L, 1, 1, err_ldx) && lua_type(L, -1) == LUA_TSTRING)
16428 rtn = (
char*)lua_tostring(L, -1);
16435 lua_pop(L, lua_gettop(L) - err_ldx + 1);
16453 static int ade_index_handler(lua_State *L)
16457 const int obj_ldx = 1;
16458 const int key_ldx = 2;
16459 const int arg_ldx = 3;
16460 int last_arg_ldx = lua_gettop(L);
16461 char *type_name = NULL;
16462 uint ade_id = UINT_MAX;
16463 int mtb_ldx = INT_MAX;
16469 lua_pushvalue(L, key_ldx);
16470 lua_rawget(L, obj_ldx);
16471 if(!lua_isnil(L, -1))
16478 if(lua_getmetatable(L, obj_ldx))
16480 mtb_ldx = lua_gettop(L);
16482 int err_ldx = lua_gettop(L);
16486 lua_pushstring(L,
"__adeid");
16487 lua_rawget(L, mtb_ldx);
16488 if(lua_isnumber(L, -1))
16490 ade_id = (
uint) lua_tonumber(L, -1);
16491 if(ade_id < Ade_table_entries.size())
16493 entry = &Ade_table_entries[ade_id];
16494 type_name = entry->
Name;
16500 if(lua_isuserdata(L, obj_ldx) && ade_id != UINT_MAX && !
ADE_SETTING_VAR)
16503 Assert(
sizeof(
char) == 1);
16506 char *ud = (
char *)lua_touserdata(L, obj_ldx);
16510 lua_pushnumber(L, sig);
16511 lua_rawget(L, mtb_ldx);
16512 if(lua_istable(L, -1))
16514 int hvt_ldx = lua_gettop(L);
16515 lua_pushvalue(L, key_ldx);
16516 lua_rawget(L, hvt_ldx);
16517 if(!lua_isnil(L, -1))
16526 lua_pushstring(L,
"__ademembers");
16527 lua_rawget(L, mtb_ldx);
16528 if(lua_istable(L, -1))
16530 int amt_ldx = lua_gettop(L);
16531 lua_pushvalue(L, key_ldx);
16532 lua_rawget(L, amt_ldx);
16533 if(!lua_isnil(L, -1))
16541 lua_pushstring(L,
"__virtvars");
16542 lua_rawget(L, mtb_ldx);
16543 if(lua_istable(L, -1))
16546 int vvt_ldx = lua_gettop(L);
16547 lua_pushvalue(L, key_ldx);
16548 lua_rawget(L, vvt_ldx);
16549 if(lua_isfunction(L, -1))
16554 LuaError(L,
"Unable to set upvalue for virtual variable");
16558 lua_pushvalue(L, obj_ldx);
16560 for(i = arg_ldx; i <= last_arg_ldx; i++)
16562 lua_pushvalue(L, i);
16567 lua_pcall(L, numargs, LUA_MULTRET, err_ldx);
16569 return (lua_gettop(L) - vvt_ldx);
16582 lua_pushstring(L,
"__indexer");
16583 lua_rawget(L, mtb_ldx);
16584 if(lua_isfunction(L, -1))
16590 LuaError(L,
"Unable to set upvalue for indexer");
16593 for(i = 1; i <= last_arg_ldx; i++)
16594 lua_pushvalue(L, i);
16597 lua_pcall(L, last_arg_ldx, LUA_MULTRET, err_ldx);
16599 return (lua_gettop(L) - err_ldx);
16607 lua_pushvalue(L, key_ldx);
16608 lua_pushvalue(L, arg_ldx);
16609 lua_rawset(L, obj_ldx);
16611 lua_pushvalue(L, key_ldx);
16612 lua_rawget(L, obj_ldx);
16616 else if(
ADE_SETTING_VAR && ade_id != UINT_MAX && mtb_ldx != INT_MAX && lua_isuserdata(L, obj_ldx))
16619 Assert(
sizeof(
char) == 1);
16622 char *ud = (
char *)lua_touserdata(L, obj_ldx);
16626 lua_pushnumber(L, sig);
16627 lua_rawget(L, mtb_ldx);
16630 if(!lua_istable(L, -1))
16634 lua_pushnumber(L, sig);
16635 lua_pushvalue(L, -2);
16636 lua_rawset(L, mtb_ldx);
16640 if(lua_istable(L, -1))
16642 int hvt_ldx = lua_gettop(L);
16643 lua_pushvalue(L, key_ldx);
16644 lua_pushvalue(L, arg_ldx);
16645 lua_rawset(L, hvt_ldx);
16647 lua_pushvalue(L, key_ldx);
16648 lua_rawget(L, hvt_ldx);
16655 if(type_name != NULL)
16656 LuaError(L,
"Could not find index '%s' in type '%s'", lua_tostring(L, key_ldx), type_name);
16658 LuaError(L,
"Could not find index '%s'", lua_tostring(L, key_ldx));
16666 int cleanup_items = 0;
16667 int mtb_ldx = INT_MAX;
16668 int data_ldx = INT_MAX;
16669 int desttable_ldx = INT_MAX;
16670 int amt_ldx = INT_MAX;
16683 lua_pushstring(L,
"<UNNAMED FUNCTION>");
16684 lua_pushboolean(L, 0);
16685 lua_pushcclosure(L,
Value.Function, 2);
16690 char typestr[2] = {
Type,
'\0'};
16697 data_ldx = lua_gettop(L);
16704 if(data_ldx != INT_MAX)
16707 if(p_amt_ldx != LUA_GLOBALSINDEX)
16716 lua_pushstring(L,
"__virtvars");
16717 lua_rawget(L, p_mtb_ldx);
16718 if(lua_istable(L, -1))
16724 desttable_ldx = lua_gettop(L);
16735 desttable_ldx = p_amt_ldx;
16736 else if(lua_istable(L, p_mtb_ldx))
16737 desttable_ldx = p_mtb_ldx;
16740 if(desttable_ldx != INT_MAX)
16743 if(lua_isfunction(L, data_ldx))
16747 lua_pushstring(L,
GetName());
16748 if(lua_setupvalue(L, data_ldx, 1) == NULL) {
16756 lua_pushstring(L,
Name);
16757 lua_pushvalue(L, data_ldx);
16758 lua_rawset(L, desttable_ldx);
16763 lua_pushvalue(L, data_ldx);
16764 lua_rawset(L, desttable_ldx);
16778 if(!luaL_newmetatable(L,
Name))
16780 LuaError(L,
"ade_table_entry::SetTable - Couldn't create metatable for table entry '%s' - does a Lua object already exist with this name?",
Name);
16783 mtb_ldx = lua_gettop(L);
16788 if(data_ldx != INT_MAX)
16790 lua_pushvalue(L, mtb_ldx);
16791 lua_setmetatable(L, data_ldx);
16795 lua_pushstring(L,
"__index");
16796 lua_pushstring(L,
"ade_index_handler(get)");
16797 lua_pushboolean(L, 0);
16798 lua_pushcclosure(L, ade_index_handler, 2);
16799 lua_rawset(L, mtb_ldx);
16802 lua_pushstring(L,
"__newindex");
16803 lua_pushstring(L,
"ade_index_handler(set)");
16804 lua_pushboolean(L, 1);
16805 lua_pushcclosure(L, ade_index_handler, 2);
16806 lua_rawset(L, mtb_ldx);
16809 lua_pushstring(L,
"__virtvars");
16811 lua_rawset(L, mtb_ldx);
16814 lua_createtable(L, 0, Num_subentries);
16815 if(lua_istable(L, -1)) {
16817 amt_ldx = lua_gettop(L);
16821 lua_pushstring(L,
"__ademembers");
16822 lua_pushvalue(L, amt_ldx);
16823 lua_rawset(L, mtb_ldx);
16827 lua_pushstring(L,
"__adeid");
16829 lua_rawset(L, mtb_ldx);
16833 lua_pushstring(L,
"__adederivid");
16835 lua_rawset(L, mtb_ldx);
16839 if(amt_ldx != INT_MAX)
16844 for(i = 0; i < Ade_table_entries[
DerivatorIdx].Num_subentries; i++)
16846 Ade_table_entries[Ade_table_entries[
DerivatorIdx].Subentries[
i]].SetTable(L, amt_ldx, mtb_ldx);
16851 Ade_table_entries[
Subentries[
i]].SetTable(L, amt_ldx, mtb_ldx);
16856 lua_pop(L, cleanup_items);
16863 for(
int i = 0; i < Lua_type_names_num; i++)
16865 if(!
stricmp(Lua_type_names[i], typestr))
16867 fputs(typestr, fp);
16872 fprintf(fp,
"<a href=\"#%s\">%s</a>", typestr, typestr);
16883 bool skip_this =
false;
16903 fputs(
"<dd><dl>", fp);
16911 fprintf(fp,
"<dt id=\"%s\">",
GetName());
16916 fprintf(fp,
"<h2>%s</h2>\n",
ShortName);
16922 fprintf(fp,
"<h2>%s",
Name);
16929 fputs(
"</h2>\n", fp);
16931 fputs(
"</dt>\n", fp);
16940 fprintf(fp,
"<dd><b>Return Type: </b> %s<br> </dd>\n",
ReturnType);
16944 fprintf(fp,
"<dd><b>Return Description: </b> %s<br> </dd>\n",
ReturnDescription);
16959 fputs(
" </i>", fp);
16970 fprintf(fp,
"<b>%s",
Name);
16977 fprintf(fp,
"(%s)", ade_Operators[ao2].dest);
16985 fprintf(fp,
"<b>%s%s", Ade_table_entries[
ParentIdx].
Name, ade_Operators[ao].dest);
16988 fprintf(fp,
"<b>%s", ade_Operators[ao].dest);
16994 fprintf(fp,
"(</b><i>%s</i><b>)</b>\n",
Arguments);
16996 fprintf(fp,
"()</b>\n");
17003 fprintf(fp,
" <i>%s</i>\n",
Arguments);
17006 fputs(
"</dt>\n", fp);
17017 fputs(
"<dd><b>Returns:</b> Nothing<br> </dd>\n", fp);
17032 fputs(
"<dt>\n", fp);
17037 fputs(
" </i>", fp);
17045 fprintf(fp,
"<b>%s",
Name);
17048 fputs(
"</b>\n", fp);
17051 fprintf(fp,
" = <i>%s</i>",
Arguments);
17052 fputs(
"</dt>\n", fp);
17066 fputs(
"<dd><dl>\n", fp);
17073 fputs(
"</dl></dd>\n", fp);
17076 fputs(
"<br></dl></dd>\n", fp);
17086 Warning(
LOCATION,
"Found ade_table_entry with no name or shortname");
17092 if(ate->
Name == NULL)
17098 fprintf(fp,
"<a href=\"#%s\">%s", ate->
Name, ate->
Name);
17107 fputs(
"</dd>\n", fp);
17110 void script_state::OutputLuaMeta(FILE *
fp)
17114 fputs(
"<dl>\n", fp);
17117 fputs(
"<dt><b>Libraries</b></dt>\n", fp);
17118 for(i = 0; i < Ade_table_entries.size(); i++)
17120 ate = &Ade_table_entries[
i];
17127 fputs(
"<dt><b>Types</b></dt>\n", fp);
17128 for(i = 0; i < Ade_table_entries.size(); i++)
17130 ate = &Ade_table_entries[
i];
17137 fputs(
"<dt><b><a href=\"#Enumerations\">Enumerations</a></b></dt>", fp);
17140 fputs(
"</dl><br/><br/>", fp);
17143 fputs(
"<dl>\n", fp);
17144 for(i = 0; i < Ade_table_entries.size(); i++)
17146 ate = &Ade_table_entries[
i];
17151 fprintf(fp,
"<dt id=\"Enumerations\"><h2>Enumerations</h2></dt>");
17152 for(i = 0; i < Num_enumerations; i++)
17158 fprintf(fp,
"<dd><b>%s</b></dd>", Enumerations[i].
name);
17160 fputs(
"</dl>\n", fp);
17163 fputs(
"</dl>\n", fp);
void light_add_directional(const vec3d *dir, float intensity, float r, float g, float b, float spec_r, float spec_g, float spec_b, bool specular)
void mc_info_init(mc_info *mc)
#define BMP_FLAG_RENDER_TARGET_DYNAMIC
Texture is a dynamic type (animation)
void gr_rect(int x, int y, int w, int h, int resize_mode)
int fire_countermeasure_count
char fg_filename[MAX_FILENAME_LEN]
int cf_is_valid(CFILE *cfile)
int model_collide(mc_info *mc_info_obj)
target your target's target
#define MESSAGE_PRIORITY_NORMAL
bool model_anim_start_type(ship_subsys *pss, int animation_type, int subtype, int direction, bool instant)
int shader_effect_duration
int gr_get_fontnum(const char *filename)
cockpit_disp_info_h(ship_info *sip, size_t display_num)
int tertiary_bank_rearm_time
int timestamp(int delta_ms)
camid cam_get_camera(uint idx)
int gr_get_current_fontnum()
struct screen3d::@234::@236 xyw
#define MULTIPLAYER_CLIENT
ade_lib l_Tables("Tables", NULL,"tb","Tables library")
#define LE_MESSAGE_PRIORITY_HIGH
int ship_info_lookup(const char *token)
ade_obj< object_h > l_ShipTextures("shiptextures","Ship textures handle")
#define LE_PARTICLE_SMOKE
void sexp_modify_variable(int node)
ubyte pre_death_explosion_happened
camid cam_create(char *n_name, vec3d *n_pos, vec3d *n_norm, object *n_object, int n_object_host_submodel)
int get_object_host_submodel()
model_subsystem * system_info
weapon Weapons[MAX_WEAPONS]
int primary_bank_weapons[MAX_SHIP_PRIMARY_BANKS]
SCP_vector< ArmorType > Armor_types
float ets_get_max_speed(object *objp, float engine_energy)
int cf_get_dir_type(CFILE *cfile)
virtual void onFrame(float frametime)
int cf_delete(const char *filename, int path_type)
Delete the specified file.
toggle the squadmate messaging menu
#define MESSAGE_SOURCE_NONE
increase energy to engines
ade_obj< int > l_Persona("persona","Persona handle")
char * ship_subsys_get_name(ship_subsys *ss)
matrix * vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1)
#define TARGET_DISPLAY_DIST
int get_effect_from_name(char *name)
void mission_log_add_entry(int type, char *pname, char *sname, int info_index)
waypoint * find_matching_waypoint(const char *name)
control_info ai_override_ci
model_h(polymodel *n_model)
GLfloat GLfloat GLfloat GLfloat h
void set_object_host(object *objp, int n_object_host_submodel=-1)
char Recent_missions[MAX_RECENT_MISSIONS][MAX_FILENAME_LEN]
color * iff_get_color_by_team(int team, int seen_from_team, int is_bright)
#define LE_LUA_OVERRIDE_BUTTON_CONTROL
char Game_current_mission_filename[MAX_FILENAME_LEN]
polymodel * model_get(int model_num)
weapon_info Weapon_info[MAX_WEAPON_TYPES]
ade_obj< vec3d > l_Vector("vector","Vector object")
float shield_get_strength(object *objp)
TARGET_LAST_TRANMISSION_SENDER.
#define MOUSE_LEFT_BUTTON
SCP_vector< game_snd > Snds
#define SIF_IN_TECH_DATABASE_M
int gamesnd_get_by_tbl_index(int index)
float vm_vec_mag(const vec3d *v)
#define gr_end_view_matrix
ade_obj< cockpit_displays_h > l_CockpitDisplays("displays","Player cockpit displays array handle")
VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK.
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
#define LE_ORDER_ATTACK_WING
decrease shield recharge rate
submodel_instance_info submodel_info_1
int snd_load(game_snd *gs, int allow_hardware_load)
int sexp_add_variable(const char *text, const char *var_name, int type, int index)
ade_obj< cockpit_display_h > l_CockpitDisplay("display","Cockpit display handle")
ade_obj< object_h > l_Weapon("weapon","Weapon handle",&l_Object)
#define LE_LUA_STEERING_CONTROLS
#define SF2_NO_SUBSPACE_DRIVE
gr_set_cursor_bitmap(bm_load(s), ul)
void mission_parse_lookup_callsign_index(int index, char *out)
void credits_stop_music(bool fade)
bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum, vec3d *turret_pos, vec3d *turret_fvec, vec3d *predicted_pos=NULL, float flak_range_override=100.0f)
float afterburner_forward_accel_time_const
int calc_waypoint_index(int waypoint_instance)
asteroid Asteroids[MAX_ASTEROIDS]
#define AI_GOAL_CHASE_WING
ade_lib l_Mission_Beams("Beams",&l_Mission, NULL, NULL)
ade_lib l_CFile("CFile", NULL,"cf","CFile FS2 filesystem access")
int weapon_create(vec3d *pos, matrix *orient, int weapon_type, int parent_obj, int group_id=-1, int is_locked=0, int is_spawned=0, float fof_cooldown=0.0f, ship_subsys *src_turret=NULL)
matrix * vm_angles_2_matrix(matrix *m, const angles *a)
#define LE_MISSION_REPEAT
#define AI_GOAL_WAYPOINTS
#define LE_NORMAL_CONTROLS
void vm_rotate_matrix_by_angles(matrix *orient, const angles *tangles)
__inline void gr_circle(int xc, int yc, int d, int resize_mode=GR_RESIZE_FULL)
int model_rotate_gun(int model_num, model_subsystem *turret, matrix *orient, angles *base_angles, angles *gun_angles, vec3d *pos, vec3d *dst, int obj_idx, bool reset=false)
int hud_escort_num_ships_on_list()
matrix * vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec)
#define LE_TEXTURE_STATIC
char * Object_type_names[MAX_OBJECT_TYPES]
void object_set_gliding(object *objp, bool enable, bool force)
void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos, vec3d *gvec, int use_angles, vec3d *targetp)
int next_primary_fire_stamp[MAX_SHIP_PRIMARY_BANKS]
int ship_get_num_subsys(ship *shipp)
#define LE_PARTICLE_BITMAP
int weapon_info_lookup(const char *name=NULL)
int mission_load(char *filename_ext)
waypoint_list * find_waypoint_list_with_instance(int waypoint_instance, int *waypoint_index)
ade_lib l_Base_States("GameStates",&l_Base, NULL,"Freespace 2 states")
float vm_vec_normalize_quick(vec3d *src)
int next_secondary_fire_stamp[MAX_SHIP_SECONDARY_BANKS]
int gameseq_get_state(void)
void mission_parse_lookup_alt_index(int index, char *out)
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
physics_info_h(object *objp)
#define LE_CFILE_TYPE_MEMORY_MAPPED
wingman message: attack current target
submodel_instance_info submodel_info_2
#define gr_set_clear_color
void gr_init_alphacolor(color *clr, int r, int g, int b, int alpha, int type)
void set_position(vec3d *in_position=NULL, float in_translation_time=0.0f, float in_translation_acceleration_time=0.0f, float in_translation_deceleration_time=0.0f, float in_end_velocity=0.0f)
GLint GLint GLsizei GLsizei GLsizei depth
#define SEXP_VARIABLE_SET
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
int ship_fire_primary(object *obj, int stream_weapons, int force)
#define DIR_SEPARATOR_CHAR
int weapon_recharge_index
#define MOUSE_MIDDLE_BUTTON
texture_map_h(polymodel *n_model, texture_map *n_tmap=NULL)
target the closest ship attacking current target
#define AI_GOAL_STAY_NEAR_SHIP
#define LE_MESSAGE_PRIORITY_LOW
int run_sexp(const char *sexpression)
#define AI_GOAL_CHASE_ANY
SCP_vector< ade_table_entry > Ade_table_entries
toggle auto-match target speed
int bm_get_info(int handle, int *w, int *h, ubyte *flags, int *nframes, int *fps)
Gets info on the bitmap indexed by handle.
void set_flags(uint flags)
void get(float Time, float *Position, float *Velocity)
__inline void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
cockpit_displays_h(object *objp)
int secondary_bank_start_ammo[MAX_SHIP_SECONDARY_BANKS]
int g3_draw_polygon(const vec3d *pos, const matrix *ori, float width, float height, int tmap_flags=TMAP_FLAG_TEXTURED)
struct vec3d::@225::@227 xyz
ade_obj< int > l_Texture("texture","Texture handle")
int ai_goal_num(ai_goal *goals)
#define TMAP_HTL_3D_UNLIT
bool cam_set_camera(camid cid)
void model_render_immediate(model_render_params *render_info, int model_num, matrix *orient, vec3d *pos, int render, bool sort)
#define LE_NORMAL_BUTTON_CONTROLS
ade_obj< matrix_h > l_Matrix("orientation","Orientation matrix object")
#define ADE_FUNCNAME_UPVALUE_INDEX
int model_find_2d_bound_min(int model_num, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
int * Player_cockpit_textures
int gamesnd_get_by_name(const char *name)
bitmap_entry bm_bitmaps[MAX_BITMAPS]
int snd_is_playing(int sig)
void calculatePosition(vertex *target_point, vec3d *tpos, vec2d *outcoords, int *dir, float *half_triangle_sep)
ship_bank_h(object *objp_in, ship_weapon *wpn, int in_type, int in_bank)
#define SF2_AFFECTED_BY_GRAVITY
ai_info Ai_info[MAX_AI_INFO]
float afterburner_fuel_capacity
vec3d * vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m)
int message_persona_name_lookup(char *name)
#define END_OF_LIST(head)
#define gr_set_line_width
#define LE_LUA_FULL_CONTROLS
#define AI_GOAL_DISARM_SHIP
model_subsystem * subsystems
void set_detail_level_lock(int detail_level_lock)
particle_h(particle *part_p)
ship_subsys * targeted_subsys
ade_lib l_Mission_Messages("Messages",&l_Mission, NULL, NULL)
sexp_variable Sexp_variables[MAX_SEXP_VARIABLES]
ade_obj< thrusterbank_h > l_Thrusterbank("thrusterbank","A model thrusterbank")
#define LE_VM_PADLOCK_RIGHT
ship_subsys * homing_subsys
GLenum GLuint GLenum GLsizei const GLchar * message
void ship_reset_disabled_physics(object *objp, int ship_class)
int mouse_get_pos(int *xpos, int *ypos)
ade_lib l_Mission_EscortShips("EscortShips",&l_Mission, NULL, NULL)
void gr_set_color_fast(color *dst)
cockpit_displays_info_h()
int ship_fire_secondary(object *obj, int allow_swarm)
int turret_next_fire_stamp
bool validate_ship_ets_indxes(const int &ship_idx, int(&ets_indexes)[num_retail_ets_gauges])
void ai_clear_ship_goals(ai_info *aip)
ade_lib l_Testing("Testing", NULL,"ts","Experimental or testing stuff")
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
#define VM_EXTERNAL_CAMERA_LOCKED
void set_fov(float in_fov, float in_fov_time=0.0f, float in_fov_acceleration_time=0.0f, float in_deceleration_time=0.0f)
ade_obj< ship_subsys_h > l_Subsystem("subsystem","Ship subsystem handle")
target closest ship that is attacking player
int primary_bank_capacity[MAX_SHIP_PRIMARY_BANKS]
int tertiary_bank_start_ammo
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
int current_secondary_bank
GLfloat GLfloat GLfloat v2
int get_index_sexp_variable_name(const char *text)
ade_obj< camid > l_Camera("camera","Camera handle")
#define ADE_SETTING_UPVALUE_INDEX
int tertiary_bank_capacity
ade_obj< int > l_Team("team","Team handle")
camid game_render_frame_setup()
color current_clear_color
void snd_update_3d_pos(int soundnum, game_snd *gs, vec3d *new_pos, float radius, float range_factor)
ade_lib l_Tables_WeaponClasses("WeaponClasses",&l_Tables, NULL, NULL)
void hud_target_clear_display_list()
GLenum GLuint GLenum GLsizei const GLchar * buf
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
ade_obj< sexpvar_h > l_SEXPVariable("sexpvariable","SEXP Variable handle")
void hud_target_add_display_list(object *objp, vertex *target_point, vec3d *target_pos, int correction, color *bracket_clr, char *name, int flags)
void ship_get_global_turret_info(object *objp, model_subsystem *tp, vec3d *gpos, vec3d *gvec)
SCP_vector< message_extra > Message_waves
void get_post_process_effect_names(SCP_vector< SCP_string > &names)
SCP_list< waypoint_list > Waypoint_lists
ade_obj< int > l_Control_Info("control info","control info handle")
int calc_waypoint_instance(int waypoint_list_index, int waypoint_index)
ade_obj< int > l_Font("font","font handle")
#define BMP_FLAG_RENDER_TARGET_STATIC
Texture is a static type.
script_state Script_system("FS2_Open Scripting")
#define gr_end_proj_matrix
SCP_list< CJumpNode > Jump_nodes
void get_info(vec3d *position, matrix *orientation)
char filename[MAX_FILENAME_LEN]
ade_lib l_Mission_Debris("Debris",&l_Mission, NULL,"debris in the mission")
int hud_escort_return_objnum(int index)
int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *keyframe, int can_drop_frames, int dir_type)
Loads a bitmap sequance so we can draw with it.
#define CLAMP(x, min, max)
ade_obj< object_h > l_Object
waypoint * find_waypoint_with_objnum(int objnum)
float forward_decel_time_const
iff_info Iff_info[MAX_IFFS]
void ai_start_waypoints(object *objp, waypoint_list *wp_list, int wp_flags)
transfer shield energy to right
void sexp_variable_delete(int index)
void gr_set_color(int r, int g, int b)
SCP_vector< waypoint > & get_waypoints()
cockpit_displays_info_h(int ship_info_idx)
stop targeting subsystems on ship
SCP_vector< cockpit_display > Player_displays
int bm_is_valid(int handle)
Checks if the bitmap indexed by handle is valid.
thrusters_h(polymodel *pm)
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
ade_obj< int > l_Shipclass("shipclass","Ship class handle")
player Players[MAX_PLAYERS]
ade_obj< thrusters_h > l_Thrusters("thrusters","The thrusters of a model")
ade_lib l_HookVar_Globals("Globals",&l_HookVar)
int strextcmp(const char *s1, const char *s2)
#define gr_set_view_matrix
SCP_vector< MMessage > Messages
void snd_rewind(int snd_handle, game_snd *gs, float seconds)
ade_obj< object_h > l_Debris("debris","Debris handle",&l_Object)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
EModelAnimationPosition secondary_animation_position[MAX_SHIP_SECONDARY_BANKS]
matrix * vm_transpose(matrix *m)
#define LE_TEXTURE_DYNAMIC
void set_object_target(object *objp, int n_object_target_submodel=-1)
SCP_vector< HudGauge * > default_hud_gauges
matrix * vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec)
int ok_to_target_timestamp
void set_name(const char *name)
void weapon_set_tracking_info(int weapon_objnum, int parent_objnum, int target_objnum, int target_is_locked=0, ship_subsys *target_subsys=NULL)
void vm_vec_add2(vec3d *dest, const vec3d *src)
#define GR_ALPHABLEND_FILTER
char pof_file[MAX_FILENAME_LEN]
int shader_effect_start_time
int l_cf_get_path_id(char *n_path)
#define LE_VM_PADLOCK_REAR
#define gr_set_proj_matrix
#define LE_ALPHABLEND_NONE
ship_subsys * ship_get_indexed_subsys(ship *sp, int index, vec3d *attacker_pos)
ade_obj< int > l_Event("event","Mission event handle")
GLdouble GLdouble GLdouble r
#define LE_MOUSE_RIGHT_BUTTON
ade_get_args(L,"|i",&depth)
ship_subsys * turret_subsys
ade_virtvar(char *name, lua_CFunction func, ade_lib_handle &parent, char *args=NULL, char *desc=NULL, char *ret_type=NULL, char *ret_desc=NULL)
int ds_get_channel(int sig)
struct matrix::@228::@230 vec
#define HUD_OBJECT_CUSTOM
glowpoint_h(glow_point *np)
union ade_table_entry::@260 Value
order_h(object *objp, int n_odx)
ade_obj< gamestate_h > l_GameState("gamestate","Game state")
#define LOG_SHIP_DISABLED
float ship_max_hull_strength
message targeted ship (if player)
#define LE_VM_WARPIN_ANCHOR
void vm_vec_scale(vec3d *dest, float s)
int timestamp_until(int stamp)
const int num_retail_ets_gauges
const char * getCustomGaugeText()
void ship_end_render_cockpit_display(int cockpit_display_num)
__inline void gr_arc(int xc, int yc, float r, float angle_start, float angle_end, bool fill, int resize_mode=GR_RESIZE_FULL)
int g3_draw_sphere(vertex *pnt, float rad)
int snd_get_pitch(int sig)
ade_obj< cockpit_displays_info_h > l_CockpitDisplayInfos("cockpitdisplays","Array of cockpit display information")
int gameseq_get_state_idx(char *s)
wingman message: cover me
void ai_attack_wing(object *attacker, int wingnum)
#define MSS_FLAG_TURRET_RESET_IDLE
int primary_bank_ammo[MAX_SHIP_PRIMARY_BANKS]
char * cfgets(char *buf, int n, CFILE *cfile)
#define SW_FLAG_TURRET_LOCK
int * ship_replacement_textures
cf_pathtype Pathtypes[CF_MAX_PATH_TYPES]
GLboolean GLboolean GLboolean GLboolean a
int secondary_bank_capacity[MAX_SHIP_SECONDARY_BANKS]
int cf_exists_full(const char *filename, int dir_type)
toggle between high and low HUD contrast
__inline void gr_unfilled_circle(int xc, int yc, int d, int resize_mode=GR_RESIZE_FULL)
int armor_type_get_idx(char *name)
int get_max_ammo_count_for_bank(int ship_class, int bank, int ammo_type)
ade_lib l_Mission_BuiltinMessages("BuiltinMessages",&l_Mission, NULL, NULL)
void g3_set_view_matrix(const vec3d *view_pos, const matrix *view_matrix, float zoom)
float get_hull_pct(object *objp)
increase shield recharge rate
void model_clear_instance(int model_num)
char name[MAX_FILENAME_LEN]
float slide_decel_time_const
#define strnicmp(s1, s2, n)
ade_obj< int > l_Shiptype("shiptype","Ship type handle")
int id
index into Sounds[], where sound data is stored
ade_lib l_Base_Events("GameEvents",&l_Base, NULL,"Freespace 2 game events")
ai_goal goals[MAX_AI_GOALS]
int snd_play_3d(game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius, vec3d *source_vel, int looping, float vol_scale, int priority, vec3d *sound_fvec, float range_factor, int force, bool is_ambient)
mission_event Mission_events[MAX_MISSION_EVENTS]
texture_map maps[MAX_MODEL_TEXTURES]
#define LE_SEXPVAR_TYPE_NUMBER
ade_lib l_Base("Base", NULL,"ba","Base FreeSpace 2 functions")
int FindTexture(int bm_handle)
ade_obj< int > l_Soundfile("soundfile","Handle to a sound file")
int primary_animation_done_time[MAX_SHIP_PRIMARY_BANKS]
ade_obj< object_h > l_Beam("beam","Beam handle",&l_Object)
void game_shudder_apply(int, float)
void vm_vec_sub2(vec3d *dest, const vec3d *src)
ade_obj< sound_h > l_Sound3D("3Dsound","3D sound instance handle",&l_Sound)
void ship_subsys_set_name(ship_subsys *ss, char *n_name)
ade_obj< physics_info_h > l_Physics("physics","Physics handle")
ade_obj< object_h > l_Waypoint("waypoint","waypoint handle",&l_Object)
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
#define LE_SEXPVAR_CAMPAIGN_PERSISTENT
#define ADE_VIRTVAR(name, parent, args, desc, ret_type, ret_desc)
void set_team_color(team_color &clr)
SCP_string default_team_name
const char * bm_get_filename(int handle)
Gets the filename of the bitmap indexed by handle, which must exist.
decrease energy to engines
int next_tertiary_fire_stamp
#define SF_HIDDEN_FROM_SENSORS
sound_h(int n_gs_idx, int n_sig)
int object_in_turret_fov(object *objp, ship_subsys *ss, vec3d *tvec, vec3d *tpos, float dist)
int iff_lookup(char *iff_name)
ubyte g3_rotate_vertex(vertex *dest, const vec3d *src)
EModelAnimationPosition primary_animation_position[MAX_SHIP_PRIMARY_BANKS]
#define LE_PARTICLE_DEBUG
wingman message: disarm current target
vec3d norm[MAX_DOCK_SLOTS]
ade_obj< ship_bank_h > l_WeaponBank("weaponbank","Ship/subystem weapons bank handle")
int snd_play(game_snd *gs, float pan, float vol_scale, int priority, bool is_voice_msg)
ade_lib l_Mission_SEXPVariables("SEXPVariables",&l_Mission, NULL,"SEXP Variables")
#define AI_GOAL_STAY_STILL
int engine_recharge_index
#define SF_PRIMARY_LINKED
fix game_get_overall_frametime()
virtual void preprocess()
int secondary_bank_weapons[MAX_SHIP_SECONDARY_BANKS]
HudGauge * hud_get_gauge(const char *name)
int ade_friendly_error(lua_State *L)
void button_info_clear(button_info *bi)
int get_max_ammo_count_for_primary_bank(int ship_class, int bank, int ammo_type)
int model_anim_get_time_type(ship_subsys *pss, int animation_type, int subtype)
int cf_rename(const char *old_name, const char *name, int dir_type)
texture_map_h(int modelnum, texture_map *n_tmap=NULL)
#define LE_VM_EXTERNAL_CAMERA_LOCKED
float vm_vec_dist(const vec3d *v0, const vec3d *v1)
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char)
ade_obj< int > l_Species("species","Species handle")
void snd_set_pitch(int sig, int pitch)
#define LE_ORDER_WAYPOINTS_ONCE
wingman message: form on my wing
int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile)
ade_lib l_Graphics("Graphics", NULL,"gr","Graphics Library")
int waypoint_add(vec3d *pos, int waypoint_instance)
float shield_get_max_strength(object *objp)
angles * vm_extract_angles_matrix(angles *a, const matrix *m)
void do_subobj_destroyed_stuff(ship *ship_p, ship_subsys *subsys, vec3d *hitpos, bool no_explosion)
bool scripting_target_override
target next subsystem on current target
cycle number of missiles fired from secondary bank
int model_load(char *filename, int n_subsystems, model_subsystem *subsystems, int ferror=1, int duplicate=0)
#define gr_post_process_set_defaults
#define LE_ORDER_ATTACK_ANY
char filename[MAX_FILENAME_LEN]
ade_obj< order_h > l_Order("order","order handle")
#define AI_GOAL_EVADE_SHIP
bool bm_set_render_target(int handle, int face)
(GR function) Calls gr_bm_set_render target for the given bitmap indexed by handle ...
char bg_filename[MAX_FILENAME_LEN]
ade_obj< object_h > l_Ship("ship","Ship handle",&l_Object)
void message_training_queue(char *text, int timestamp, int length)
int psnet_use_protocol(int protocol)
void model_page_in_textures(int modelnum, int ship_info_index=-1)
ade_lib l_Mission_Waypoints("Waypoints",&l_Mission, NULL, NULL)
float vm_vec_normalize_safe(vec3d *v)
#define MESSAGE_PRIORITY_LOW
int g3_project_vertex(vertex *point)
void shield_set_quad(object *objp, int quadrant_num, float strength)
ade_lib l_Mission_Wings("Wings",&l_Mission, NULL, NULL)
int secondary_bank_ammo[MAX_SHIP_SECONDARY_BANKS]
debris Debris[MAX_DEBRIS_PIECES]
void audiostream_unpause(int i, bool via_sexp_or_script)
#define SIF_IN_TECH_DATABASE
void setAVD(float final_position, float total_movement_time, float starting_accleration_time, float ending_acceleration_time, float final_velocity)
void ship_recalc_subsys_strength(ship *shipp)
vec3d * vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m)
void SetStatus(int n_status)
void game_post_level_init()
int cfread_lua_number(double *buf, CFILE *cfile)
cycle to previous primary weapon
target ship closest to center of reticle
target the closest friendly ship
#define AI_GOAL_IGNORE_NEW
void game_render_frame(camid cid)
#define AI_GOAL_FLY_TO_SHIP
int get_subsystem_pos(vec3d *pos, object *objp, ship_subsys *subsysp)
const char * getCustomGaugeName()
int snd_get_duration(int snd_id)
object Objects[MAX_OBJECTS]
ade_lib l_Mission_Personas("Personas",&l_Mission, NULL, NULL)
void shipfx_warpin_start(object *objp)
transfer energy to shield from weapons
#define LE_SEXPVAR_PLAYER_PERSISTENT
#define AI_GOAL_PLAY_DEAD
int get_mission_info(const char *filename, mission *mission_p, bool basic)
cycle to next secondary weapon
vec3d afterburner_max_vel
int sexp_variable_count()
void game_simulation_frame()
#define SF_ARRIVING_STAGE_1
int ship_create(matrix *orient, vec3d *pos, int ship_type, char *ship_name)
ade_lib l_Mouse("Controls", NULL,"io","Controls library")
eyepoints_h(polymodel *pm)
#define AI_GOAL_WAYPOINTS_ONCE
#define MH_ANGLES_OUTOFDATE
#define LE_MOUSE_LEFT_BUTTON
int shield_armor_type_idx
dock_bay * getDockingBay()
#define gr_post_process_set_effect
ade_lib l_Graphics_Cameras("Cameras",&l_Graphics, NULL,"Cameras")
target the closest repair ship
int snd_get_3d_vol_and_pan(game_snd *gs, vec3d *pos, float *vol, float *pan, float radius, float range_factor)
void briefing_stop_music(bool fade)
ade_obj< glowpoint_h > l_Glowpoint("glowpoint","A model glowpoint")
#define LE_VM_PADLOCK_LEFT
#define MULTIPLAYER_STANDALONE
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
void OutputMeta(FILE *fp)
int ai_override_timestamp
wingman message: engage enemy
dockingbay_h(polymodel *pm, int dock_idx)
#define AI_GOAL_GUARD_WING
thrusterbank_h(thruster_bank *ba)
float forward_cruise_percent
ade_func(char *name, lua_CFunction func, ade_lib_handle &parent, char *args=NULL, char *desc=NULL, char *ret_type=NULL, char *ret_desc=NULL)
void set_rotation(matrix *in_orientation=NULL, float in_rotation_time=0.0f, float in_rotation_acceleration_time=0.0f, float in_rotation_deceleration_time=0.0f)
int wing_name_lookup(const char *name, int ignore_count)
void sanity_check_ets_inputs(int(&ets_indexes)[num_retail_ets_gauges])
if i'm an observer, zoom to my targeted object
const char * snd_get_filename(int snd_id)
int SetTexture(int n_tex)
GLuint const GLchar * name
union MissionMessage::@255 wave_info
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
cockpit_display_h(object *objp, size_t display_num)
ade_lib l_Campaign("Campaign", NULL,"ca","Campaign Library")
int secondary_bank_rearm_time[MAX_SHIP_SECONDARY_BANKS]
ade_lib l_Mission_WaypointLists("WaypointLists",&l_Mission, NULL, NULL)
ade_obj< waypointlist_h > l_WaypointList("waypointlist","waypointlist handle")
void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1)
transfer energy to weapons from shield
TrackIRDLL gTirDll_TrackIR
bool sexp_replace_variable_names_with_values(char *text, int max_len)
bool weapon_armed(weapon *wp, bool hit_target)
int ade_set_object_with_breed(lua_State *L, int obj_idx)
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
GLboolean GLboolean GLboolean b
int bm_get_cache_slot(int bitmap_id, int separate_ani_frames)
dockingbays_h(polymodel *pm)
SCP_vector< cockpit_display_info > displays
int model_find_dock_name_index(int modelnum, char *name)
#define HUD_OBJECT_OFFSCREEN
void model_instance_find_world_dir(vec3d *out_dir, vec3d *in_dir, int model_instance_num, int submodel_num, const matrix *objorient)
float turret_turning_rate
void audiostream_close_file(int i, int fade)
flag_def_list plr_commands[]
wingman message: protect current target
#define MESSAGE_PRIORITY_HIGH
bool add_message(char *name, char *message, int persona_index, int multi_team)
equalize shield energy to all quadrants
#define MOUSE_RIGHT_BUTTON
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void ade_stackdump(lua_State *L, char *stackdump)
ade_lib l_Mission_Asteroids("Asteroids",&l_Mission, NULL,"Asteroids in the mission")
#define LE_MESSAGE_PRIORITY_NORMAL
#define MAX_REPLACEMENT_TEXTURES
#define ADE_FUNC(name, parent, args, desc, ret_type, ret_desc)
ship_subsys * ship_get_subsys(ship *shipp, char *subsys_name)
#define LE_SEXPVAR_NOT_PERSISTENT
waypointlist_h(char wlname[NAME_LENGTH])
int ship_launch_countermeasure(object *objp, int rand_val)
HUD_TARGETBOX_TOGGLE_WIREFRAME.
#define LE_MOUSE_MIDDLE_BUTTON
void CAP(T &v, T mn, T mx)
#define LE_PARTICLE_PERSISTENT_BITMAP
int secondary_next_slot[MAX_SHIP_SECONDARY_BANKS]
ade_obj< dockingbays_h > l_Dockingbays("dockingbays","The docking bays of a model")
waypoint_list * find_matching_waypoint_list(const char *name)
#define LE_ORDER_GUARD_WING
GLint GLsizei GLsizei height
#define AI_GOAL_KEEP_SAFE_DISTANCE
#define SF_SECONDARY_DUAL_FIRE
GLubyte GLubyte GLubyte GLubyte w
ship_subsys * target_subsys
#define AI_GOAL_DISABLE_SHIP
int set_target_objnum(ai_info *aip, int objnum)
int snd_time_remaining(int handle)
target ships subsystem in reticle
waypoint_list * find_waypoint_list_at_index(int index)
camid cam_lookup(char *name)
void ai_add_ship_goal_scripting(int mode, int submode, int priority, char *shipname, ai_info *aip)
#define LE_PARTICLE_SMOKE2
ade_obj< int > l_Wing("wing","Wing handle")
void hud_disable_except_messages(int disable)
ade_lib l_Graphics_Fonts("Fonts",&l_Graphics, NULL,"Font library")
void gr_bitmap_list(bitmap_2d_list *list, int n_bm, int resize_mode)
void audiostream_unpause_all(bool via_sexp_or_script=false)
#define MH_MATRIX_OUTOFDATE
class camera * getCamera()
float shield_get_quad(object *objp, int quadrant_num)
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
ade_obj< CFILE * > l_File("file","File handle")
ade_lib l_Mission("Mission", NULL,"mn","Mission library")
ade_obj< gameevent_h > l_GameEvent("gameevent","Game event")
float forward_accel_time_const
void game_render_post_frame()
#define MAX_AUDIO_STREAMS
int snd_play_looping(game_snd *gs, float pan, int start_loop, int stop_loop, float vol_scale, int scriptingUpdateVolume)
#define SEXP_VARIABLE_CAMPAIGN_PERSISTENT
void mission_campaign_jump_to_mission(char *name, bool no_skip)
ship_subsys * targeted_subsys
ade_obj< sound_h > l_Sound("sound","sound instance handle")
#define MAX_FRAME_COLLISIONS
char subobj_name[MAX_NAME_LEN]
int SetTable(lua_State *L, int p_amt_ldx, int p_mtb_ldx)
void set_name(char *in_name)
int get_object_target_submodel()
#define LE_ORDER_STAY_NEAR
void physics_apply_whack(vec3d *impulse, vec3d *pos, physics_info *pi, matrix *orient, float mass)
GLsizei const GLchar ** path
bool shader_effect_active
void ship_hit_kill(object *ship_objp, object *other_obj, float percent_killed, int self_destruct)
void snd_ffwd(int snd_handle, game_snd *gs, float seconds)
cycle to next primary weapon
#define ODATA_SIG_DEFAULT
char variable_name[TOKEN_LENGTH]
ade_obj< HudGauge > l_HudGauge("HudGauge","HUD Gauge handle")
int find_index_of_waypoint_list(waypoint_list *wp_list)
float slide_accel_time_const
#define MULTIPLAYER_MASTER
ade_lib l_Mission_Weapons("Weapons",&l_Mission, NULL, NULL)
void message_send_unique_to_player(char *id, void *data, int m_source, int priority, int group, int delay)
void snd_set_volume(int sig, float volume)
texture_info textures[TM_NUM_TYPES]
SCP_vector< ship_info > Ship_info
int secondary_animation_done_time[MAX_SHIP_SECONDARY_BANKS]
vec3d * vm_vec_avg(vec3d *dest, const vec3d *src0, const vec3d *src1)
void ade_debug_ret(lua_State *L, lua_Debug *ar)
decrease weapon recharge rate
int submodel_find_2d_bound_min(int model_num, int submodel, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
void ade_output_toc(FILE *fp, ade_table_entry *ate)
void snd_set_pos(int snd_handle, game_snd *gs, float val, int as_pct)
ade_lib l_Mission_Ships("Ships",&l_Mission, NULL,"Ships in the mission")
#define AI_GOAL_CHASE_WEAPON
#define LE_ORDER_WAYPOINTS
#define TMAP_FLAG_TEXTURED
int model_anim_match_type(char *p)
__inline void gr_aabitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode=GR_RESIZE_FULL, bool mirror=false)
int gameseq_get_event_idx(char *s)
SCP_vector< species_info > Species_info
object * get_object_host()
MINUS_5_PERCENT_THROTTLE.
void resize(int *x, int *y)
show the mission goals screen
void shipfx_warpout_start(object *objp)
char * maneuverability_str
void audiostream_play(int i, float volume, int looping)
char * objective_key_text
transfer shield energy to left
modeltextures_h(polymodel *pm)
float Master_event_music_volume
GLsizei GLsizei GLuint * obj
target the next friendly ship
wingman message: capture current target
int add_wave(const char *wave_name)
void change_ship_type(int n, int ship_type, int by_sexp)
target the previous closest hostile
void shield_set_max_strength(object *objp, float newmax)
float vm_vec_dot(const vec3d *v0, const vec3d *v1)
cockpit_display_info * Get()
ade_lib l_Graphics_Posteffects("PostEffects",&l_Graphics, NULL,"Post processing effects")
void shield_set_strength(object *objp, float strength)
TARGET_PREV_UNINSPECTED_CARGO.
beam_collision f_collisions[MAX_FRAME_COLLISIONS]
wingman message: disable current target
void asteroid_hit(object *pasteroid_obj, object *other_obj, vec3d *hitpos, float damage)
#define LE_ORDER_STAY_STILL
ade_lib l_Audio("Audio", NULL,"ad","Sound/Music Library")
ade_obj< particle_h > l_Particle("particle","Handle to a particle")
physics_info_h(physics_info *in_pi)
#define MAX_CAMPAIGN_MISSIONS
GLsizei GLsizei GLchar * source
ade_obj< object_h > l_Asteroid("asteroid","Asteroid handle",&l_Object)
string_conv ade_Operators[]
#define GR_BITBLT_MODE_NORMAL
void hud_shield_hit_reset(object *objp, int player)
#define CF_MAX_PATH_TYPES
ade_obj< model_h > l_Model("model","3D Model (POF) handle")
float shockwave_shake_amp
#define ADE_INDEXER(parent, args, desc, ret_type, ret_desc)
ade_obj< mc_info_h > l_ColInfo("collision info","Information about a collision")
void ai_set_guard_wing(object *objp, int wingnum)
#define LE_CFILE_TYPE_NORMAL
eye view_positions[MAX_EYES]
#define SEXP_VARIABLE_NUMBER
ade_obj< object_h > l_Shields("shields","Shields handle")
void ade_debug_call(lua_State *L, lua_Debug *ar)
ade_obj< eyepoints_h > l_Eyepoints("eyepoints","Array of model eye points")
self destruct (multiplayer only)
wingman message: warp out
#define AI_GOAL_REARM_REPAIR
char variable_name[TOKEN_LENGTH]
ade_obj< object_h > l_ShipOrders("shiporders","Ship orders")
ade_obj< texture_map_h > l_TextureMap("material","Texture map, including diffuse, glow, and specular textures")
cycle to next radar range
int audiostream_open(const char *filename, int type)
#define PF_AFTERBURNER_ON
ship_subsys_h(object *objp_in, ship_subsys *sub)
int ship_index[MAX_SHIPS_PER_WING]
#define LE_ALPHABLEND_FILTER
bool Ade_get_args_lfunction
const char * ade_get_type_string(lua_State *L, int argnum)
ade_lib l_Mission_Events("Events",&l_Mission, NULL,"Events")
void model_calc_bound_box(vec3d *box, vec3d *big_mn, vec3d *big_mx)
int primary_bank_rearm_time[MAX_SHIP_PRIMARY_BANKS]
int ade_get_operator(char *tablename)
int ship_get_subsys_index(ship *sp, char *ss_name, int error_bypass)
int is_white_space(char ch)
ade_obj< enum_h > l_Enum("enumeration","Enumeration object")
#define LE_ORDER_FORM_ON_WING
#define PLAYER_FLAGS_IS_MULTI
float hud_find_target_distance(object *targetee, object *targeter)
int primary_bank_start_ammo[MAX_SHIP_PRIMARY_BANKS]
object * get_object_target()
void game_update_missiontime()
gr_init_alphacolor &[idx] HUD_config
int ship_name_lookup(const char *name, int inc_players)
void audiostream_pause(int i, bool via_sexp_or_script)
vec3d * vm_vec_cross(vec3d *dest, const vec3d *src0, const vec3d *src1)
ade_obj< ship_banktype_h > l_WeaponBankType("weaponbanktype","Ship/subsystem weapons bank type handle")
int obj_get_by_signature(int sig)
#define GR_ALPHABLEND_NONE
particle * particle_create(particle_info *pinfo)
int current_tertiary_bank
#define LE_LUA_ADDITIVE_BUTTON_CONTROL
void gamesnd_play_iface(int n)
int draw_subsys_brackets(ship_subsys *subsys, int min_width, int min_height, bool draw, bool set_color, int *draw_coords)
#define AI_GOAL_DESTROY_SUBSYSTEM
#define WF_DESTROYED_BY_WEAPON
ade_obj< sound_entry_h > l_SoundEntry("soundentry","sounds.tbl table entry handle")
void audiostream_pause_all(bool via_sexp_or_script=false)
#define MESSAGE_SOURCE_SPECIAL
int cfclose(CFILE *cfile)
#define LE_ORDER_KEEP_SAFE_DISTANCE
wingman message: disable current target
__inline void gr_pixel(int x, int y, int resize_mode=GR_RESIZE_FULL)
void gr_set_font(int fontnum)
GLclampf GLclampf GLclampf alpha
int bm_make_render_target(int width, int height, int flags)
Creates a render target as close to the desired resolution as possible.
ade_obj< int > l_Message("message","Handle to a mission message")
ade_indexer(lua_CFunction func, ade_lib_handle &parent, char *args=NULL, char *desc=NULL, char *ret_type=NULL, char *ret_desc=NULL)
ade_lib(char *in_name, ade_lib_handle *parent=NULL, char *in_shortname=NULL, char *in_desc=NULL)
#define MESSAGE_SOURCE_COMMAND
void main_hall_stop_music(bool fade)
ade_obj< int > l_Player("player","Player handle")
int ship_start_render_cockpit_display(int cockpit_display_num)
void ade_output_type_link(FILE *fp, char *typestr)
float default_volume
range: 0.0 -> 1.0
int main_hall_get_index(const SCP_string &name_to_find)
void renderOffscreenIndicator(vec2d *coords, int dir, float distance, float half_triangle_sep, bool draw_solid=true)
int hud_disabled_except_messages()
Like hud_disabled(), except messages are still drawn.
char filename[FILESPEC_LENGTH]
increase weapon recharge rate
void _cdecl void LuaError(struct lua_State *L, SCP_FORMAT_STRING const char *format=NULL,...) SCP_FORMAT_STRING_ARGS(2
void g3_point_to_vec(vec3d *v, int sx, int sy)
void draw_brackets_square(int x1, int y1, int x2, int y2, int resize_mode)
void updateCustomGaugeText(const char *txt)
SCP_vector< asteroid_info > Asteroid_info
ade_obj< modeltextures_h > l_ModelTextures("modeltextures_h","Array of materials")
int timer_get_milliseconds()
void gameseq_post_event(int event)
TARGET_NEXT_UNINSPECTED_CARGO.
void hud_set_iff_color(object *objp, int is_bright)
Will set the color to the IFF color based on the team.
vec3d pnt[MAX_DOCK_SLOTS]
int shield_recharge_index
void vm_vec_add(vec3d *dest, const vec3d *src0, const vec3d *src1)
transfer shield energy to rear
matrix vmd_identity_matrix
ade_obj< eye_h > l_Eyepoint("eyepoint","Eyepoint handle")
#define timestamp_valid(stamp)
#define AI_GOAL_FORM_ON_WING
int wing_lookup(const char *name)
multi_global_options Multi_options_g
void message_load_wave(int index, const char *filename)
#define LE_SEXPVAR_TYPE_STRING
ship_banktype_h(object *objp_in, ship_weapon *wpn, int in_type)
int cfilelength(CFILE *cfile)
target the next hostile target
char ship_name[NAME_LENGTH]
ship_subsys * set_targeted_subsys(ai_info *aip, ship_subsys *new_subsys, int parent_objnum)
ade_obj< dockingbay_h > l_Dockingbay("dockingbay","Handle to a model docking bay")
return ade_set_args(L,"f",*val)
float VIEWER_ZOOM_DEFAULT
char * ade_concat_helper(lua_State *L, int obj_ldx)
transfer shield energy to front
#define SEXP_VARIABLE_STRING
int cf_exists(const char *filename, int dir_type)
SCP_vector< ship_type_info > Ship_types
void model_set_detail_level(int n)
texture_map_h(object *objp, texture_map *n_tmap=NULL)
cmission missions[MAX_CAMPAIGN_MISSIONS]
#define MAX_SEXP_VARIABLES
ade_lib l_HUD("HUD", NULL,"hu","HUD library")
ade_lib l_BitOps("BitOps", NULL,"bit","Bitwise Operations library")
#define LE_ORDER_PLAY_DEAD
ade_obj< cockpit_disp_info_h > l_DisplayInfo("display info","Ship cockpit display information handle")
ade_lib l_Tables_ShipClasses("ShipClasses",&l_Tables, NULL, NULL)
waypointlist_h(waypoint_list *n_wlp)
#define g3_start_frame(zbuffer_flag)
GLfloat GLfloat GLfloat GLfloat v3
void snd_set_pan(int sig, float pan)
float vm_vec_normalize(vec3d *v)
ade_lib l_Mission_Teams("Teams",&l_Mission, NULL, NULL)
#define SEXP_VARIABLE_PLAYER_PERSISTENT
ade_lib l_HookVar("HookVariables", NULL,"hv","Hook variables repository")
int snd_play_raw(int soundnum, float pan, float vol_scale, int priority)
ade_obj< int > l_Weaponclass("weaponclass","Weapon class handle")
void ai_remove_ship_goal(ai_info *aip, int index)
int cfseek(CFILE *fp, int offset, int where)
int gamesnd_get_by_iface_tbl_index(int index)