refactor: Some functions now returns tuple for better unpacking
This commit is contained in:
@@ -5,7 +5,6 @@ def get_call_repr():
|
|||||||
func_name = frame.f_code.co_name
|
func_name = frame.f_code.co_name
|
||||||
args_info = inspect.getargvalues(frame)
|
args_info = inspect.getargvalues(frame)
|
||||||
|
|
||||||
# Формируем аргументы в виде строки
|
|
||||||
args_str = []
|
args_str = []
|
||||||
for arg in args_info.args:
|
for arg in args_info.args:
|
||||||
val = args_info.locals[arg]
|
val = args_info.locals[arg]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from ..server import PythonWebsocketServer
|
from ..server import PythonWebsocketServer
|
||||||
from ..call_repr import get_call_repr
|
from ..call_repr import get_call_repr
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
async def getHostname() -> str:
|
async def getHostname() -> str:
|
||||||
"""
|
"""
|
||||||
@@ -157,23 +158,23 @@ async def getServerWorld() -> str:
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def getTime() -> dict:
|
async def getTime() -> tuple:
|
||||||
"""
|
"""
|
||||||
The function is used to get the path of the default world on the server.
|
The function is used to get the path of the default world on the server.
|
||||||
Original: [getTime](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/game/getTime/)
|
Original: [getTime](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/game/getTime/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def getTime() -> dict
|
async def getTime() -> tuple
|
||||||
```
|
```
|
||||||
## Returns
|
## Returns
|
||||||
`dict {day, hour, min}`: The current time in the game.
|
`tuple (day, hour, min)`: The current time in the game.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['day'], result['hour'], result['min'])
|
||||||
|
|
||||||
async def serverLog(text : str):
|
async def serverLog(text : str):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from ..server import PythonWebsocketServer
|
from ..server import PythonWebsocketServer
|
||||||
from ..call_repr import get_call_repr
|
from ..call_repr import get_call_repr
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
async def addBan(info : dict) -> bool:
|
async def addBan(info : dict) -> bool:
|
||||||
"""
|
"""
|
||||||
@@ -192,25 +193,25 @@ async def getPlayerArmor(id : int) -> str:
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def getPlayerAtVector(id : int) -> dict:
|
async def getPlayerAtVector(id : int) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
This function will get player at vector.
|
This function will get player at vector.
|
||||||
Original: [getPlayerAtVector](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerAtVector/)
|
Original: [getPlayerAtVector](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerAtVector/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
getPlayerAtVector(id : int) -> dict
|
getPlayerAtVector(id : int) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`int` **id**: the player id.
|
`int` **id**: the player id.
|
||||||
## Returns
|
## Returns
|
||||||
`dict {x, y, z}`: the player at vector.
|
`tuple (x, y, z)`: the player at vector.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['x'], result['y'], result['z']) if result is not None else None
|
||||||
|
|
||||||
async def getPlayerBelt(id : int) -> str:
|
async def getPlayerBelt(id : int) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -232,25 +233,25 @@ async def getPlayerBelt(id : int) -> str:
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def getPlayerCameraPosition(id : int) -> dict:
|
async def getPlayerCameraPosition(id : int) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
This function will get the player camera position in world.
|
This function will get the player camera position in world.
|
||||||
Original: [getPlayerCameraPosition](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerCameraPosition/)
|
Original: [getPlayerCameraPosition](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerCameraPosition/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
getPlayerCameraPosition(id : int) -> dict
|
getPlayerCameraPosition(id : int) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`int` **id**: the player id.
|
`int` **id**: the player id.
|
||||||
## Returns
|
## Returns
|
||||||
`dict {x, y, z}`: the dictionary that represents camera position.
|
`tuple (x, y, z)`: the dictionary that represents camera position.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['x'], result['y'], result['z']) if result is not None else None
|
||||||
|
|
||||||
async def getPlayerCollision(id : int) -> bool:
|
async def getPlayerCollision(id : int) -> bool:
|
||||||
"""
|
"""
|
||||||
@@ -272,25 +273,25 @@ async def getPlayerCollision(id : int) -> bool:
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def getPlayerColor(id : int) -> dict:
|
async def getPlayerColor(id : int) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
This function will get the player nickname color.
|
This function will get the player nickname color.
|
||||||
Original: [getPlayerColor](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerColor/)
|
Original: [getPlayerColor](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerColor/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def getPlayerColor(id : int) -> dict
|
async def getPlayerColor(id : int) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`int` **id**: the player id.
|
`int` **id**: the player id.
|
||||||
## Returns
|
## Returns
|
||||||
`dict {r, g, b}`: the player nickname color.
|
`tuple (r, g, b)`: the player nickname color.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['r'], result['g'], result['b']) if result is not None else None
|
||||||
|
|
||||||
async def getPlayerContext(id : int, type : int) -> int:
|
async def getPlayerContext(id : int, type : int) -> int:
|
||||||
"""
|
"""
|
||||||
@@ -638,25 +639,25 @@ async def getPlayerPing(id : int) -> int:
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def getPlayerPosition(id : int) -> dict:
|
async def getPlayerPosition(id : int) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
This function will get the player world position.
|
This function will get the player world position.
|
||||||
Original: [getPlayerPosition](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerPosition/)
|
Original: [getPlayerPosition](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerPosition/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def getPlayerPosition(id : int) -> dict
|
async def getPlayerPosition(id : int) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`int` **id**: the player id.
|
`int` **id**: the player id.
|
||||||
## Returns
|
## Returns
|
||||||
`dict {x, y, z}`: the player world position.
|
`tuple (x, y, z)`: the player world position.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['x'], result['y'], result['z']) if result is not None else None
|
||||||
|
|
||||||
async def getPlayerRangedWeapon(id : int) -> str:
|
async def getPlayerRangedWeapon(id : int) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -719,25 +720,25 @@ async def getPlayerRing(id : int, handId : int) -> str:
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def getPlayerScale(id : int) -> dict:
|
async def getPlayerScale(id : int) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
This function will get the player scale.
|
This function will get the player scale.
|
||||||
Original: [getPlayerScale](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerScale/)
|
Original: [getPlayerScale](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerScale/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def getPlayerScale(id : int) -> dict
|
async def getPlayerScale(id : int) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`int` **id**: the player id.
|
`int` **id**: the player id.
|
||||||
## Returns
|
## Returns
|
||||||
`dict {x, y, z}`: the player scale.
|
`tuple (x, y, z)`: the player scale.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['x'], result['y'], result['z']) if result is not None else None
|
||||||
|
|
||||||
async def getPlayerSerial(id : int) -> str:
|
async def getPlayerSerial(id : int) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -907,25 +908,25 @@ async def getPlayerVirtualWorld(id : int) -> int:
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def getPlayerVisual(id : int) -> dict:
|
async def getPlayerVisual(id : int) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
This function will get the player visual.
|
This function will get the player visual.
|
||||||
Original: [getPlayerVisual](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerVisual/)
|
Original: [getPlayerVisual](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/player/getPlayerVisual/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def getPlayerVisual(id : int) -> dict
|
async def getPlayerVisual(id : int) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`int` **id**: the player id.
|
`int` **id**: the player id.
|
||||||
## Returns
|
## Returns
|
||||||
`dict {bodyModel, bodyTxt, headModel, headTxt}`: player visual.
|
`tuple (bodyModel, bodyTxt, headModel, headTxt)`: player visual.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['bodyModel'], result['bodyTxt'], result['headModel'], result['headTxt']) if result is not None else None
|
||||||
|
|
||||||
async def getPlayerWeaponMode(id : int) -> int:
|
async def getPlayerWeaponMode(id : int) -> int:
|
||||||
"""
|
"""
|
||||||
@@ -1481,7 +1482,7 @@ async def setPlayerName(id : int, name : str) -> bool:
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def setPlayerPosition(id : int, x : float, y : float, z : float):
|
async def setPlayerPosition(id : int, x : float, y : float, z : float) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
!!! note
|
!!! note
|
||||||
This functions supports ``pass_exception: bool`` optional argument for manual handling exceptions.
|
This functions supports ``pass_exception: bool`` optional argument for manual handling exceptions.
|
||||||
@@ -1490,7 +1491,7 @@ async def setPlayerPosition(id : int, x : float, y : float, z : float):
|
|||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def setPlayerPosition(id : int, x : float, y : float, z : float)
|
async def setPlayerPosition(id : int, x : float, y : float, z : float) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`int` **id**: the player id.
|
`int` **id**: the player id.
|
||||||
@@ -1498,13 +1499,13 @@ async def setPlayerPosition(id : int, x : float, y : float, z : float):
|
|||||||
`float` **y**: the position in the world on the y axis.
|
`float` **y**: the position in the world on the y axis.
|
||||||
`float` **z**: the position in the world on the z axis.
|
`float` **z**: the position in the world on the z axis.
|
||||||
OR
|
OR
|
||||||
`dict[str, float]` **pos**: the position in the world on the XYZ axis.
|
`tuple(x, y, z)` **pos**: the position in the world on the XYZ axis.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['x'], result['y'], result['z']) if result is not None else None
|
||||||
|
|
||||||
async def setPlayerRespawnTime(id : int, respawnTime : int):
|
async def setPlayerRespawnTime(id : int, respawnTime : int):
|
||||||
"""
|
"""
|
||||||
@@ -1527,7 +1528,7 @@ async def setPlayerRespawnTime(id : int, respawnTime : int):
|
|||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def setPlayerScale(id : int, x : float, y : float, z : float):
|
async def setPlayerScale(id : int, x : float, y : float, z : float) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
!!! note
|
!!! note
|
||||||
This functions supports ``pass_exception: bool`` optional argument for manual handling exceptions.
|
This functions supports ``pass_exception: bool`` optional argument for manual handling exceptions.
|
||||||
@@ -1536,7 +1537,7 @@ async def setPlayerScale(id : int, x : float, y : float, z : float):
|
|||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def setPlayerScale(id : int, x : float, y : float, z : float)
|
async def setPlayerScale(id : int, x : float, y : float, z : float) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`int` **id**: the player id.
|
`int` **id**: the player id.
|
||||||
@@ -1544,13 +1545,13 @@ async def setPlayerScale(id : int, x : float, y : float, z : float):
|
|||||||
`float` **y**: the scale factor on y axis.
|
`float` **y**: the scale factor on y axis.
|
||||||
`float` **z**: the scale factor on z axis.
|
`float` **z**: the scale factor on z axis.
|
||||||
OR
|
OR
|
||||||
`dict[str, float]` **pos**: the scale factor on the XYZ axis.
|
`tuple(x, y, z)` **pos**: the scale factor on the XYZ axis.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['x'], result['y'], result['z']) if result is not None else None
|
||||||
|
|
||||||
async def setPlayerSkillWeapon(id : int, skillId : int, percentage : int):
|
async def setPlayerSkillWeapon(id : int, skillId : int, percentage : int):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
from ..server import PythonWebsocketServer
|
from ..server import PythonWebsocketServer
|
||||||
from ..call_repr import get_call_repr
|
from ..call_repr import get_call_repr
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
async def getNearestWaypoint(world : str, x : int, y : int, z : int) -> dict:
|
async def getNearestWaypoint(world : str, x : int, y : int, z : int) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
This function is used to retrieve the information about nearest waypoint from the specified position.
|
This function is used to retrieve the information about nearest waypoint from the specified position.
|
||||||
Original: [getNearestWaypoint](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/waypoint/getNearestWaypoint/)
|
Original: [getNearestWaypoint](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/waypoint/getNearestWaypoint/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def getNearestWaypoint(world : str, x : int, y : int, z : int) -> dict
|
async def getNearestWaypoint(world : str, x : int, y : int, z : int) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`str` **world**: the world name in which the waypoint exists.
|
`str` **world**: the world name in which the waypoint exists.
|
||||||
@@ -16,22 +17,22 @@ async def getNearestWaypoint(world : str, x : int, y : int, z : int) -> dict:
|
|||||||
`int` **y**: the position in the world on the y axis.
|
`int` **y**: the position in the world on the y axis.
|
||||||
`int` **z**: the position in the world on the z axis.
|
`int` **z**: the position in the world on the z axis.
|
||||||
## Returns
|
## Returns
|
||||||
`dict {name, x, y, z}`: Waypoint information.
|
`tuple (name, x, y, z)`: Waypoint information.
|
||||||
"""
|
"""
|
||||||
data = f'return {get_call_repr()}'
|
data = f'return {get_call_repr()}'
|
||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['name'], result['x'], result['y'], result['z']) if result is not None else None
|
||||||
|
|
||||||
async def getWaypoint(world : str, name : str) -> dict:
|
async def getWaypoint(world : str, name : str) -> Optional[tuple]:
|
||||||
"""
|
"""
|
||||||
This function is used to retrieve the position of specified waypoint.
|
This function is used to retrieve the position of specified waypoint.
|
||||||
Original: [getWaypoint](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/waypoint/getWaypoint/)
|
Original: [getWaypoint](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-functions/waypoint/getWaypoint/)
|
||||||
|
|
||||||
## Declaration
|
## Declaration
|
||||||
```python
|
```python
|
||||||
async def getWaypoint(world : str, name : str) -> dict
|
async def getWaypoint(world : str, name : str) -> Optional[tuple]
|
||||||
```
|
```
|
||||||
## Parameters
|
## Parameters
|
||||||
`str` **world**: the world name in which the waypoint exists.
|
`str` **world**: the world name in which the waypoint exists.
|
||||||
@@ -43,4 +44,4 @@ async def getWaypoint(world : str, name : str) -> dict:
|
|||||||
|
|
||||||
server = await PythonWebsocketServer.get_server()
|
server = await PythonWebsocketServer.get_server()
|
||||||
result = await server.make_request(data)
|
result = await server.make_request(data)
|
||||||
return result
|
return (result['x'], result['y'], result['z']) if result is not None else None
|
||||||
Reference in New Issue
Block a user