aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Aircraft.py10
-rw-r--r--lib/PacketManager/packets/FSNETCMD_AIRCMD.py27
2 files changed, 34 insertions, 3 deletions
diff --git a/lib/Aircraft.py b/lib/Aircraft.py
index 215a1cb..2672621 100644
--- a/lib/Aircraft.py
+++ b/lib/Aircraft.py
@@ -69,6 +69,7 @@ class Aircraft:
def add_state(self, packet:FSNETCMD_AIRPLANESTATE):
"""Adds the state of the aircraft"""
+
if packet.player_id != self.id:
return None
self.prev_life = self.life
@@ -79,9 +80,16 @@ class Aircraft:
return packet
def check_command(self,command:FSNETCMD_AIRCMD):
- """Checks the command"""
+ """Checks the command, and adds it to the aircraft"""
if command.aircraft_id != self.id:
return
if command.command:
self.initial_config[command.command[0]] = command.command[1]
debug(f"Command: {command.command}")
+
+ def set_afterburner(self, enabled:bool):
+ """If the afterburner is avaialble on the aircraft, will send a command
+ to toggle it."""
+ if self.get_initial_config_value("AFTBURNR") == "TRUE":
+ return FSNETCMD_AIRCMD.set_afterburner(self.id,enabled, True)
+ return None
diff --git a/lib/PacketManager/packets/FSNETCMD_AIRCMD.py b/lib/PacketManager/packets/FSNETCMD_AIRCMD.py
index 094da7d..50a9228 100644
--- a/lib/PacketManager/packets/FSNETCMD_AIRCMD.py
+++ b/lib/PacketManager/packets/FSNETCMD_AIRCMD.py
@@ -42,7 +42,7 @@ class FSNETCMD_AIRCMD: #30
return buffer
@staticmethod
- def setPayload(aircraft_id:int, payload:int, units:str='kg', with_size:bool=False):
+ def set_payload(aircraft_id:int, payload:int, units:str='kg', with_size:bool=False):
"""
This will set the payload of the aircraft, useful if you want to
load or unload passengers/cargo - for YSRP I use this to load and unload
@@ -52,5 +52,28 @@ class FSNETCMD_AIRCMD: #30
message = f"INITLOAD {payload} {units}"
return FSNETCMD_AIRCMD.encode(aircraft_id, message, with_size)
+ @staticmethod
+ def set_command(aircraft_id:int, command:str, value:int, with_size:bool=False):
+ """
+ This will set the command of the aircraft, useful if you want to
+ set the engine power, fuel, etc.
+ """
+ if command in AIRCMD_KEYWORDS:
+ command = AIRCMD_KEYWORDS.index(command)
+
+ message = f"*{command} {value}"
+ return FSNETCMD_AIRCMD.encode(aircraft_id, message, with_size)
+
+ @staticmethod
+ def set_afterburner(aircarft_id:int, enabled:int, with_size:bool=False):
+ """
+ This will set the afterburner of the aircraft, useful if you want to
+ enable or disable the afterburner.
+ """
+
+ command = "AFTBURNR"
+ value = str(enabled).upper()
+ return FSNETCMD_AIRCMD.set_command(aircarft_id, command, value, with_size)
+
def __str__(self):
- return "Aircraft ID : {self.aircraft_id}; Message : {self.message}; Command : {self.command}"
+ return f"Aircraft ID : {self.aircraft_id}; Message : {self.message}; Command : {self.command}"