37 lines
923 B
C
37 lines
923 B
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "moduletime.h"
|
|
#include "assert/assert.h"
|
|
#include "script/struct/scriptstruct.h"
|
|
|
|
void moduleTime(scriptcontext_t *ctx) {
|
|
assertNotNull(ctx, "Script context cannot be NULL");
|
|
|
|
// Script structure
|
|
scriptStructRegister(ctx, "time_mt", moduleTimeGetter, NULL);
|
|
|
|
// Register struct
|
|
scriptStructPush(ctx, "time_mt", "TIME", &TIME);
|
|
}
|
|
|
|
void moduleTimeGetter(
|
|
const scriptcontext_t *context,
|
|
const char_t *key,
|
|
const void *structPtr,
|
|
scriptvalue_t *outValue
|
|
) {
|
|
if(stringCompare(key, "delta") == 0) {
|
|
outValue->type = SCRIPT_VALUE_TYPE_FLOAT;
|
|
outValue->value.floatValue = TIME.delta;
|
|
return;
|
|
} else if(stringCompare(key, "time") == 0) {
|
|
outValue->type = SCRIPT_VALUE_TYPE_FLOAT;
|
|
outValue->value.floatValue = TIME.time;
|
|
return;
|
|
}
|
|
} |