Skip to content

Commit d777354

Browse files
author
Roberto De Ioris
committed
added get_world_type()
1 parent bc1f0c8 commit d777354

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ static PyMethodDef ue_PyUObject_methods[] = {
634634
{ "quit_game", (PyCFunction)py_ue_quit_game, METH_VARARGS, "" },
635635
{ "play", (PyCFunction)py_ue_play, METH_VARARGS, "" },
636636

637+
{ "get_world_type", (PyCFunction)py_ue_get_world_type, METH_VARARGS, "" },
638+
637639
{ "world_exec", (PyCFunction)py_ue_world_exec, METH_VARARGS, "" },
638640

639641
{ "simple_move_to_location", (PyCFunction)py_ue_simple_move_to_location, METH_VARARGS, "" },

Source/UnrealEnginePython/Private/UObject/UEPyWorld.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ PyObject *py_ue_quit_game(ue_PyUObject *self, PyObject * args)
4242
Py_RETURN_NONE;
4343
}
4444

45+
PyObject *py_ue_get_world_type(ue_PyUObject *self, PyObject * args)
46+
{
47+
48+
ue_py_check(self);
49+
50+
UWorld *world = ue_get_uworld(self);
51+
if (!world)
52+
return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");
53+
54+
return PyLong_FromUnsignedLong(world->WorldType);
55+
}
56+
4557
PyObject *py_ue_play(ue_PyUObject *self, PyObject * args)
4658
{
4759

Source/UnrealEnginePython/Private/UObject/UEPyWorld.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ PyObject *py_ue_get_levels(ue_PyUObject *, PyObject *);
2626
PyObject *py_ue_get_game_viewport(ue_PyUObject *, PyObject *);
2727

2828
PyObject *py_ue_get_current_level(ue_PyUObject *, PyObject *);
29-
PyObject *py_ue_set_current_level(ue_PyUObject *, PyObject *);
29+
PyObject *py_ue_set_current_level(ue_PyUObject *, PyObject *);
30+
31+
PyObject *py_ue_get_world_type(ue_PyUObject *, PyObject *);

0 commit comments

Comments
 (0)