Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Source/Core/Scripting/Python/Modules/utilmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Core/Core.h"
#include "Core/ConfigManager.h"
#include "Core/Host.h"
#include "Core/Movie.h"
#include "Core/System.h"
#include "Scripting/Python/PyScriptingBackend.h"
#include "Scripting/Python/Utils/module.h"
Expand Down Expand Up @@ -228,6 +229,12 @@ static PyObject* get_script_id(PyObject* module, PyObject* args)
return Py_BuildValue("i", (cur_instance->GetScriptId()));
}

static PyObject* get_frame_count(PyObject* module, PyObject* args)
{
auto& movie = Core::System::GetInstance().GetMovie();
return Py_BuildValue("i", (movie.GetCurrentFrame()));
}

static void setup_file_module(PyObject* module, FileState* state)
{
// I don't think we need anything here yet
Expand Down Expand Up @@ -258,6 +265,7 @@ PyMODINIT_FUNC PyInit_dol_utils()
{"activate_script", (PyCFunction) activate_script, METH_VARARGS | METH_KEYWORDS, ""},
{"get_script_name", get_script_name, METH_NOARGS, ""},
{"get_script_id", get_script_id, METH_NOARGS, ""},
{"get_frame_count", get_frame_count, METH_NOARGS, ""},
{nullptr, nullptr, 0, nullptr}};
static PyModuleDef module_def =
Py::MakeStatefulModuleDef<FileState, setup_file_module>("dolphin_utils", methods);
Expand Down
5 changes: 4 additions & 1 deletion python-stubs/dolphin_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,7 @@ def get_script_name() -> str:
"""Return the filepath of the current script"""

def get_script_id() -> int:
"""Return the id of the current script"""
"""Return the id of the current script"""

def get_frame_count() -> int:
"""Return the framecount since game boot"""
Loading