(In this specific case, of course, as the author of that particular bit of Obj-C code I'm highly unlikely to be suing OXP authors who produce JS implementations of the same algorithm having read the Oolite source, and I'm happy for you to use JS reimplementations of it in any CC-BY-SA or CC-BY-NC-SA OXP without further note - but you need to be much more careful with GPL code in general)
If you want to be absolutely certain, what sometimes happens in these cases is person A will analyse the original code and write a specification for what it does - but not how it does it. Person B will then implement some new code to that specification without ever looking at the original. ("Clean room implementation" is the phrase to search if you want more details)
In this particular case, the behaviour of everything in that function is documented at [wiki]trade-goods.plist[/wiki] already, and there's a post from me somewhere on the forums explaining how
economicBiasForGood
works and why.
As regards the re-use of code under other licenses, the problem with your solution here is that if you incorporate GPL code into your program, the
entire program must then be licensed GPL (intentionally so, to prevent people including GPL modules in closed-source apps). This doesn't stop you, as the copyright holder for the rest of the work, licensing that additionally under something else. So, what you'd need to do is:
- license for OXP in Readme and manifest is marked as GPL (the manifest really should
only include licenses which can apply to the whole OXP, to avoid leaving traps for people trusting that field). In the Readme note that except where otherwise stated in the code, reuse under (say) CC-BY-NC-SA is also allowed.
- reverse the sense of the comment: state that this section of code is not redistributable under CC-BY-NC-SA due to its source, and must be removed and reimplemented to distribute under that license. (It would be nice to list the locations of these sections in the Readme as well, but that's not strictly necessary)
- make sure you don't also incorporate any code anywhere which you
can't use as GPL - e.g. anything taken from other CC-BY-NC-SA or CC-BY-SA 3 OXPs, because you don't have permission to redistribute that as GPL, but don't have permission to not do so either.
Some licenses do allow that sort of integration and note approach - MIT, or BSD, for example - but the GPL doesn't.
In the specific case of CC-BY-SA-4 it allows you to relicense works under that license one-way to GPL3, so what you can do there is:
- take the GPL 2 or later code in Oolite
- take the option to use it under GPL 3
- take the CC-BY-SA-4 code in another OXP
- take the option to use it under GPL 3
- license your entire OXP under GPL 3.
but that's a particularly unusual case.
You could also:
1) Ask in the
Scripting Requests thread - generally if it's trivial to reimplement in JS it's probably also pretty easy to expose the functionality to JS
2) Submit a patch to the core code which provides the JS implementation (if you can read ObjC you can probably write it too, and the Javascript interface is easy to add stuff too by copy and paste - that's what most of my first patches to the core were)