/**
 * 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);
}