Code Monkey home page Code Monkey logo

vscode-craftos-pc's Introduction

CraftOS-PC for VS Code README

An extension for Visual Studio Code adding a bunch of new features to help you write ComputerCraft code easier through CraftOS-PC.

Features

  • Support for built-in CraftOS-PC terminals in VS Code
  • Quickly access computer data directories and the configuration
  • Run ComputerCraft Lua scripts in CraftOS-PC
  • Browse files on the connected computer in the current workspace
  • Connect to CraftOS-PC raw mode WebSocket servers
  • Use the remote.craftos-pc.cc service to open any ComputerCraft computer in VS Code (beta)
  • Debug code directly in VS Code using the native debugger interface

Screenshot

Debugger screenshot

Requirements

  • CraftOS-PC v2.3 or later (https://www.craftos-pc.cc)
    • If on Windows, make sure to install the console version as well under Optional components in the installer
    • If installed in a non-standard directory (such as in your user directory), make sure to set craftos-pc.executablePath in the settings
    • See "Known issues" for caveats for certain CraftOS-PC versions
    • If you only want to use remote.craftos-pc.cc, you do not have to install CraftOS-PC

Recommended Extensions

Extension Settings

This extension contributes the following settings:

  • craftos-pc.executablePath.[windows|mac|linux|all]: Path to the CraftOS-PC executable depending on the platform. This should be an absolute path to an executable supporting console output (on Windows, this must be pointing to a copy of CraftOS-PC_console.exe, which is optionally available in the installer).
  • craftos-pc.dataPath: Path to the data directory storing computer files, configuration, etc.
  • craftos-pc.additionalArguments: Additional command-line arguments to send to CraftOS-PC, separated by spaces.
  • craftos-pc.customFont.path: The path to a custom font, if desired. Must be a path to a valid image, or 'hdfont' to automatically find the HD font. Unlike normal CraftOS-PC, this may point to non-BMP files as well.

Known Issues

  • Occasionally, keyboard input may stop working. To fix this, click outside the CraftOS-PC window and then back in.
  • Scroll events do not report the position of the scroll. This is a limitation of JavaScript.
  • Live Share support does not respect read-only mode due to a limitation in the Live Share API.
  • Some versions of CraftOS-PC have bugs that interfere with the functioning of this extension:
    • The debugger only works on CraftOS-PC v2.7 or later.
    • Filesystem access only works on CraftOS-PC v2.6 or later, or any server implementing raw mode 1.1 or later.
    • v2.5.4-v2.5.5: Creating a new window results in a crash. This is fixed in v2.6.
    • v2.5.1-v2.5.1.1: CraftOS-PC often crashes in raw mode on these versions. This is fixed in v2.5.2.
    • v2.3-v2.3.4: All events are sent to the first window, and all windows have the same ID. This is fixed in v2.4.

Live Share

The VS Code Live Share extension uses a permission list to check whether an extension is allowed to use certain parts of the API. Unfortunately, that list does not include this extension (yet), so Live Share support requires creating a special config file to enable it manually.

To fix this, create a file called .vs-liveshare-settings.json in your home folder, and paste this inside the file:

{
    "extensionPermissions": {
        "JackMacWindows.craftos-pc": [
            "shareServices"
        ]
    }
}

Then reload VS Code and run Live Share again.

Release Notes

1.2.3

  • Added a new very prominent button to open files
  • Added an extra alert when the files are already open

1.2.2

  • Fixed an issue preventing uploading files between 48-64 kB in size

1.2.1

  • Added automatic detection of user installations on Windows
  • Adjusted some error messages to be more descriptive
  • Added a new output channel for debugging messages

1.2.0

  • Added debugger support for CraftOS-PC v2.7 and later
  • Added support for Visual Studio Live Share
    • This currently requires manually allowing the extension to communicate

1.1.8

  • Fixed a bug causing disconnections when sending large data packets

1.1.6

  • Added Run Script button to quickly run files in a new CraftOS-PC instance

1.1.5

  • Added history to Open WebSocket button

1.1.4

  • Terminal windows now automatically resize to fit the screen
  • Fixed an issue causing the bug info prompt from 1.1.3 to not appear

1.1.3

  • Added more information about VS Code "certificate has expired" bug
  • Added a "CraftOS-PC: Force Close Connection" to close the connection immediately without waiting for a response
  • Fixed an issue causing remote screens to go black

1.1.1

  • Fixed mouse_up event not being sent

1.1.0

  • Added ability to connect to WebSocket servers
  • Added integration with new remote.craftos-pc.cc service (beta)
  • Added support for raw mode 1.1 specification
  • Added URI handler for WebSocket links
  • Fixed security vulnerability in glob-parent dependency

1.0.2

  • Fixed wrong mouse buttons being sent
  • Fixed drag coordinates in the margins of the screen
  • Fixed mouse drag events firing in the same cell after click

1.0.1

  • Fixed mouse events not being sent to the window

1.0.0

  • Added support for custom fonts
    • Font files must be in the exact same format as ComputerCraft fonts (with the same outer padding area)
  • Added close buttons to each window, as well as a global quit button
  • Added buttons to open a new window with the selected computer's data directory
    • This requires either CraftOS-PC v2.5.6 or later, or computers labeled "Computer >id<"
  • Added button to open the configuration
  • Added paste event detection
  • Added icons for monitors
  • Updated extension icon to CraftOS-PC v2.4's new icon
  • Fixed duplicate drag events being sent for the same character cell
  • Fixed mouse events sending the wrong coordinates
  • Fixed the computer background not being drawn properly
  • Upgraded y18n and lodash to fix vulnerabilities (#3, #4)
  • Reformatted code to be a bit more clean

0.2.1

  • Added an error message if the executable is missing
  • Fixed mouse_click events being sent instead of mouse_drag

0.2.0

  • Fixed performance issues causing high CPU usage and major slowdown
    • Render speed should now be about the same as in standard GUI mode
  • Added craftos-pc.additionalArguments setting
  • Added command to close the emulator session without having to close each window
  • Fixed a bug causing CraftOS-PC to not start on Windows when a workspace is open

0.1.1

Fixes a bug where the wrong key events were being sent (e.g. key_up when pressing a key down). Also fixes char events being sent with modifier keys held.

Download the latest build of CraftOS-PC (from 7/27/20 or later) to fix a bug with events being sent to the wrong window, as well as a bug preventing Ctrl-R/S/T from working properly.

0.1.0

First public alpha release.

vscode-craftos-pc's People

Contributors

dependabot[bot] avatar mcjack123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-craftos-pc's Issues

Error loading webview

Error loading webview: Error: Could not register service workers: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state..

Not sure of the cause. CraftOS-PC is installed at the default location. I am using VSCode 1.63.2.

Breakpoints not working in mounted files

Hi, I just recently got started with using CraftOS-PC in combination with vscode.
I've wanted to try it for a while now, because it'd allow me to debug easier, and do it with a readonly mounted filesystem to avoid breaking project files.

Although, after trying it, it didn't seem to work with the builtin breakpoint functionality.

One possible solution would be to allow specifying a source:destination mapping in the workspace config for automounting.

Something like:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "craftos-pc",
            "request": "attach",
            "name": "Debug CraftOS-PC",
            "port": 0,
            "mount": {
                "src": "project"
            }
        }
    ]
}

Where src refers to the directory ${workspaceFolder}/src/, and project refers to the mounted path /project/ in the CraftOS-PC system.

I think adding this would allow much more flexibility with projects, and seperate design and runtime files without requiring a copy task (Which also allows semi-live reload).

Lua files in CraftOS-PC cause Lua Language Server to load infinitely

No idea if there is anything you can do about this, but I figured since it is CraftOS PC specific it would be better to start here. The Lua Language Server + extension has trouble handling files from CraftOS PC.

It does not seem to matter if they are remote or local.

The only other notable thing is that I am using VS Code Remote with WSL (so VS Code is on the Windows host system, but it connects to the WSL Linux instance and CraftOS is also inside of WSL/running the Linux version). There are no other issues, the terminal and everything else still works.

image

The Loading workspace count and memory usage keeps climbing until VS Code slows down. I am guessing it is because the file CraftOS PC paths are not "real" (/ on the host system is a real Linux file system, so it is trying to index the whole file system).

`key_up` not being fired for certain keys

Describe the bug
The key_up is not sent for certain keys, such as Shift, the A, Q, W, E, R keys...

To Reproduce
Steps to reproduce the behavior:

  1. Go into the lua interpreter
  2. Type while true do print(os.pullEvent("key_up")) end
  3. Watch how only certain keys trigger the key_up event, such as the D key.

Expected behavior
key_up should be triggered for each key of the keyboard (except escape).

Screenshots
Compares the extension with CraftOS-PC standalone. Notice how the key_up event isn't being triggered for keys 28, 30, 31, etc.
image

Environment (please complete the following information):

  • OS: Windows 10
  • OS Version: 1909
  • CraftOS-PC Version: v2.5.1.1
  • Compiled from source? No

Additional context
The same behaviour does not occur on the standalone version (Haven't tried on the web one because it freezes for me for some reason). This is an extension/binding issue and not a program core one, as far as I know.

CC Remote Terminal monitor size discrepancy?

Hello, I noticed that the size of the remote monitor with ComputerCraft Remote Terminal does not have the same size as the one in the game. Is there any way to make them match, or to modify the monitor size visible in VS Code so that I can see more stuff?

(Also, for some reason things displayed in the remote monitor do not appear in the in-game monitor, is that normal?)

image

Also, the remote feature is absolutely awesome, thank you so much for making it!

Option to close old terminal when running script

Hi,
i just hate, when i need to close old craftos terminal when i need to run something again when i change something in lua code.
Will it be possible, to make settings option, where user will check, if they want to automaticaly close old terminal, or is it possible to run script on same terminal and i'm just missing something
image

`mouse_click` spam on drag

Describe the bug
mouse_click is sent multiple times when dragging the mouse over while holding any mouse button down.

To Reproduce
Steps to reproduce the behavior:

  1. Go into the lua interpreter
  2. Type while true do print(os.pullEvent("mouse_click")) end
  3. Watch how the events flood in when the mouse is holded down and being dragged.

Expected behavior
mouse_click should only be pushed when a mouse's button is clicked, and not holded.

Screenshots
In this screenshot you can see different behaviour with the same input both in CraftOS-PC and Tweaked CC.
image

Environment (please complete the following information):

  • OS: Windows 10
  • OS Version: 1909
  • CraftOS-PC Version: v2.5.1.1
  • Compiled from source? No

Additional context
The same behaviour does not occur on the standalone version (Haven't tried on the web one because it freezes for me for some reason). This is an extension/binding issue and not a program core one, as far as I know.

OrphanedThreadException when connected to CC: Tweaked Remote PC

First of all great work on this extension! Unfortunately I am encountering the following issue after a short duration of being connected to a CC: Tweaked PC on a multiplayer server:

  1. Connect to CC: Tweaked PC with the "Connect to Remote (Beta)" feature
  2. Editing files and using the terminal from VSCode works
  3. Wait a short while (~1min)
  4. VSCode shows notification "Disconnected from WebSocket server", files no longer available, terminal in VSCode no longer responds to key input
  5. CC: Tweaked PC in Minecraft shows the following exception:
[string "server.lua"]:1: Java Exception Thrown:
org.squiddev.cobalt.InterruptedError:
org.squiddev.cobalt.OrphanedThreadException:
OrphanedThread

At this point it is possible to reconnect again, but the exception occurs every time after a short duration.

Version Details

VSCode-CraftOS-PC: v1.2.1
VSCode:            1.77.0 (On MacOS Ventura 13.3, x86)
Modpack:           FTB Revelation 3.6.0
Minecraft Forge:   14.23.5.2858
CC: Tweaked:       1.89.2

The Server is hosted on exaroton.com and is using Java 8.

More than 100000 Files have been scanned by language server // language server scanns root directory of Computer

Describe the bug
A clear and concise description of what the bug is.

If you add a computers file system -> before you connect it -> lua language server by sumneko will scan the root directory of your entire PC leading to this error
image

Hypothetical reason for this happening -> a not connected computer file path is "/" -> so path turns to ":/"
image

Leading to this (upper path is my project -> lower is the computers path I assume)
image

To Reproduce
Steps to reproduce the behaviour:

  1. open vscode
  2. install ComputerCraft Extension Pack by Lemmmy
  3. Follow steps in your tutorial for CraftOs https://www.youtube.com/watch?v=HtafiCaT6CI
  4. Connect to computer
  5. Add File Explorer
  6. Watch VSCODE toss this error
    image
  7. hover over Lua at bottom right to see the dirs being loaded
    image

Expected behavior
A clear and concise description of what you expected to happen.
Excepted behaviour is that if a computer's files are not loaded/connected it should not send the root of the operating system ":/" to the Lua server to scan

Screenshots
If applicable, add screenshots or recordings to help explain your problem. You can capture these using F2, F3, or F12. If CraftOS-PC has crashed, paste the stack trace here (wrapped in ``` characters please!).

Environment (please complete the following information):

  • OS: Windows10 [e.g. Windows 10]
  • OS Version: 22H2 [e.g. 2004] (this can be found in Settings -> System -> About)
  • CraftOS-PC Version: v1.2.2 [e.g. v2.2]
  • Compiled from source? No [Yes] [No] (if in doubt, choose No)

Additional context
Add any other context about the problem here.

Improper handling of `mouse_click` position for big screens

Was playing around with this and was surprised how well it has been handling anything that's not the standard 50x19 screens of ComputerCraft. E.g. building a big advanced screen array and running the server on that, or hacking the server to just use rawterm in detached mode without a real screen being forced to mirror its state.

Sadly mouse_click position gets handled in a very fixed way by the extension, for some reason, and just gets trimmed, despite the extension having full knowledge of the screen size.

Crash when attaching peripheral

Hey there, just wanted to attach a peripheral, but CraftOS-PC crashed when doing so.

When I try the same command in CraftOS-PC Standalone, it works though, that's why I'm posting here.

I tried: attach top monitor and attach left debugger

I would attach the dump, but it's not being generated.

The only thing that might help with diagnosing is this:
image

This is a fresh installation of both the plugin and CraftOS-PC. Both with default settings.

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.