Added epoch to scripts.

This commit is contained in:
2021-09-25 18:59:12 -07:00
parent af58678de8
commit e8c15e1edd
5 changed files with 68 additions and 3 deletions

32
src/script/api/epoch.c Normal file
View File

@ -0,0 +1,32 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "epoch.h"
scripterreturn_t _scripterEpochGetDelta(scriptercontext_t *ctx) {
scripter_t *scripter = scripterFromContext(ctx);
duk_push_number(ctx, scripter->engine->time.delta);
return 1;
}
scripterreturn_t _scripterEpochGetCurrent(scriptercontext_t *ctx) {
scripter_t *scripter = scripterFromContext(ctx);
duk_push_number(ctx, scripter->engine->time.current);
return 1;
}
scripterreturn_t _scripterEpochGetLast(scriptercontext_t *ctx) {
scripter_t *scripter = scripterFromContext(ctx);
duk_push_number(ctx, scripter->engine->time.last);
return 1;
}
void scriptsApiEpoch(scripter_t *scripter) {
scripterDefineMethod(scripter, "epochGetDelta", 0, &_scripterEpochGetDelta);
scripterDefineMethod(scripter, "epochGetCurrent",0,&_scripterEpochGetCurrent);
scripterDefineMethod(scripter, "epochGetLast", 0, &_scripterEpochGetLast);
}

10
src/script/api/epoch.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
// Copyright (c) 2021 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
declare function epochGetDelta():number;
declare function epochGetCurrent():number;
declare function epochGetLast():number;

13
src/script/api/epoch.h Normal file
View File

@ -0,0 +1,13 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../../libs.h"
#include "../scripter.h"
#include "../../engine/engine.h"
void scriptsApiEpoch(scripter_t *scripter);