mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Added gActiveMods global to lua
This commit is contained in:
parent
48cff1c5da
commit
5cfef9abb3
8 changed files with 93 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ in_files = [
|
||||||
'src/game/spawn_sound.h',
|
'src/game/spawn_sound.h',
|
||||||
'src/pc/network/network.h',
|
'src/pc/network/network.h',
|
||||||
'src/game/hardcoded.h',
|
'src/game/hardcoded.h',
|
||||||
|
'src/pc/mods/mod.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
out_filename_c = 'src/pc/lua/smlua_cobject_autogen.c'
|
out_filename_c = 'src/pc/lua/smlua_cobject_autogen.c'
|
||||||
|
|
@ -70,6 +71,10 @@ override_field_mutable = {
|
||||||
"NetworkPlayer": [ "overrideModelIndex", "overridePaletteIndex" ],
|
"NetworkPlayer": [ "overrideModelIndex", "overridePaletteIndex" ],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override_field_invisible = {
|
||||||
|
"Mod": [ "files" ]
|
||||||
|
}
|
||||||
|
|
||||||
override_field_immutable = {
|
override_field_immutable = {
|
||||||
"MarioState": [ "playerIndex" ],
|
"MarioState": [ "playerIndex" ],
|
||||||
"Character": [ "*" ],
|
"Character": [ "*" ],
|
||||||
|
|
@ -80,10 +85,13 @@ override_field_immutable = {
|
||||||
"SpawnParticlesInfo": [ "model" ],
|
"SpawnParticlesInfo": [ "model" ],
|
||||||
"MarioBodyState": [ "updateTorsoTime" ],
|
"MarioBodyState": [ "updateTorsoTime" ],
|
||||||
"Area": [ "localAreaTimer" ],
|
"Area": [ "localAreaTimer" ],
|
||||||
|
"Mod": [ "*" ],
|
||||||
|
"ModFile": [ "*" ],
|
||||||
}
|
}
|
||||||
|
|
||||||
override_allowed_structs = {
|
override_allowed_structs = {
|
||||||
"src/pc/network/network.h": [ 'ServerSettings' ]
|
"src/pc/network/network.h": [ 'ServerSettings' ],
|
||||||
|
"src/pc/mods/mod.h": [ 'Mod' ],
|
||||||
}
|
}
|
||||||
|
|
||||||
sLuaManuallyDefinedStructs = [{
|
sLuaManuallyDefinedStructs = [{
|
||||||
|
|
@ -248,6 +256,10 @@ def build_struct(struct):
|
||||||
for field in struct['fields']:
|
for field in struct['fields']:
|
||||||
fid, ftype, fimmutable, lvt, lot = get_struct_field_info(struct, field)
|
fid, ftype, fimmutable, lvt, lot = get_struct_field_info(struct, field)
|
||||||
|
|
||||||
|
if sid in override_field_invisible:
|
||||||
|
if fid in override_field_invisible[sid]:
|
||||||
|
continue
|
||||||
|
|
||||||
row = []
|
row = []
|
||||||
row.append(' { ' )
|
row.append(' { ' )
|
||||||
row.append('"%s", ' % fid )
|
row.append('"%s", ' % fid )
|
||||||
|
|
@ -341,6 +353,11 @@ def doc_struct_index(structs):
|
||||||
def doc_struct_field(struct, field):
|
def doc_struct_field(struct, field):
|
||||||
fid, ftype, fimmutable, lvt, lot = get_struct_field_info(struct, field)
|
fid, ftype, fimmutable, lvt, lot = get_struct_field_info(struct, field)
|
||||||
|
|
||||||
|
sid = struct['identifier']
|
||||||
|
if sid in override_field_invisible:
|
||||||
|
if fid in override_field_invisible[sid]:
|
||||||
|
return ''
|
||||||
|
|
||||||
if '???' in lvt or '???' in lot:
|
if '???' in lvt or '???' in lot:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
@ -425,6 +442,10 @@ def def_struct(struct):
|
||||||
for field in struct['fields']:
|
for field in struct['fields']:
|
||||||
fid, ftype, fimmutable, lvt, lot = get_struct_field_info(struct, field)
|
fid, ftype, fimmutable, lvt, lot = get_struct_field_info(struct, field)
|
||||||
|
|
||||||
|
if sid in override_field_invisible:
|
||||||
|
if fid in override_field_invisible[sid]:
|
||||||
|
continue
|
||||||
|
|
||||||
if '???' in lvt or '???' in lot:
|
if '???' in lvt or '???' in lot:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ gMarioStates = {}
|
||||||
--- @type NetworkPlayer[]
|
--- @type NetworkPlayer[]
|
||||||
gNetworkPlayers = {}
|
gNetworkPlayers = {}
|
||||||
|
|
||||||
|
--- @type Mod[]
|
||||||
|
gActiveMods = {}
|
||||||
|
|
||||||
--- @type Character[]
|
--- @type Character[]
|
||||||
gCharacter = {}
|
gCharacter = {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -680,6 +680,18 @@
|
||||||
--- @field public wasNetworkVisible integer
|
--- @field public wasNetworkVisible integer
|
||||||
--- @field public waterLevel integer
|
--- @field public waterLevel integer
|
||||||
|
|
||||||
|
--- @class Mod
|
||||||
|
--- @field public basePath string
|
||||||
|
--- @field public description string
|
||||||
|
--- @field public enabled boolean
|
||||||
|
--- @field public fileCount integer
|
||||||
|
--- @field public incompatible string
|
||||||
|
--- @field public index integer
|
||||||
|
--- @field public isDirectory boolean
|
||||||
|
--- @field public name string
|
||||||
|
--- @field public relativePath string
|
||||||
|
--- @field public selectable boolean
|
||||||
|
|
||||||
--- @class ModeTransitionInfo
|
--- @class ModeTransitionInfo
|
||||||
--- @field public frame integer
|
--- @field public frame integer
|
||||||
--- @field public lastMode integer
|
--- @field public lastMode integer
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,13 @@ It is indexed by the local `playerIndex`, so `gNetworkPlayers[0]` is always the
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [gActiveMods](#gNetworkPlayers)
|
||||||
|
The `gActiveMods[]` table is an array that starts at `0`, and contains a [Mod](structs.md#Mod) struct for each active mod.
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [gCharacter](#gCharacter)
|
## [gCharacter](#gCharacter)
|
||||||
The `gCharacter[]` table is an array from `0` to `(CT_MAX - 1)` that contains a [Character](structs.md#Character) struct for each possible character.
|
The `gCharacter[]` table is an array from `0` to `(CT_MAX - 1)` that contains a [Character](structs.md#Character) struct for each possible character.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
- [MarioAnimation](#MarioAnimation)
|
- [MarioAnimation](#MarioAnimation)
|
||||||
- [MarioBodyState](#MarioBodyState)
|
- [MarioBodyState](#MarioBodyState)
|
||||||
- [MarioState](#MarioState)
|
- [MarioState](#MarioState)
|
||||||
|
- [Mod](#Mod)
|
||||||
- [ModeTransitionInfo](#ModeTransitionInfo)
|
- [ModeTransitionInfo](#ModeTransitionInfo)
|
||||||
- [NetworkPlayer](#NetworkPlayer)
|
- [NetworkPlayer](#NetworkPlayer)
|
||||||
- [Object](#Object)
|
- [Object](#Object)
|
||||||
|
|
@ -974,6 +975,25 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [Mod](#Mod)
|
||||||
|
|
||||||
|
| Field | Type | Access |
|
||||||
|
| ----- | ---- | ------ |
|
||||||
|
| basePath | `string` | read-only |
|
||||||
|
| description | `string` | read-only |
|
||||||
|
| enabled | `boolean` | read-only |
|
||||||
|
| fileCount | `integer` | read-only |
|
||||||
|
| incompatible | `string` | read-only |
|
||||||
|
| index | `integer` | read-only |
|
||||||
|
| isDirectory | `boolean` | read-only |
|
||||||
|
| name | `string` | read-only |
|
||||||
|
| relativePath | `string` | read-only |
|
||||||
|
| selectable | `boolean` | read-only |
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [ModeTransitionInfo](#ModeTransitionInfo)
|
## [ModeTransitionInfo](#ModeTransitionInfo)
|
||||||
|
|
||||||
| Field | Type | Access |
|
| Field | Type | Access |
|
||||||
|
|
|
||||||
|
|
@ -533,6 +533,17 @@ void smlua_cobject_init_globals(void) {
|
||||||
lua_setglobal(L, "gNetworkPlayers");
|
lua_setglobal(L, "gNetworkPlayers");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
lua_newtable(L);
|
||||||
|
int t = lua_gettop(gLuaState);
|
||||||
|
for (s32 i = 0; i < gActiveMods.entryCount; i++) {
|
||||||
|
lua_pushinteger(L, i);
|
||||||
|
smlua_push_object(L, LOT_MOD, gActiveMods.entries[i]);
|
||||||
|
lua_settable(L, t);
|
||||||
|
}
|
||||||
|
lua_setglobal(L, "gActiveMods");
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
int t = lua_gettop(gLuaState);
|
int t = lua_gettop(gLuaState);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
#include "src/game/spawn_sound.h"
|
#include "src/game/spawn_sound.h"
|
||||||
#include "src/pc/network/network.h"
|
#include "src/pc/network/network.h"
|
||||||
#include "src/game/hardcoded.h"
|
#include "src/game/hardcoded.h"
|
||||||
|
#include "src/pc/mods/mod.h"
|
||||||
|
|
||||||
#include "include/object_fields.h"
|
#include "include/object_fields.h"
|
||||||
|
|
||||||
|
|
@ -790,6 +791,21 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
|
||||||
{ "waterLevel", LVT_S16, offsetof(struct MarioState, waterLevel), false, LOT_NONE },
|
{ "waterLevel", LVT_S16, offsetof(struct MarioState, waterLevel), false, LOT_NONE },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define LUA_MOD_FIELD_COUNT 10
|
||||||
|
static struct LuaObjectField sModFields[LUA_MOD_FIELD_COUNT] = {
|
||||||
|
{ "basePath", LVT_STRING, offsetof(struct Mod, basePath), true, LOT_NONE },
|
||||||
|
{ "description", LVT_STRING_P, offsetof(struct Mod, description), true, LOT_NONE },
|
||||||
|
{ "enabled", LVT_BOOL, offsetof(struct Mod, enabled), true, LOT_NONE },
|
||||||
|
{ "fileCount", LVT_U16, offsetof(struct Mod, fileCount), true, LOT_NONE },
|
||||||
|
{ "incompatible", LVT_STRING_P, offsetof(struct Mod, incompatible), true, LOT_NONE },
|
||||||
|
{ "index", LVT_S32, offsetof(struct Mod, index), true, LOT_NONE },
|
||||||
|
{ "isDirectory", LVT_BOOL, offsetof(struct Mod, isDirectory), true, LOT_NONE },
|
||||||
|
{ "name", LVT_STRING_P, offsetof(struct Mod, name), true, LOT_NONE },
|
||||||
|
{ "relativePath", LVT_STRING, offsetof(struct Mod, relativePath), true, LOT_NONE },
|
||||||
|
{ "selectable", LVT_BOOL, offsetof(struct Mod, selectable), true, LOT_NONE },
|
||||||
|
// { "size", LVT_???, offsetof(struct Mod, size), true, LOT_??? }, <--- UNIMPLEMENTED
|
||||||
|
};
|
||||||
|
|
||||||
#define LUA_MODE_TRANSITION_INFO_FIELD_COUNT 6
|
#define LUA_MODE_TRANSITION_INFO_FIELD_COUNT 6
|
||||||
static struct LuaObjectField sModeTransitionInfoFields[LUA_MODE_TRANSITION_INFO_FIELD_COUNT] = {
|
static struct LuaObjectField sModeTransitionInfoFields[LUA_MODE_TRANSITION_INFO_FIELD_COUNT] = {
|
||||||
{ "frame", LVT_S16, offsetof(struct ModeTransitionInfo, frame), false, LOT_NONE },
|
{ "frame", LVT_S16, offsetof(struct ModeTransitionInfo, frame), false, LOT_NONE },
|
||||||
|
|
@ -1908,6 +1924,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
|
||||||
{ LOT_MARIOANIMATION, sMarioAnimationFields, LUA_MARIO_ANIMATION_FIELD_COUNT },
|
{ LOT_MARIOANIMATION, sMarioAnimationFields, LUA_MARIO_ANIMATION_FIELD_COUNT },
|
||||||
{ LOT_MARIOBODYSTATE, sMarioBodyStateFields, LUA_MARIO_BODY_STATE_FIELD_COUNT },
|
{ LOT_MARIOBODYSTATE, sMarioBodyStateFields, LUA_MARIO_BODY_STATE_FIELD_COUNT },
|
||||||
{ LOT_MARIOSTATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT },
|
{ LOT_MARIOSTATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT },
|
||||||
|
{ LOT_MOD, sModFields, LUA_MOD_FIELD_COUNT },
|
||||||
{ LOT_MODETRANSITIONINFO, sModeTransitionInfoFields, LUA_MODE_TRANSITION_INFO_FIELD_COUNT },
|
{ LOT_MODETRANSITIONINFO, sModeTransitionInfoFields, LUA_MODE_TRANSITION_INFO_FIELD_COUNT },
|
||||||
{ LOT_NETWORKPLAYER, sNetworkPlayerFields, LUA_NETWORK_PLAYER_FIELD_COUNT },
|
{ LOT_NETWORKPLAYER, sNetworkPlayerFields, LUA_NETWORK_PLAYER_FIELD_COUNT },
|
||||||
{ LOT_OBJECT, sObjectFields, LUA_OBJECT_FIELD_COUNT },
|
{ LOT_OBJECT, sObjectFields, LUA_OBJECT_FIELD_COUNT },
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ enum LuaObjectAutogenType {
|
||||||
LOT_MARIOANIMATION,
|
LOT_MARIOANIMATION,
|
||||||
LOT_MARIOBODYSTATE,
|
LOT_MARIOBODYSTATE,
|
||||||
LOT_MARIOSTATE,
|
LOT_MARIOSTATE,
|
||||||
|
LOT_MOD,
|
||||||
LOT_MODETRANSITIONINFO,
|
LOT_MODETRANSITIONINFO,
|
||||||
LOT_NETWORKPLAYER,
|
LOT_NETWORKPLAYER,
|
||||||
LOT_OBJECT,
|
LOT_OBJECT,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue