ReDScribe Tutorial
What is ReDScribe?
ReDScribe is a GDExtension plugin that runs Ruby (mruby) inside Godot for writing DSL.
Features:
- 💎 You can execute mruby code (a lightweight Ruby) in Godot and emit signals from mruby to Godot.
- ✏️ You can write and edit Ruby files in the Godot Editor.
- ⬛ You can try out Ruby interactively in Godot.
What is Godot?
Godot is a cross-platform game engine released under the MIT license.
GDScript
GDScript is Godot's built-in scripting language.
extends Node
class_name MyNode
const Foo = 'CONST'
var bar := [1, 2, 3]
func _ready() -> void:
do_something()
func do_something() -> void:
# ...
return true
extends Resource
class_name MyResource
@export var foo : String
var bar : int
func do_something() -> bool:
# ...
return true
Signal
Signals are used to send messages from one game object to another.
# When the Button node's pressed signal is emitted
func _on_button_pressed() -> void:
do_something()
# A custome signal
signal some_signal(val: String)
func _ready() -> void:
some_signal.connect(_on_some_signal)
func do_something() -> void:
# ...
some_signal.emit('foo')
func _on_some_signal(val: String) -> void:
print_debug(val) # output 'foo'
ReDScribe is using signals to bridge between Ruby (mruby) and Godot.
What is Ruby?
Ruby is an object-oriented programming language that has an elegant syntax.
class Game
attr_accessor :score
def initialize
self.score = 0
end
def roll(pins)
# ...
end
end
game = Game.new
20.times { game.roll(1) }
Ruby favors developer freedom over rigid rules.
- Optional
return
- Optional
;
- Optional
()
- Method names can end with
!
or?
- Everything is an Object
- Even built-in class methods can be redefined
- Metaprogramming
module IntegerExt
def days_ago
Date.today - self
end
def !
(1..self).reduce(1){|sum, i| sum *= i }
end
def to_kanji
chars = %w(〇 一 二 三 四 五 六 七 八 九)
to_s.split('').map{|i| chars[i.to_i] }.join
end
def method_missing(name, *args)
"#{to_kanji}#{name}#{args.map(&:to_s).join}"
end
end
Integer.prepend IntegerExt
Date.today # => 2025/7/15
4.days_ago # => 2025/7/11
5.! # => 120
2025.年 7.月 # => '二〇二五年七月'
mruby
mruby is a lightweight implementation of the Ruby language designed for embedding into applications.
ReDScribe runs mruby inside Godot using GDExtension.
What is DSL?
A domain-specific language (DSL) is a programming language or structured text format designed with the vocabulary of a particular domain in mind, with minimal syntactic noise.
Ruby is often used for internal DSLs because its syntax is less noisy.
class Player
def initialize(name)
@name = name
end
def walk
puts "#{@name} walk"
end
def jump
puts "#{@name} jump"
end
end
def player(name, &block)
Player.new(name).instance_exec(&block)
end
require 'player'
player 'Alice' do
3.times { walk }
jump
end
# => Alice walk
# Alice walk
# Alice walk
# Alice jump
This tutorial will guide you through using ReDScribe to build your own domain-specific languages in Ruby, making game programming feel more expressive, personal, and fun.