3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 /******************************************************************************/
21 /******************************************************************************/
22 /* WARNING!!!! do NOT add this header in any include file or any code file */
23 /* not being a modapi file!!!!!!!! */
24 /******************************************************************************/
25 /******************************************************************************/
35 #include "common/c_types.h"
37 // What script_run_callbacks does with the return values of callbacks.
38 // Regardless of the mode, if only one callback is defined,
39 // its return value is the total return value.
40 // Modes only affect the case where 0 or >= 2 callbacks are defined.
43 // Returns the return value of the first callback
44 // Returns nil if list of callbacks is empty
45 RUN_CALLBACKS_MODE_FIRST,
46 // Returns the return value of the last callback
47 // Returns nil if list of callbacks is empty
48 RUN_CALLBACKS_MODE_LAST,
49 // If any callback returns a false value, the first such is returned
50 // Otherwise, the first callback's return value (trueish) is returned
51 // Returns true if list of callbacks is empty
52 RUN_CALLBACKS_MODE_AND,
53 // Like above, but stops calling callbacks (short circuit)
54 // after seeing the first false value
55 RUN_CALLBACKS_MODE_AND_SC,
56 // If any callback returns a true value, the first such is returned
57 // Otherwise, the first callback's return value (falseish) is returned
58 // Returns false if list of callbacks is empty
59 RUN_CALLBACKS_MODE_OR,
60 // Like above, but stops calling callbacks (short circuit)
61 // after seeing the first true value
62 RUN_CALLBACKS_MODE_OR_SC,
63 // Note: "a true value" and "a false value" refer to values that
64 // are converted by lua_toboolean to true or false, respectively.
67 std::string script_get_backtrace (lua_State *L);
68 void script_error (lua_State *L, const char *fmt, ...);
69 void script_run_callbacks (lua_State *L, int nargs,
70 RunCallbacksMode mode);
72 #endif /* C_INTERNAL_H_ */