From e77915c1ae159f426476683b3c313d63bbb71d4b Mon Sep 17 00:00:00 2001 From: Noskcaj Date: Fri, 14 Sep 2018 20:08:45 -0400 Subject: [PATCH 1/3] Call setup() on autonomous modes, fixing #19 --- magicbot/magicrobot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/magicbot/magicrobot.py b/magicbot/magicrobot.py index 0d1feb6..5940374 100644 --- a/magicbot/magicrobot.py +++ b/magicbot/magicrobot.py @@ -498,6 +498,12 @@ def _create_components(self): if hasattr(component, 'setup'): component.setup() + # Call setup functions for autonomous modes + for mode in self._automodes.modes.values(): + if hasattr(component, 'setup'): + mode.setup() + + def _create_component(self, name, ctyp): # Create instance, set it on self component = ctyp() From e5ed9c090425078a635a32d2385ba8a4532ea884 Mon Sep 17 00:00:00 2001 From: Noskcaj Date: Fri, 14 Sep 2018 21:46:35 -0400 Subject: [PATCH 2/3] Fix wrong variable name --- magicbot/magicrobot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magicbot/magicrobot.py b/magicbot/magicrobot.py index 5940374..ad553a0 100644 --- a/magicbot/magicrobot.py +++ b/magicbot/magicrobot.py @@ -500,7 +500,7 @@ def _create_components(self): # Call setup functions for autonomous modes for mode in self._automodes.modes.values(): - if hasattr(component, 'setup'): + if hasattr(mode, 'setup'): mode.setup() From 8cb34d361eb7167c491718317a9768e76bad54ff Mon Sep 17 00:00:00 2001 From: Noskcaj Date: Sat, 15 Sep 2018 09:19:42 -0400 Subject: [PATCH 3/3] Remove extra blank line --- magicbot/magicrobot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/magicbot/magicrobot.py b/magicbot/magicrobot.py index ad553a0..6a91cd6 100644 --- a/magicbot/magicrobot.py +++ b/magicbot/magicrobot.py @@ -503,7 +503,6 @@ def _create_components(self): if hasattr(mode, 'setup'): mode.setup() - def _create_component(self, name, ctyp): # Create instance, set it on self component = ctyp()