sm64coopdx/src/pc/lua/smlua_utils.h
PeachyPeach 32f395fb0c
Some checks failed
Build coop / build-linux (push) Has been cancelled
Build coop / build-steamos (push) Has been cancelled
Build coop / build-windows-opengl (push) Has been cancelled
Build coop / build-windows-directx (push) Has been cancelled
Build coop / build-macos-arm (push) Has been cancelled
Build coop / build-macos-intel (push) Has been cancelled
ModFs improvements (#907)
* zip + json properties; check existing file in create file

* smlua_audio_utils_replace_sequence

* audio_stream_load, audio_sample_load, smlua_model_util_get_id

* get_texture_info + can also load PNG files

* smlua_collision_util_get

* add wildcard in properties files + set text mode

* filepath restrictions

* Some mod_storage improvements

- Cache mod storage files into a map to reduce file I/O
- Fix a bug in mod_storage_save
- Add mod_storage_load_all that returns all keys/values as a table

* shutdown; fix buffer overflow; fix warnings; lua table

* reject binary files starting with MZ or ELF

* function members

* better doc

* adding file rewind

* ModFS guide; replace yaml by ini; read string buffer changes
2025-10-21 19:42:06 +02:00

77 lines
No EOL
3 KiB
C

#ifndef SMLUA_UTILS_H
#define SMLUA_UTILS_H
#include "smlua.h"
#include "src/pc/network/packets/packet.h"
extern u8 gSmLuaConvertSuccess;
typedef int LuaFunction;
typedef int LuaTable;
typedef struct ByteString {
const char *bytes;
size_t length;
} ByteString;
f32* smlua_get_vec3f_from_buffer(void);
s16* smlua_get_vec3s_from_buffer(void);
f32* smlua_get_vec4f_from_buffer(void);
s16* smlua_get_vec4s_from_buffer(void);
u8* smlua_get_color_from_buffer(void);
void smlua_bind_function(lua_State* L, const char* name, void* func);
bool smlua_is_table_empty(int index);
bool smlua_to_boolean(lua_State* L, int index);
lua_Integer smlua_to_integer(lua_State* L, int index);
lua_Number smlua_to_number(lua_State* L, int index);
const char* smlua_to_string(lua_State* L, int index);
ByteString smlua_to_bytestring(lua_State* L, int index);
LuaFunction smlua_to_lua_function(lua_State* L, int index);
LuaTable smlua_to_lua_table(lua_State* L, int index);
bool smlua_is_cobject(lua_State* L, int index, u16 lot);
void* smlua_to_cobject(lua_State* L, int index, u16 lot);
void* smlua_to_cpointer(lua_State* L, int index, u16 lvt);
struct LSTNetworkType smlua_to_lnt(lua_State* L, int index);
struct TextureInfo *smlua_to_texture_info(lua_State *L, int index);
bool packet_write_lnt(struct Packet* p, struct LSTNetworkType* lnt);
bool packet_read_lnt(struct Packet* p, struct LSTNetworkType* lnt);
CObject *smlua_push_object(lua_State* L, u16 lot, void* p, void *extraInfo);
CPointer *smlua_push_pointer(lua_State* L, u16 lvt, void* p, void *extraInfo);
void smlua_push_integer_field(int index, const char* name, lua_Integer val);
void smlua_push_number_field(int index, const char* name, lua_Number val);
void smlua_push_string_field(int index, const char* name, const char* val);
void smlua_push_nil_field(int index, const char* name);
void smlua_push_table_field(int index, const char* name);
void smlua_push_lua_table(lua_State* L, LuaTable table);
void smlua_push_bytestring(lua_State* L, ByteString bytestring);
void smlua_push_lnt(struct LSTNetworkType* lnt);
lua_Integer smlua_get_integer_field(int index, const char* name);
lua_Number smlua_get_number_field(int index, const char* name);
const char* smlua_get_string_field(int index, const char* name);
LuaFunction smlua_get_function_field(int index, const char *name);
const char* smlua_lnt_to_str(struct LSTNetworkType* lnt);
s64 smlua_get_integer_mod_variable(u16 modIndex, const char* variable);
s64 smlua_get_any_integer_mod_variable(const char* variable);
LuaFunction smlua_get_function_mod_variable(u16 modIndex, const char *variable);
LuaFunction smlua_get_any_function_mod_variable(const char *variable);
void smlua_logline(void);
void smlua_dump_stack(void);
void smlua_dump_globals(void);
void smlua_dump_table(int index);
void smlua_free(void *ptr, u16 lot);
#define smlua_free_lot(name, lot) \
static inline void smlua_free_##name(void *ptr) { smlua_free(ptr, lot); }
smlua_free_lot(surface, LOT_SURFACE);
smlua_free_lot(soc, LOT_STATICOBJECTCOLLISION);
#endif