-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run code from a .sw file as part of a scenario's goal condition #828
Comments
We should implement Even unfinished import would be better than adding a hack for scenarios. For example, even if import only accepted files with definitions and could only be written as the first command it would be enough to solve this issue and improve the overall experience by 100%. Any hack for robots in scenarios will require the same work as "half-done import", so I would strongly advocate for doing that instead. To be fair, there is a use case that we discussed previously with @byorgey for adding definitions to the base before starting the scenario to implement a DSL. (Not sure if it was another issue or on IRC.) But with (even unfinished) import this could be much simpler, we could just let the base execute some code first without letting the player cancel. Note that it is possible to reuse scripts across scenarios - all code needs to be part of the SW file and you can switch between it based on e.g. robot name or entity placed under the robot. See for example how the Move tutorial reuses code. @kostmo please don't take this as a critique of the issue, it is a perfectly valid problem. But it is fundamentally caused by a longstanding imperfection of the |
Update regarding the specific issue called out in the title: I was actually able to make use of an external script in the goal condition, just not how I had initially envisioned. This works:
Experimentally (see #835), it appears that the |
@kostmo if you read #495 that I linked, you will see it tries to solve this very issue: Since your feature request seems to align exactly with that proposal, shall we close this as a duplicate? The root cause is the general problem of |
I should add that relying on the fact that in this case |
Is your feature request related to a problem? Please describe.
One may have goal evaluation code that is complicated and only feasible to write as a
.sw
file.This code might be tested using real robots, so that the author can observe the code's behavior in real time.
When it comes time to convert that to a
condition
, would like to re-use the code from the same file.Describe the solution you'd like
Definitions within that file should be brought into scope for "inline" use subsequently in the condition code.
Would like to be able to write the following condition code:
Related observation
Organizing code into a "function library"
.sw
file for use across multiple scenarios does not seem possible today.The text was updated successfully, but these errors were encountered: