diff --git a/mesh_bot.py b/mesh_bot.py index 1859788..2ae7bb5 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -1178,8 +1178,12 @@ def handleLunarLander(message, nodeID, deviceID): global lunarlanderTracker from modules.settings import use_metric - # Strip command prefix from message - user_input = message.replace("lunarlander", "").strip() + # Strip command prefix from message (case-insensitive, start-only) + msg = message.strip() + if msg.lower().startswith("lunarlander"): + user_input = msg[len("lunarlander"):].strip() + else: + user_input = msg tracker_entry = next((entry for entry in lunarlanderTracker if entry['nodeID'] == nodeID), None) diff --git a/modules/games/lunarlander.py b/modules/games/lunarlander.py index c3e8373..0b653f3 100644 --- a/modules/games/lunarlander.py +++ b/modules/games/lunarlander.py @@ -372,6 +372,10 @@ def process_final_tick( delta_t = capsule.altitude / average_vel new_state = capsule.predict_motion(delta_t) capsule.update_state(sim_clock, delta_t, new_state) + + # Prevent infinite loop - if we're still above surface, landing result + if new_state.altitude <= 0: + return show_landing(sim_clock, capsule) def handle_flyaway(sim_clock: SimulationClock, capsule: Capsule) -> bool: