mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-27 04:21:42 +00:00
Create Lua function log_to_stdout()
This commit is contained in:
parent
11b54313c5
commit
3f3addf730
4 changed files with 87 additions and 0 deletions
|
|
@ -223,6 +223,7 @@ manual_index_documentation = """
|
|||
- [smlua_anim_util_register_animation](#smlua_anim_util_register_animation)
|
||||
- [level_script_parse](#level_script_parse)
|
||||
- [log_to_console](#log_to_console)
|
||||
- [log_to_stdout](#log_to_stdout)
|
||||
- [add_scroll_target](#add_scroll_target)
|
||||
- [collision_find_surface_on_ray](#collision_find_surface_on_ray)
|
||||
- [cast_graph_node](#cast_graph_node)
|
||||
|
|
@ -494,6 +495,29 @@ Logs a message to the in-game console.
|
|||
|
||||
<br />
|
||||
|
||||
## [log_to_stdout](#log_to_stdout)
|
||||
|
||||
Logs a message to standard output.
|
||||
|
||||
### Lua Example
|
||||
`log_to_stdout("sm64coopdx FTW", CONSOLE_MESSAGE_INFO)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| message | `string` |
|
||||
| level (optional) | `ConsoleMessageLevel` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void log_to_stdout(const char* message, enum ConsoleMessageLevel level);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [add_scroll_target](#add_scroll_target)
|
||||
|
||||
Registers a vertex buffer to be used for a scrolling texture. Should be used with `RM_Scroll_Texture` or `editor_Scroll_Texture`
|
||||
|
|
|
|||
|
|
@ -405,6 +405,13 @@ function log_to_console(message, level)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param message string The message to log
|
||||
--- @param level? ConsoleMessageLevel Optional; Determines whether the message should appear as info, a warning or an error.
|
||||
--- Logs a message to standard output
|
||||
function log_to_stdout(message, level)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer The index of the scroll target, should match up with the behavior param of `RM_Scroll_Texture` or `editor_Scroll_Texture`
|
||||
--- @param name string The name of the vertex buffer that should be used while scrolling the texture
|
||||
--- Registers a vertex buffer to be used for a scrolling texture. Should be used with `RM_Scroll_Texture` or `editor_Scroll_Texture`
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
- [smlua_anim_util_register_animation](#smlua_anim_util_register_animation)
|
||||
- [level_script_parse](#level_script_parse)
|
||||
- [log_to_console](#log_to_console)
|
||||
- [log_to_stdout](#log_to_stdout)
|
||||
- [add_scroll_target](#add_scroll_target)
|
||||
- [collision_find_surface_on_ray](#collision_find_surface_on_ray)
|
||||
- [cast_graph_node](#cast_graph_node)
|
||||
|
|
@ -2455,6 +2456,29 @@ Logs a message to the in-game console.
|
|||
|
||||
<br />
|
||||
|
||||
## [log_to_stdout](#log_to_stdout)
|
||||
|
||||
Logs a message to standard output.
|
||||
|
||||
### Lua Example
|
||||
`log_to_stdout("sm64coopdx FTW", CONSOLE_MESSAGE_INFO)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| message | `string` |
|
||||
| level (optional) | `ConsoleMessageLevel` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void log_to_stdout(const char* message, enum ConsoleMessageLevel level);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [add_scroll_target](#add_scroll_target)
|
||||
|
||||
Registers a vertex buffer to be used for a scrolling texture. Should be used with `RM_Scroll_Texture` or `editor_Scroll_Texture`
|
||||
|
|
|
|||
|
|
@ -796,6 +796,37 @@ int smlua_func_log_to_console(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_log_to_stdout(lua_State* L) {
|
||||
if (!smlua_functions_valid_param_range(L, 1, 2)) { return 0; }
|
||||
|
||||
int paramCount = lua_gettop(L);
|
||||
|
||||
const char* message = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("log_to_stdout: Failed to convert parameter 1 for function"); return 0; }
|
||||
|
||||
enum ConsoleMessageLevel level = CONSOLE_MESSAGE_INFO;
|
||||
if (paramCount >= 2) {
|
||||
level = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("log_to_stdout: Failed to convert parameter 2 for function"); return 0; }
|
||||
}
|
||||
|
||||
const char* origin = gLuaActiveModFile->relativePath;
|
||||
|
||||
switch (level) {
|
||||
case CONSOLE_MESSAGE_INFO:
|
||||
LOG_INFO("%s: %s", origin, message);
|
||||
break;
|
||||
case CONSOLE_MESSAGE_WARNING:
|
||||
LOG_WARNING("%s: %s", origin, message);
|
||||
break;
|
||||
case CONSOLE_MESSAGE_ERROR:
|
||||
LOG_ERROR("%s: %s", origin, message);
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// scroll targets //
|
||||
////////////////////
|
||||
|
|
@ -1042,6 +1073,7 @@ void smlua_bind_functions(void) {
|
|||
smlua_bind_function(L, "level_script_parse", smlua_func_level_script_parse);
|
||||
smlua_bind_function(L, "smlua_anim_util_register_animation", smlua_func_smlua_anim_util_register_animation);
|
||||
smlua_bind_function(L, "log_to_console", smlua_func_log_to_console);
|
||||
smlua_bind_function(L, "log_to_stdout", smlua_func_log_to_stdout);
|
||||
smlua_bind_function(L, "add_scroll_target", smlua_func_add_scroll_target);
|
||||
smlua_bind_function(L, "collision_find_surface_on_ray", smlua_func_collision_find_surface_on_ray);
|
||||
smlua_bind_function(L, "cast_graph_node", smlua_func_cast_graph_node);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue