134                                 st->
ParseChunk(&Script_gameinithook, 
"GameInit");
 
  138                                 st->
ParseChunk(&Script_simulationhook, 
"Simulation");
 
  181                 mprintf((
"TABLES: Unable to parse '%s'!  Error message = %s.\n", filename, e.what()));
 
  190         mprintf((
"SCRIPTING: Beginning initialization sequence...\n"));
 
  199         mprintf((
"SCRIPTING: Beginning Lua initialization...\n"));
 
  204                 mprintf((
"SCRIPTING: Outputting scripting metadata...\n"));
 
  207         mprintf((
"SCRIPTING: Beginning main hook parse sequence....\n"));
 
  210         mprintf((
"SCRIPTING: Inititialization complete.\n"));
 
  236                 if(Conditions[
i].condition_type == 
CHC_NONE)
 
  251         Actions.push_back(*sa);
 
  265                 scp = &Conditions[
i];
 
  337                                                 bool primary = 
false, secondary = 
false, prev_primary = 
false, prev_secondary = 
false;
 
  343                                                                 if (!(primary || secondary))
 
  359                                                                 if ( !prev_secondary && ! secondary && !prev_primary && !primary )
 
  362                                                                 if ( (!prev_secondary && !secondary) && (prev_primary && primary) ) 
 
  365                                                                 if ( (!prev_secondary && !secondary) && (!prev_primary && primary) ) 
 
  368                                                                 if ( (!prev_primary && !primary) && (prev_secondary && secondary) )
 
  371                                                                 if ( (!prev_primary && !primary) && (!prev_secondary && secondary) )
 
  376                                                                 bool equipped = 
false;
 
  403                                                                 if (more_data == 1) {
 
  414                                                                 return more_data == 1 ? primary : secondary;
 
  454                                         if(Current_key_down == 0)
 
  466                                         int action_index = more_data;
 
  521                 if(sap->action_type == action)
 
  536                 if(sap->action_type == action)
 
  560         if(this->OpenHookVarTable())
 
  562                 int amt_ldx = lua_gettop(LuaState);
 
  563                 for(
int i = 0; 
i < 
num; 
i++)
 
  565                         char *
name = va_arg(vl, 
char*);
 
  566                         object *
objp = va_arg(vl, 
object*);
 
  569                         int data_ldx = lua_gettop(LuaState);
 
  571                         lua_pushstring(LuaState, name);
 
  572                         lua_pushvalue(LuaState, data_ldx);
 
  573                         lua_rawset(LuaState, amt_ldx);
 
  575                         lua_pop(LuaState, 1);   
 
  577                 this->CloseHookVarTable();
 
  581                 LuaError(LuaState, 
"Could not get HookVariable library to add hook variables - get a coder");
 
  591 static int ohvt_poststack = 0;          
 
  592 static int ohvt_isopen = 0;                     
 
  593 bool script_state::OpenHookVarTable()
 
  596                 Error(
LOCATION, 
"OpenHookVarTable was called twice with no call to CloseHookVarTable - missing call ahoy!");
 
  598         lua_pushstring(LuaState, 
"hv");
 
  599         lua_gettable(LuaState, LUA_GLOBALSINDEX);
 
  600         int sv_ldx = lua_gettop(LuaState);
 
  601         if(lua_isuserdata(LuaState, sv_ldx))
 
  604                 lua_getmetatable(LuaState, sv_ldx);
 
  605                 int mtb_ldx = lua_gettop(LuaState);
 
  606                 if(lua_istable(LuaState, mtb_ldx))
 
  609                         lua_pushstring(LuaState, 
"__ademembers");
 
  610                         lua_rawget(LuaState, mtb_ldx);
 
  611                         int amt_ldx = lua_gettop(LuaState);
 
  612                         if(lua_istable(LuaState, amt_ldx))
 
  615                                 ohvt_poststack = amt_ldx;
 
  618                         lua_pop(LuaState, 1);   
 
  620                 lua_pop(LuaState, 1);   
 
  622         lua_pop(LuaState, 1);   
 
  630 bool script_state::CloseHookVarTable()
 
  634                 Error(
LOCATION, 
"CloseHookVarTable was called with no associated call to OpenHookVarTable");
 
  636         int top_ldx = lua_gettop(LuaState);
 
  637         if(top_ldx >= ohvt_poststack)
 
  639                 lua_pop(LuaState, ohvt_isopen);
 
  645                 Error(
LOCATION, 
"CloseHookVarTable() was called with too few objects on the stack; get a coder. (Stack: %d OHVT post: %d OHVT num: %d", top_ldx, ohvt_poststack, ohvt_isopen);
 
  657                 char fmt[2] = {
format, 
'\0'};
 
  660                         data_ldx = lua_gettop(LuaState);
 
  662                 if(data_ldx < 1 && data == NULL)
 
  666                 if(this->OpenHookVarTable())
 
  668                         int amt_ldx = lua_gettop(LuaState);
 
  669                         lua_pushstring(LuaState, name);
 
  679                                 lua_pushvalue(LuaState, data_ldx);
 
  685                                 else if (format == 
'i')
 
  695                         lua_rawset(LuaState, amt_ldx);
 
  698                                 lua_pop(LuaState, 1);
 
  700                         this->CloseHookVarTable();
 
  704                         LuaError(LuaState, 
"Could not get HookVariable library to set hook variable '%s'", name);
 
  706                                 lua_pop(LuaState, 1);
 
  714         bool got_global = 
false;
 
  718                 char fmt[3] = {
'|', 
format, 
'\0'};
 
  723                 if(this->OpenHookVarTable())
 
  725                         int amt_ldx = lua_gettop(LuaState);
 
  727                         lua_pushstring(LuaState, name);
 
  728                         lua_rawget(LuaState, amt_ldx);
 
  729                         if(!lua_isnil(LuaState, -1))
 
  736                         lua_pop(LuaState, 1);   
 
  738                         this->CloseHookVarTable();
 
  742                         LuaError(LuaState, 
"Could not get HookVariable library to get hook variable '%s'", name);
 
  761                 if(this->OpenHookVarTable())
 
  763                         int amt_ldx = lua_gettop(LuaState);
 
  766                         for(
unsigned int i = 0; 
i < 
num; 
i++)
 
  768                                 char *
name = va_arg(vl, 
char*);
 
  769                                 lua_pushstring(LuaState, name);
 
  770                                 lua_pushnil(LuaState);
 
  771                                 lua_rawset(LuaState, amt_ldx);
 
  775                         this->CloseHookVarTable();
 
  779                         LuaError(LuaState, 
"Could not get HookVariable library to remove hook variables - get a coder");
 
  787         bool got_global = 
false;
 
  791                 char fmt[3] = {
'|', 
format, 
'\0'};
 
  793                 lua_getglobal(LuaState, name);
 
  795                 if(!lua_isnil(LuaState, -1))
 
  802                 lua_pop(LuaState, 1);   
 
  813                 lua_pushnil(LuaState);
 
  814                 lua_setglobal(LuaState, name);
 
  820         for(
int i = 0; 
i < (
int)ScriptImages.size(); 
i++)
 
  822                 if(!
stricmp(name, ScriptImages[
i].fname))
 
  823                         return ScriptImages[
i].handle;
 
  832                 ScriptImages.push_back(
id);
 
  840         for(
int i = 0; 
i < (
int)ScriptImages.size(); 
i++)
 
  845         ScriptImages.clear();
 
  848 int script_state::RunBytecodeSub(
int in_lang, 
int in_idx, 
char format, 
void *
data)
 
  856                 if (in_idx == Script_hudhook.
h_index) {
 
  872                         int args_start = lua_gettop(LuaState);
 
  879                                 if(lua_pcall(
GetLuaSession(), 0, format!=
'\0' ? 1 : 0, err_ldx) != 0)
 
  883                                         for(; args_start > 0; args_start--) lua_pop(
GetLuaSession(), 1);
 
  892                                         char fmt[2] = {
format, 
'\0'};
 
  902                                 for(; args_start > 0; args_start--) lua_pop(
GetLuaSession(), 1);
 
  929                 if(chp->ConditionsValid(action, objp, more_data))
 
  931                         chp->Run(
this, action, format, data);
 
  943                 if(chp->ConditionsValid(action, objp))
 
  945                         if(chp->IsOverride(
this, action))
 
  957 void script_state::Clear()
 
  969         strncpy(StateName, name, 
sizeof(StateName)-1);
 
  986         if(LuaState != NULL) {
 
  993 void script_state::SetLuaSession(lua_State *L)
 
 1000         if(LuaState != NULL) {
 
 1003         else if(Langs & 
SC_LUA) {
 
 1010         FILE *
fp = fopen(filename,
"w");
 
 1021                 fputs(
"<body>", fp);
 
 1027                 fputs(
"<body>", fp);
 
 1033                 fputs(
"<body>", fp);
 
 1041         fputs(
"<dt><h2>Conditional Hooks</h2></dt>", fp);
 
 1042         fputs(
"<dd><dl>", fp);
 
 1045         fputs(
"<dt><b>Conditions</b></dt>", fp);
 
 1048                 fprintf(fp, 
"<dd>%s</dd>", Script_conditions[i].
name);
 
 1052         fputs(
"<dt><b>Actions</b></dt>", fp);
 
 1055                 fprintf(fp, 
"<dd>%s</dd>", Script_actions[i].
name);
 
 1058         fputs(
"</dl></dd><br />", fp);
 
 1061         fputs(
"<dt><h2>Scripting languages</h2></dt>", fp);
 
 1063                 fputs(
"<dd><a href=\"#Lua\">Lua</a></dd>", fp);
 
 1069         if(Langs & SC_LUA) {
 
 1070                 fputs(
"<dt><H2><a name=\"#Lua\">Lua</a></H2></dt>", fp);
 
 1076         fputs(
"</dl></body></html>", fp);
 
 1085         char lastchar = 
string[strlen(
string)-1];
 
 1087         if(
string[0] == 
'{')
 
 1092         if(
string[0] == 
'[' && lastchar != 
']')
 
 1097         size_t s_bufSize = strlen(
string) + 8;
 
 1098         char *
s = 
new char[ s_bufSize ];
 
 1099         if(
string[0] != 
'[')
 
 1114                 s[strlen(s)-1] = 
'\0';
 
 1118         int stack_start = lua_gettop(LuaState);
 
 1123         int rval = luaL_loadbuffer(LuaState, s, strlen(s), debug_str);
 
 1129                 if(lua_pcall(LuaState, 0, LUA_MULTRET, -2))
 
 1133                 int stack_curr = lua_gettop(LuaState);
 
 1140                 if(rtn != NULL && stack_curr > (stack_start+1))
 
 1150                 stack_curr = lua_gettop(LuaState) - stack_start;
 
 1151                 for(; stack_curr > 0; stack_curr--) lua_pop(LuaState, 1);
 
 1165 void script_state::ParseChunkSub(
int *out_lang, 
int *out_index, 
char* debug_str)
 
 1167         Assert(out_lang != NULL);
 
 1168         Assert(out_index != NULL);
 
 1169         Assert(debug_str != NULL);
 
 1190                         char *raw_lua = (
char*)
vm_malloc(len+1);
 
 1191                         raw_lua[
len] = 
'\0';
 
 1193                         cfread(raw_lua, len, 1, cfp);
 
 1198                         if(!luaL_loadbuffer(
GetLuaSession(), raw_lua, len, filename))
 
 1229                 strcat(raw_lua, 
"\n");
 
 1231                 char *tmp_ptr = raw_lua;
 
 1235                 if(!luaL_loadbuffer(
GetLuaSession(), tmp_ptr, strlen(tmp_ptr), debug_str))
 
 1268                 int len = strlen(buf);
 
 1289         static int total_parse_calls = 0;
 
 1290         char debug_buf[128];
 
 1292         total_parse_calls++;
 
 1295         if(debug_str == NULL)
 
 1297                 debug_str = debug_buf;
 
 1298                 sprintf(debug_str, 
"script_parse() count %d", total_parse_calls);
 
 1305                 size_t bufSize = strlen(debug_str) + 10;
 
 1306                 char *debug_str_over = (
char*)
vm_malloc(bufSize);
 
 1307                 strcpy_s(debug_str_over, bufSize, debug_str);
 
 1308                 strcat_s(debug_str_over, bufSize, 
" override");
 
 1321                         return Script_conditions[
i].
def;
 
 1333                         return &Script_actions[
i];
 
 1368                         chp = &ConditionalHooks[ConditionalHooks.size()-1];
 
 1383         bool actions_added = 
false;
 
 1390                 char *buf = (
char *)
vm_malloc(strlen(filename) + strlen(action->
name) + 4);
 
 1400                         actions_added = 
true;
 
 1405                 Warning(
LOCATION, 
"No actions specified for conditional hook in file '%s'", filename);
 
 1406                 ConditionalHooks.pop_back();
 
 1428         if (scripting_state_inited)
 
 1433         scripting_state_inited = 1;
 
 1438         if (!scripting_state_inited)
 
 1443         scripting_state_inited = 0;
 
 1449         if (!scripting_state_inited)
 
GLenum GLsizei GLenum format
 
bool IsOverride(class script_state *sys, int action)
 
bool AddAction(script_action *sa)
 
bool ParseCondition(const char *filename="<Unknown>")
 
bool AddCondition(script_condition *sc)
 
script_hook Script_hudhook
 
char name[CONDITION_LENGTH]
 
weapon Weapons[MAX_WEAPONS]
 
int primary_bank_weapons[MAX_SHIP_PRIMARY_BANKS]
 
#define MAX_SHIP_PRIMARY_BANKS
 
int previous_primary_bank
 
bool GetGlobal(char *name, char format='\0', void *data=NULL)
 
int check_for_string(const char *pstr)
 
#define CHA_ONACTIONSTOPPED
 
bool GetHookVar(char *name, char format='\0', void *data=NULL)
 
void fs2netd_add_table_validation(const char *tblname)
 
#define MAX_HOOK_CONDITIONS
 
weapon_info Weapon_info[MAX_WEAPON_TYPES]
 
void RemHookVar(char *name)
 
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
 
script_hook Script_simulationhook
 
char * Object_type_names[MAX_OBJECT_TYPES]
 
script_hook Script_gameinithook
 
int gameseq_get_state(void)
 
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
 
#define gr_set_clear_color
 
union script_condition::@261 data
 
void scripting_state_close()
 
#define CHA_AFTERBURNSTART
 
char Game_current_mission_filename[]
 
int current_secondary_bank
 
#define CHA_ONTURRETFIRED
 
char * textify_scancode(int code)
 
GLenum GLuint GLenum GLsizei const GLchar * buf
 
script_state & operator=(script_state &in)
 
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot. 
 
void ParseChunk(script_hook *dest, char *debug_str=NULL)
 
script_state Script_system("FS2_Open Scripting")
 
ship_subsys * last_fired_turret
 
int scripting_state_inited
 
config_item Control_config[]
Stores the keyboard configuration. 
 
void script_hook_init(script_hook *hook)
 
script_hook Script_splashhook
 
#define CHA_ONWPDESELECTED
 
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
 
#define MAX_SHIP_SECONDARY_BANKS
 
int previous_secondary_bank
 
void scripting_state_init()
 
ade_get_args(L,"|i",&depth)
 
#define CHA_COLLIDEDEBRIS
 
int ade_set_object_with_breed(lua_State *L, int obj_idx)
 
#define strnicmp(s1, s2, n)
 
void stuff_string(char *outstr, int type, int len, char *terminators)
 
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
 
#define CHA_GAMEPLAYSTART
 
void script_parse_table(const char *filename)
 
int required_string(const char *pstr)
 
#define SF_PRIMARY_LINKED
 
int secondary_bank_weapons[MAX_SHIP_SECONDARY_BANKS]
 
int ade_friendly_error(lua_State *L)
 
int optional_string(const char *pstr)
 
char Mission_filename[80]
 
#define CHA_HUDMSGRECEIVED
 
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
 
void SetHookObject(char *name, object *objp)
 
#define CHA_COLLIDEASTEROID
 
void scripting_state_do_frame(float frametime)
 
bool script_hook_valid(script_hook *hook)
 
int hud_disabled()
Checks if HUD disabled. 
 
#define CHA_COLLIDEWEAPON
 
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
 
int script_parse_condition()
 
void reset_parse(char *text)
 
GLuint const GLchar * name
 
int RunCondition(int condition, char format='\0', void *data=NULL, class object *objp=NULL, int more_data=0)
 
void SetHookObjects(int num,...)
 
int RunBytecode(script_hook &hd, char format='\0', void *data=NULL)
 
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later. 
 
GLboolean GLboolean GLboolean b
 
bool ConditionsValid(int action, class object *objp=NULL, int more_data=0)
 
flag_def_list Script_conditions[]
 
bool Run(class script_state *sys, int action, char format='\0', void *data=NULL)
 
flag_def_list Script_actions[]
 
lua_State * GetLuaSession()
 
int Num_script_conditions
 
void RemHookVars(unsigned int num,...)
 
char * text
describes the action in the config screen 
 
SCP_vector< ship_info > Ship_info
 
bool Output_scripting_meta
 
GLenum GLsizei GLenum GLenum const GLvoid * data
 
#define CHA_SECONDARYFIRE
 
script_hook Script_globalhook
 
void SetHookVar(char *name, char format, void *data=NULL)
 
bool EvalString(const char *string, const char *format=NULL, void *rtn=NULL, const char *debug_str=NULL)
 
int parse_modular_table(const char *name_check, void(*parse_callback)(const char *filename), int path_type, int sort_type)
 
char filename[MAX_FILENAME_LEN]
 
#define CHA_ONWEAPONDELETE
 
bool Ade_get_args_lfunction
 
#define CHA_MOUSERELEASED
 
void RemGlobal(char *name)
 
int cfclose(CFILE *cfile)
 
int OutputMeta(char *filename)
 
void _cdecl void LuaError(struct lua_State *L, SCP_FORMAT_STRING const char *format=NULL,...) SCP_FORMAT_STRING_ARGS(2
 
bool IsConditionOverride(int action, object *objp=NULL)
 
void gameseq_post_event(int event)
 
char * alloc_block(char *startstr, char *endstr, int extra_chars)
 
int cfilelength(CFILE *cfile)
 
return ade_set_args(L,"f",*val)
 
flag_def_list * script_parse_action()
 
SCP_vector< ship_type_info > Ship_types
 
int last_fired_weapon_info_index
 
bool IsOverride(script_hook &hd)