commit
d0318c23d5
|
@ -116,7 +116,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
|
|||
| HOOK_ON_CHAT_MESSAGE | Called when a chat message gets sent. Return `false` to prevent the message from being sent. | [MarioState](structs.md#MarioState) messageSender |
|
||||
| HOOK_OBJECT_SET_MODEL | Called when a behavior changes models. Also runs when a behavior spawns. | [Object](structs.md#Object) obj, `integer` modelID |
|
||||
| HOOK_CHARACTER_SOUND | Called when mario retrieves a character sound to play, return a character sound or `0` to override it. | [MarioState](structs.md#MarioState) mario, [enum CharacterSound](constants.md#enum-CharacterSound) characterSound |
|
||||
| HOOK_BEFORE_SET_MARIO_ACTION | Called before Mario's action changes. Return an action to change the incoming action or `1` to cancel the action change. | `integer` incomingAction |
|
||||
| HOOK_BEFORE_SET_MARIO_ACTION | Called before Mario's action changes. Return an action to change the incoming action or `1` to cancel the action change. | [MarioState](structs.md#MarioState) mario, `integer` incomingAction |
|
||||
|
||||
### Parameters
|
||||
|
||||
|
|
|
@ -458,7 +458,7 @@ static s32 get_character_sound(struct MarioState* m, enum CharacterSound charact
|
|||
if (m == NULL || m->marioObj == NULL) { return 0; }
|
||||
|
||||
s32 override = 0;
|
||||
if (smlua_call_event_hooks_mario_charactersound_param_ret_int(HOOK_CHARACTER_SOUND, m, characterSound, &override)) {
|
||||
if (smlua_call_event_hooks_mario_character_sound_param_ret_int(HOOK_CHARACTER_SOUND, m, characterSound, &override)) {
|
||||
return override;
|
||||
}
|
||||
|
||||
|
|
|
@ -1094,7 +1094,7 @@ static u32 set_mario_action_cutscene(struct MarioState *m, u32 action, UNUSED u3
|
|||
*/
|
||||
u32 set_mario_action(struct MarioState *m, u32 action, u32 actionArg) {
|
||||
u32 returnValue = 0;
|
||||
smlua_call_event_hooks_int_param_ret_int(HOOK_BEFORE_SET_MARIO_ACTION, action, &returnValue);
|
||||
smlua_call_event_hooks_mario_action_params_ret_int(HOOK_BEFORE_SET_MARIO_ACTION, m, action, &returnValue);
|
||||
if (returnValue == 1) { return TRUE; } else if (returnValue) { action = returnValue; }
|
||||
|
||||
switch (action & ACT_GROUP_MASK) {
|
||||
|
|
|
@ -639,7 +639,7 @@ void smlua_call_event_hooks_on_chat_message(enum LuaHookedEventType hookType, st
|
|||
}
|
||||
}
|
||||
|
||||
bool smlua_call_event_hooks_mario_charactersound_param_ret_int(enum LuaHookedEventType hookType, struct MarioState* m, enum CharacterSound characterSound, s32* returnValue) {
|
||||
bool smlua_call_event_hooks_mario_character_sound_param_ret_int(enum LuaHookedEventType hookType, struct MarioState* m, enum CharacterSound characterSound, s32* returnValue) {
|
||||
lua_State* L = gLuaState;
|
||||
if (L == NULL) { return false; }
|
||||
struct LuaHookedEvent* hook = &sHookedEvents[hookType];
|
||||
|
@ -676,7 +676,7 @@ bool smlua_call_event_hooks_mario_charactersound_param_ret_int(enum LuaHookedEve
|
|||
return false;
|
||||
}
|
||||
|
||||
void smlua_call_event_hooks_int_param_ret_int(enum LuaHookedEventType hookType, u32 param, u32* returnValue) {
|
||||
void smlua_call_event_hooks_mario_action_params_ret_int(enum LuaHookedEventType hookType, struct MarioState *m, u32 action, u32* returnValue) {
|
||||
lua_State* L = gLuaState;
|
||||
if (L == NULL) { return; }
|
||||
struct LuaHookedEvent* hook = &sHookedEvents[hookType];
|
||||
|
@ -686,11 +686,17 @@ void smlua_call_event_hooks_int_param_ret_int(enum LuaHookedEventType hookType,
|
|||
// push the callback onto the stack
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]);
|
||||
|
||||
// push params
|
||||
lua_pushinteger(L, param);
|
||||
// push mario state
|
||||
lua_getglobal(L, "gMarioStates");
|
||||
lua_pushinteger(L, m->playerIndex);
|
||||
lua_gettable(L, -2);
|
||||
lua_remove(L, -2);
|
||||
|
||||
// push action
|
||||
lua_pushinteger(L, action);
|
||||
|
||||
// call the callback
|
||||
if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i])) {
|
||||
if (0 != smlua_call_hook(L, 2, 1, 0, hook->mod[i])) {
|
||||
LOG_LUA("Failed to call the callback: %u", hookType);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -114,8 +114,8 @@ void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int mo
|
|||
void smlua_call_event_hooks_use_act_select(enum LuaHookedEventType hookType, int value, bool* foundHook, bool* returnValue);
|
||||
void smlua_call_event_hooks_ret_bool(enum LuaHookedEventType hookType, bool* returnValue);
|
||||
void smlua_call_event_hooks_on_chat_message(enum LuaHookedEventType hookType, struct MarioState* m, const char* message, bool* returnValue);
|
||||
bool smlua_call_event_hooks_mario_charactersound_param_ret_int(enum LuaHookedEventType hookType, struct MarioState* m, enum CharacterSound characterSound, s32* returnValue);
|
||||
void smlua_call_event_hooks_int_param_ret_int(enum LuaHookedEventType hookType, u32 param, u32* returnValue);
|
||||
bool smlua_call_event_hooks_mario_character_sound_param_ret_int(enum LuaHookedEventType hookType, struct MarioState* m, enum CharacterSound characterSound, s32* returnValue);
|
||||
void smlua_call_event_hooks_mario_action_params_ret_int(enum LuaHookedEventType hookType, struct MarioState *m, u32 action, u32* returnValue);
|
||||
|
||||
enum BehaviorId smlua_get_original_behavior_id(const BehaviorScript* behavior);
|
||||
const BehaviorScript* smlua_override_behavior(const BehaviorScript* behavior);
|
||||
|
|
Loading…
Reference in New Issue