Comments (5)
We have two problems here. First the obvious one that you noticed: we can't execute an expression referring a symbol that was not defined yet. Solution is seemingly easy: we simply have to define the delegate prior to running PEGAS. I don't know what's the structure of your code, but certainly you don't have to modify pegas.ks
(nor should you, really). The way I do it, is to put everything in the boot file.
However, that only solves the problem partially. The second issue is due to some restrictions that kOS places on how you can use delegates, most importantly it prevents you from running a delegate in a different module than it was declared in. In simple terms, this means that if you define your delegate in, let's say, your boot file (and also put it into sequence
there), and after that type run pegas.
into console, it won't work - because "you typing something into console" and "your previously executed bootfile" are two separate scopes.
The practical solution is to define the delegate and run PEGAS from the same scope, be it your boot file or a regular script file that you execute from the console level.
Hope that helps!
from pegas.
Hmm, so there are two solutions (correct me if I'm wrong):
- Declare the delegate on my boot file and append these instructions to it:
RUN mission.
RUN pegas.
which doesn't allow me to control when the mission "starts" by delaying the execution of PEGAS, or
- Create a separate script that has the delegate definition and runs PEGAS, which wouldn't allow me to call the delegate from within
sequence
.
None of these seem ideal unless I could append to sequence
from the separate script in option 2... right?
from pegas.
I'm pretty sure it would work with the way I use PEGAS.
My vehicle
/sequence
script is my boot
script and in the beginning, before anything else runs, it brings up the terminal window, shows a message on the screen and waits for user input (I need to focus the terminal and press any key for it to continue).
Then it runs the mission
file, displays mission parameters on the terminal (it's a good place to verify that I didn't screw something up with the mission) and waits for user input again.
After that, it runs pegas
itself. So with this, it will effectively continously be executing from your boot file, while not forcing you to load mission and pegas immediately and it should hopefully let it use the delegate if I understand it correctly.
As for the terminal input code, here's the documentation on that: https://ksp-kos.github.io/KOS/structures/misc/terminalinput.html
But you could use an action group as a trigger instead.
from pegas.
Ohh, so it's possible to condense everything in the boot file! I'll try and do that myself 😄
from pegas.
- Create a separate script that has the delegate definition and runs PEGAS, which wouldn't allow me to call the delegate from within sequence.
But you still can append (or, more likely, insert) to sequence
in this option:
FUNCTION shutvents {
// do stuff
}
sequence:INSERT(
0,
LEXICON("time", -25, "type", "delegate", "function", shutvents@, "message", "Shutting down vapor vents")
).
RUN pegas.
I have done it this way on occasion - you just need to be mindful where to insert the delegate event.
I kind of like Patryk's solution, but one significant issue with it is that you cannot alter the execution state this way - it only gives you delays on executing the whole thing, but you can't interrupt it to make some changes. Not the way you could in a usual scheme, where you can execute arbitrary commands after the boot file loads but before running PEGAS.
This is a mildly annoying thing to have to hack around, but some kOS fundamental limitations are like that.
from pegas.
Related Issues (20)
- Use PEGAS in landing HOT 3
- Setting postlaunch task HOT 3
- PEGAS with Asparagus Staging HOT 2
- PEGAS porting HOT 1
- TestFlight/TestLite support HOT 4
- Add-ons? HOT 2
- Use PEGAS in orbital maneuvers HOT 1
- In game UI still says v1.1 HOT 2
- UI: Event timeline HOT 3
- Custom steering vector transform HOT 14
- Proposal: total overhaul of the event system
- Support for hotstaging HOT 4
- Certain configurations of the flight plan cause a crash HOT 5
- Atmospheric guidance switches from pitch-program to min-AoA during UPFG preconvergence
- gLim disengages HOT 10
- Custom engine spool-up config HOT 1
- PEGAS uses variables that conflict with built-in functions, breaking the script on newer versions of kOS HOT 4
- Failure to MECO on time in certain circumstances
- gLim causes an engine shutdown when reaching 0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pegas.