Skip to content

Commit 0ac7a03

Browse files
author
Roberto De Ioris
committed
added restart_level()
1 parent 4b9fc61 commit 0ac7a03

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
752752
{ "set_player_hud", (PyCFunction)py_ue_set_player_hud, METH_VARARGS, "" },
753753
{ "get_player_camera_manager", (PyCFunction)py_ue_get_player_camera_manager, METH_VARARGS, "" },
754754
{ "get_player_pawn", (PyCFunction)py_ue_get_player_pawn, METH_VARARGS, "" },
755+
{ "restart_level", (PyCFunction)py_ue_restart_level, METH_VARARGS, "" },
755756

756757
{ "get_overlapping_actors", (PyCFunction)py_ue_get_overlapping_actors, METH_VARARGS, "" },
757758
{ "actor_set_level_sequence", (PyCFunction)py_ue_actor_set_level_sequence, METH_VARARGS, "" },

Source/UnrealEnginePython/Private/UObject/UEPyInput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ PyObject *py_ue_bind_axis(ue_PyUObject *self, PyObject * args)
428428

429429
char *axis_name;
430430
PyObject *py_callable;
431-
if (!PyArg_ParseTuple(args, "sO:bind_action", &axis_name, &py_callable))
431+
if (!PyArg_ParseTuple(args, "sO:bind_axis", &axis_name, &py_callable))
432432
{
433433
return NULL;
434434
}

Source/UnrealEnginePython/Private/UObject/UEPyPlayer.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,27 @@ PyObject *py_ue_get_num_spectators(ue_PyUObject *self, PyObject * args)
211211
#endif
212212
}
213213

214+
PyObject *py_ue_restart_level(ue_PyUObject *self, PyObject * args)
215+
{
216+
217+
ue_py_check(self);
218+
219+
int controller_id = 0;
220+
if (!PyArg_ParseTuple(args, "|i:restart_level", &controller_id))
221+
{
222+
return NULL;
223+
}
224+
225+
UWorld *world = ue_get_uworld(self);
226+
if (!world)
227+
return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");
228+
229+
APlayerController *controller = UGameplayStatics::GetPlayerController(world, controller_id);
230+
if (!controller)
231+
return PyErr_Format(PyExc_Exception, "unable to retrieve controller %d", controller_id);
232+
233+
controller->RestartLevel();
234+
235+
Py_RETURN_NONE;
236+
}
237+

Source/UnrealEnginePython/Private/UObject/UEPyPlayer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ PyObject *py_ue_get_player_controller(ue_PyUObject *, PyObject *);
1111
PyObject *py_ue_get_player_hud(ue_PyUObject *, PyObject *);
1212
PyObject *py_ue_get_player_camera_manager(ue_PyUObject *, PyObject *);
1313
PyObject *py_ue_get_player_pawn(ue_PyUObject *, PyObject *);
14-
PyObject *py_ue_set_player_hud(ue_PyUObject *, PyObject *);
14+
PyObject *py_ue_set_player_hud(ue_PyUObject *, PyObject *);
15+
PyObject *py_ue_restart_level(ue_PyUObject *, PyObject *);

0 commit comments

Comments
 (0)