Replies: 3 comments 9 replies
-
|
Hi, In your menu program you do from MissionOne import *The motor setup code doesn’t run because it's not executed automatically during the I understand you do not want to do import MissionOne because that only runs on the first import. Have a look at the example in discussion 1387 Bert |
Beta Was this translation helpful? Give feedback.
-
Not that I am an expert. The setup for each mission would be just a small part of the complete mission I think. Bert |
Beta Was this translation helpful? Give feedback.
-
This example is actually running them on import, not calling functions. For most students, I would recommend keeping it simple that way. Everything will then work just like independent programs. Each with its own setup, which I think is what you are asking for? |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
My kids are struggling to combine block-based coding with a Python menu. We cannot figure out how to get mission-based functions (tasks) in blocks files – called from a menu coded in Python – to ever work correctly since the
set upcode in the block-based mission files doesn't seem like it's ever running.Rather than importing entire files (since the import statement will run a program only the first time), we're attempting to call mission-based functions as suggested here.
So we have a have a menu.py that looks something like:
Both MissionOne.py and MissionTwo.py have the same
set upblock that configures a driving base and an attachment motor.When selected via my menu, any
printblocks in runMissionOne and runMissionTwo print to the console, so I know things are somewhat wired up. But the robot doesn't drive and motors don't turn. No errors are logged to the console, but I'm thinking that theset upblock isn't running since I'm calling tasks in MissionOne.py and MissionTwo.py, as opposed to running directly from theprogramblock as you would if you weren't using a menu. If I manually call runMissionOne from theprogramblock in MissionOne.py, it works fine and theset upcode appears to run to configure my driving base and motors. Please help! I know we're close, but it's just not clicking how to get theset upblocks to run doing things this way.Beta Was this translation helpful? Give feedback.
All reactions