Code Monkey home page Code Monkey logo

python-for-rimworld's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

python-for-rimworld's Issues

Allow multiple consoles

Allow multiple consoles to be open/Add button on console to open another console. Change console button behaviour such that it shows/hides all consoles, (or opens a single new console if every console has been closed). The window positions and sizes of all the consoles shall persist.

continuation prompt shouldn't continue indefinitely

The continuation prompt in the console ("...") should not be repeated indefinitely while inputting blank lines. The incomplete code should fail if multiple sequential blank lines are submitted (unless in a multiline string I guess).

At least there should be a key combo to end the input like ctrl+D (what you see in linux cli)

No method extensions in console

Preloaded extension methods are now working for /Python/ mods (commit 74bbf7f), but attempts to enable them for the console have continued to fail. Not only are they unable to be preloaded through the DLR interface, but clr.ImportExtensions doesn't appear to work within the console either; both silently fail. Though the actual point of failure could be anywhere between the actual import, and the name binding that happens after(/during?) code compilation.

So far I have investigated ModuleContexts being elusive, since that was the difficulty with enabling it for /Python/ mods.

A few things I have found that may be potentially interesting in an attempt to understand the lifecycle of CodeContext and ModuleContext, and how to manipulate them:

Builtin.GetExecEvalScope
PythonDynamicStackFrame
PythonOps.PublishModule / RemoveModule
PythonOps.CreateLocalContext
PythonOps.GetParentContextFromFunction
PythonOps.GetVariable
PythonOps.RawGetGlobal
PythonOps.RawGetLocal
ModuleTryGetMember //maybe proof of what Modules contain
\sCodeContext(/\*!\*/)?\s+\w+.*;
PythonScriptCode
RunnableScriptCode.GetContextForScope
PythonScopeExtensions
EnsureScopeExtension

Relationships I have come to understand:

  1. ScriptScope has a Scope, which has a PythonScopeExtension
  2. PythonScopeExtensions is likely the primary holder of ModuleContext. Its constructor creates a new ModuleContext
  3. ModuleContext has an ExtensionMethodSet. This is where the extension methods are.

Precise relationship between ModuleContext and CodeContext is still unclear. They may be codependent.

I wrote a tracer in the debug class to give tracebacks every time ModuleContext constructor is run. Further investigation of this might reveal why the ModuleContext is changing between setting the console's extensions and using the console, if that is indeed the problem at all.

The problem may well be something else entirely, such as to do with the usage of code.InteractiveInterpreter.

Tool to target game entities for console

Console "Inspect" feature, using same debug/developer menu Inspect feature functionality, to target game entities on the screen. Targeting entities from the console gives you a super easily reference them in the console via scripting.

make console button optional

make console button optional, such that the Python assemblies don't always have to be loaded right away. (make it a mod setting)

Console input wrap disappearing

Console input editor occasionally doesn't show wrapped input editor text. Could possibly be due to bug in counting number of lines in the console.

Open console targeting python mod

Make that feature where you can browse loaded Python mods, and open a console in the scope of one. The console title shall indicate which mod it's targeting.

/Python/ mod directory

Inject into RimWorld's mod loader:
A feature to: immediately after loading a mod, search the mod directory for a Python/ directory; if found, create a new scope and load a found file named main.py (probably) and execute it in the new scope.

The scope/python mod shall be globally registered such that:

  • other python mods are able to import the mod's Python/ directory as a module
  • allow a console feature of opening a console window in that mod's scope

The scope initially contains:
clr
Verse
Python
PyHarmony
Verse.ModContentPack content

Also, Python/ directory is added to sys.path for the script

Console input buffer editor

Have a toggle button to switch console view to a full blown text editor for the input buffer.

  • behave like a multiline text editor
  • Allow inserting/deleting lines. Line buffer class can be made to accommodate this (it just means a LOT of line update events being emitted since all the lines below will be shifted).
  • Allow copy/pasting. Allow copying entire buffer to clipboard, for easy saving to a text file outside of RimWorld.
  • In addition to normal selections (which can wrap), also allow selecting by lines (by clicking on the side margin or something), which the user can then use an action to switch back to the console view and auto-submitting all selected lines to the interpreter.

investigate usage of CodeContext

Figure out what's going on with CodeContext in the console output retrieval code. There was not enough understanding in its usage, and so it might unknowingly be causing unintended behaviours. Start by figuring out exactly what a CodeContext is.

Focused console should use up inputs

Stop console input from being passed to the game, when the console window has focus. ESPECIALLY stop the enter key from closing the Log window

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.