Skip to content

Add janet-lang scripting support#1

Closed
Copilot wants to merge 4 commits into
masterfrom
copilot/fix-e4f8a7d1-c1d1-4e83-984f-97e4ceb753fe
Closed

Add janet-lang scripting support#1
Copilot wants to merge 4 commits into
masterfrom
copilot/fix-e4f8a7d1-c1d1-4e83-984f-97e4ceb753fe

Conversation

Copy link
Copy Markdown

Copilot AI commented Aug 20, 2025

This PR adds janet-lang as a third scripting language option to Gauzarbeit, alongside the existing Lua and JavaScript (QuickJS) support.

What's Added

Core Implementation

  • ScriptedThing_Janet class following the same architectural pattern as ScriptedThing (Lua) and ScriptedThing_JS (JavaScript)
  • Janet runtime integration with proper initialization and cleanup via Init() and DeInit() methods
  • Script loading system supporting both global initialization scripts and per-thing scripts

File Structure

include/script/ScriptedThing_Janet.hpp  # Janet scripting interface
src/script/ScriptedThing_Janet.cpp      # Implementation
scripts/Init.janet                      # Global Janet initialization
scripts/things/*.janet                  # Per-thing Janet scripts

Integration

  • Updated main.cpp to initialize Janet scripting system alongside Lua and JavaScript
  • Updated makefile to link against janet library (-ljanet)
  • Added janet include paths and dependencies

Usage Example

// Initialize Janet scripting
ScriptedThing_Janet::Init();

// Create a Janet-scripted game object
auto grape = std::make_shared<ScriptedThing_Janet>("JanetGrape");

// Cleanup
ScriptedThing_Janet::DeInit();

Janet scripts can define variables, functions, and game logic:

# scripts/things/JanetGrape.janet
(def grape-sweetness 85)
(def grape-size (* 2.5 3))

(defn doInit []
  "Initialize the grape object")

Implementation Notes

  • Minimal changes: No modifications to existing Lua or JavaScript scripting systems
  • Consistent architecture: Follows the same pattern as existing scripting implementations
  • Error handling: Proper compilation and runtime error reporting with detailed logging
  • Future extensible: Basic framework in place for adding C++ function bindings (getName, getStat, etc.)

Verified Functionality

✅ Janet runtime initialization and cleanup
✅ Global initialization script loading (scripts/Init.janet)
✅ Per-thing script loading (scripts/things/name.janet)
✅ Script compilation and execution
✅ Error handling and logging

The implementation provides a solid foundation for janet-lang scripting in Gauzarbeit, giving developers a third scripting option with Janet's unique functional programming features and excellent C interop capabilities.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits August 20, 2025 11:52
Co-authored-by: vagos <4410494+vagos@users.noreply.github.com>
Co-authored-by: vagos <4410494+vagos@users.noreply.github.com>
Co-authored-by: vagos <4410494+vagos@users.noreply.github.com>
Copilot AI changed the title [WIP] Add scripting support using janet-lang Add janet-lang scripting support Aug 20, 2025
Copilot AI requested a review from vagos August 20, 2025 12:08
@vagos vagos closed this Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants