-
Notifications
You must be signed in to change notification settings - Fork 238
Lua 👀 #3128
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
Open
sug44
wants to merge
110
commits into
KSP-KOS:develop
Choose a base branch
from
sug44:lua_develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Lua 👀 #3128
+12,186
−176
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Separated interpreter specific logic with an new IInterpreterLink interface Created classes KSLink and LuaInterpreter that implement this interface Added a memeber "InterpreterLink" to SafeSharedObjects to access this new interface Created a new field "Interpreter" that calls OnInterpreterChanged function that sets Shared.InterpreterLink to the selected interpreter Atm interpreters can coexist alongside each other
IInterpreter -> ITerminal Interpreter -> Terminal SafeSharedObjects.Interpreter -> SafeSharedObjects.Terminal ConnectivityInterpreter -> ConnectivityTerminal IInterpreterLink -> IInterpreter SafeSharedObjects.InterpreterLink -> SafeSharedObjects.Interpreter KSLink -> KSInterpreter
Make separate boot file fields and boot file selections in editor Make interpreterLanguage field case insensitive
Swapping is done in one place during kOSProcessor booting. Revert CPU initialization and booting to how it was done before
Userdata type names Efficient print function Pairs metamethod for Structures 1 based indexing for Structures in lua Separate userdata type for kerboscript functions
This is what processor was doing on shutdown before Couldn't find anything that broke because of this but better safe than sorry
Reverted some changes from a104d58 commit that created a custom stack operator for lua Now kerboscript and lua use the same stack when calling kerboscript functions and SuffixDelegateResults
Put all types in Types folder Put function definitions in LuaFunctions.cs file Support Structure operators
…s)Cpu, (lua/ks)Interpreter in OnDestroy
Rename the stage structure getter from "stage" to "stageInfo" to avoid having the same name for the structure and the function. Make loadfile and dofile use the kOS file system. Replace terminal.input.getchar with a function that works for lua. It's a special case because the previous function modified the kerboscript stack after it returned.
"runfileon" function. Takes two arguments 1) path (works like path in "run") 2) processorId (works like processorId in "processor" function) Reboots the selected processor with the selected file as bootfile, resets the bootfile after booting. Automatically selects interpreter based on file extension "runcommandon" function. Takes two arguments 1) command string 2) processorId (works like processorId in "processor" function) Calls ProcessCommand(command) on the current interpreter of the selected processor
Refactor whitelist.lua to make it harder to accidentally expose non whitelisted values
Make kerboscript yields yield all coroutines, not just commandCoroutine. Remove base `wait` function that uses kerboscript yields. Replace the `wait` function with a kerboscript-like abstraction using lua `coroutine.yield()`. Add the `waituntil` function, similar to `wait`. This fixes update coroutines not being affected by kerboscript yields(`bounds` ship suffix, `stage` function).
Fix some function annotations
Fixes equal priority callbacks changing order after sorting because of the sorting algorithm being unstable
…e instructions hook fields to LuaInterpreter
…ts that can't be cast to structures
Because the update function has lower priority than terminal commands no need to reset it.
… without running out if instructions
Move utility functions to Lua.Util class
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds lua interpreter to kOS. It can be enabled with the "interpreter" field on kOS processors. Here is the documentation for further information. And here is the built release version.
There is the arcane issue #966 discussing lua in kOS. I chose a different approach to implementing lua in kOS than the one discussed in the issue. Instead of using the kerboscript VM I created a higher level binding layer for the functions, bound variables and structures used by it.
With a somewhat unconventional and large PR like this one, as well as the stale state of development, I took the liberty of not following some of the contributing guidelines, mainly not opening a new issue. Feel free to ask any questions, give feedback and discuss the feature here.