Skip to content

tkmfujise/ReDScribe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

214 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

logo

ReDScribe

Let’s re-describe your code as your own friendly domain-specific language.

Features:

  • Execution: You can execute mruby code (a lightweight Ruby) in Godot and emit signals from mruby to Godot.
  • Editing: You can write and edit Ruby files in the Godot Editor.
  • REPL: You can try out Ruby interactively in Godot.

Usage

extends Node

@onready var res := ReDScribe.new()

func _ready() -> void:
    res.method_missing.connect(_method_missing)
    res.channel.connect(_subscribe)
    res.perform("""

        Alice says: "Hello Ruby! ❀️"

        puts "Welcome to the world of Ruby v#{RUBY_VERSION}, powered by #{RUBY_ENGINE} πŸ’Ž"

        Godot.emit_signal :spawn, { name: 'Alice', job: 'wizard', level: 1 }

    """)

func _method_missing(method_name: String, args: Array) -> void:
    print_debug('[method_missing] ', method_name, ': ', args)

func _subscribe(key: StringName, payload: Variant) -> void:
    print_debug('[subscribe] ', key, ': ', payload)


# -- Output --
#
#   [method_missing] Alice: [{ &"says": "Hello Ruby! ❀️" }]
#
#   Welcome to the world of Ruby v3.4, powered by mruby πŸ’Ž
#
#   [subscribe] spawn: { &"name": "Alice", &"job": "wizard", &"level": 1 }
#

Architecture

architecture

Definitions

  • Properties
    • String boot_file
    • String exception
  • Methods
    • void set_boot_file(path: String)
    • void perform(dsl: String)
  • Signals
    • channel(key: StringName, payload: Variant)
    • method_missing(method_name: String, args: Array)

Built-in mruby methods

mruby description
require 'path/to/file' loads res://path/to/file.rb file.
puts 'something' prints something to the Output panel in Godot.
Object#method_missing emits method_missing signal.
(method_name: String, args: Array)
Godot.emit_signal(key, payload) emits channel signal.
(key: StringName, payload: Variant)
Godot::VERSION Godot version

Type conversions

mruby GDScript
true β‡’ true
false β‡’ false
nil β‡’ null
Float β‡’ float
Integer β‡’ int
Symbol β‡’ StringName
String β‡’ String
Hash β‡’ Dictionary
Array β‡’ Array
Range β‡’ Array
Time β‡’ Dictionary
(others) β‡’ String
(#inspect called)

see: demo/test/gdextension/test_variant.gd

Installation

  1. Download the addons.tar.gz from the release.
  2. Extract the addons.tar.gz and place the redscribe directory into (Your godot project root)/addons directory.
  3. Open the project settings and enable ReDScribe.

Screenshots

Editor

EditorArea screenshot

Note

For @ and :, syntax highlighting requires a following whitespace to work correctly.

REPL

REPL screenshot

Caution

In the REPL, local variables are undefined in the next input.

addons/redscribe/mrblib

I have created some libraries. If you'd like to use them, add require 'addons/redscribe/mrblib/xxx' at the top of your script.

see more: doc/addons/mrblib.md

Examples

1. Live coding

Live coding

see more: doc/examples/1_live_coding.md

2. Resource generator

Resource generator

see more: doc/examples/2_resource_generator.md

3. Actor (like Agent-based model)

Actor

see more: doc/examples/3_actor.md

4. Dialog controller (Coroutine)

Coroutine

see more: doc/examples/4_coroutine.md

Documentation

English : https://tkmfujise.github.io/redscribe-docs

ζ—₯本θͺž : https://tkmfujise.github.io/redscribe-docs/ja

Development

build

After installing the required packages, run the following command.

$ rake

see: Rakefile

Roadmap

v0.1.0

  • method_missing signal
  • channel signal
  • Godot module
  • puts
  • boot.rb
  • require
  • Editor
  • REPL
  • compile
    • debug/release
    • windows
    • mac
  • Document
    • doc/*.adoc
    • README
    • Godot help
  • Demo
    • Example0: Basic
    • Example1: Live Coding
    • Example2: Resource generator
    • Example3: Actor
    • Example4: Coroutine

v0.2.0 or later

  • Document
    • Wiki
  • Editor
    • Support multiple files open
    • Support search text
    • Code completion
    • Snippet
      • require
    • User definable theme
    • User definable syntax
  • REPL
    • boot_file enabled
  • mrblib
    • core_ext like ActiveSupport
      • Duration (e.g. 1.day.ago)
  • src/*.cpp
    • Regexp support (call Godot RegEx)
    • remove global variables
  • fix bugs
    • .rb files cannot be displayed on the first launch.
  • compile
    • use github workflow
    • target
      • windows.x86_64
      • windows.x86_32
      • macos
      • linux.x86_64
      • linux.arm64
      • linux.rv64
      • android.x86_64
      • android.arm64
      • ios