Skip to content
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

Allow for external calls to execute code #103

Open
erendrake opened this issue May 15, 2014 · 7 comments
Open

Allow for external calls to execute code #103

erendrake opened this issue May 15, 2014 · 7 comments
Assignees

Comments

@erendrake
Copy link
Member

We have had a request for an API to invoke a script from another module. For the first version of this feature I am going to propose a very small subset of features.

Limits:

  • One kOS module per craft
  • Only the ability to invoke a script by name

The API might only have a few calls
bool:IsActive(<Vessel.Id>)
bool:ExecuteProgram(<Vessel.Id>,)

This might not work for everything we want to do long term but I believe getting something very simple working and going from there is a prudent course.

As far as packaging this up for consumption, Would you rather We

  • Create a very small API dll you can reference and the kOS team updates?
  • Distribute a .cs file with all of the guts in it for you to include in your project?
  • publish the API as a doc and let you get to it however you like?
@erendrake erendrake added this to the v12.2 Adding features at last. milestone May 15, 2014
@Dunbaratu
Copy link
Member

Another important thing to be able to do is go the other way - allow kosscript to call other mods' APIs. I remember Nivekk had the beginnings of that, that had been used in a demo where a kos script commanded infernal robotics to rotate a hinged part. But I never saw how it was implemented.

@erendrake
Copy link
Member Author

True, but this will have to be a totally separate effort. We have started that work with RemoteTech but it needs to get much better. In fact i would like each other mod's api calls to be split out into their own dll, this will require some dependency inversion but that shouldnt be too hard.

I wish remotetech was a little healthier as a project and i could work with someone over there to figure this out. I have a few pull requests i need to send over to them.

@Dunbaratu
Copy link
Member

For the separate DLL, are you envisioning that we still are responsible for installing it on the end user's machine (It's part of our ZIP file, and the other mod should leave it out of their ZIP file?), and we're only giving a copy of it to them so their c# compiler can reference it? (And thus the other mod has to be written to be tolerant of the kos API dll being missing, since their mod can be installed on a user's machine that doesn't have KOS, and they're not installing the API DLL as part of their package ZIP.)

I'm a bit concerned about actually having the other mod include our API DLL in their ZIP because of possible fighting over which one KSP ends up loading when more than one mod are installed using it on the same user's machine. If one is out of date compared to the other that could be messy.

@erendrake
Copy link
Member Author

I imagine they would include it and we would have to make sure to always rev the DLL version, both dlls load in different paths. It is something to try out and see what works best I guess

@sirkut
Copy link

sirkut commented May 15, 2014

Is the code that utilizes the sendmessage not on Kevin's github? I know I probably still have the dll and most likey the code that implements kOS calling external methods in other dlls. It worked really well I was just no able to implement it in my end due to how IR was written.

@SolarLiner
Copy link

Hi,
I might be the one to have requested that feature, and that would help me in my process of biding GATU to kOS.
What I plan to have is the ability to listen to triggers from kOS sent by scripts that shows in the web interface. A more advanced feature would be to have a TextBox to send commands to run scripts from active terminal.
Thanks for implementing that!

@erendrake erendrake modified the milestone: v12.2 Adding features at last. Oct 11, 2014
@hvacengi hvacengi self-assigned this Dec 1, 2015
@hvacengi
Copy link
Member

hvacengi commented Dec 1, 2015

I'm currently working on an implementation for at least part of this feature. My idea is to essentially make it possible for an external dll to map a binding, an update handler, or modify/add suffixes. I think we would only require a reference to kOS.Safe (with kOS itself an option if you need to interact with KSP specific features), but I'm contemplating a separate API dll.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants