Add struct metafield
Some checks failed
Build Dusk / run-tests (push) Failing after 1m55s
Build Dusk / build-linux (push) Successful in 1m58s
Build Dusk / build-psp (push) Failing after 1m26s

This commit is contained in:
2026-01-27 21:16:53 -06:00
parent 6e78ee188d
commit cc85983736
10 changed files with 314 additions and 19 deletions

View File

@@ -8,6 +8,7 @@
#pragma once
#include "script/scriptcontext.h"
#include "input/input.h"
#include "script/scriptstruct.h"
int moduleInputBind(lua_State *L) {
assertNotNull(L, "Lua state cannot be NULL");
@@ -44,6 +45,19 @@ int moduleInputBind(lua_State *L) {
return 0;
}
void moduleInputEventGetter(
const scriptcontext_t *context,
const char_t *key,
const void *structPtr,
scriptvalue_t *outValue
) {
if(stringCompare(key, "action") == 0) {
outValue->type = SCRIPT_VALUE_TYPE_INT;
outValue->value.intValue = ((const inputevent_t*)structPtr)->action;
return;
}
}
void moduleInput(scriptcontext_t *context) {
assertNotNull(context, "Script context cannot be NULL");
@@ -63,6 +77,18 @@ void moduleInput(scriptcontext_t *context) {
#endif
);
// Script structure
scriptStructRegister(
context,
"input_mt",
&moduleInputEventGetter,
NULL
);
// Events
scriptContextRegPointer(context,"INPUT_EVENT_PRESSED",&INPUT.eventPressed);
scriptContextRegPointer(context,"INPUT_EVENT_RELEASED",&INPUT.eventReleased);
// Bind methods
scriptContextRegFunc(context, "inputBind", moduleInputBind);
}