Description
Changelog
Reviews (0)
DinoSource
DinoSource - is a full-fledged, open-source, interpreted programming language developed for the Godot Engine, written in pure GDScript!
This language is useful for supporting modding in games, implementing gameplay where programming is required (for example, programming robots or spaceships in a game), its syntax is easily modified, making it easy to create your own syntax or copy the syntax of other popular languages, and is also suitable for tool development where the programming language is used as a design tool.
✅ Features
- Basic Types and Operators
- Functions and Scope
- Classes with Constructors/Destructors
- Arrays and Index Access
- DinoSource Node Component (DSNC): is a specialized system for processing DinoSource code across multiple nodes, storing its data and methods individually and creating a bridge between other objects for communication
🔤 Language
| Category | Support |
|---|---|
| Comments | // one-line, /* */ multi-line |
| Data types | int, float, bool, string, var (dynamic), void |
| Constants | const type NAME = value |
| Arrays | One-dimensional [1,2,3] and multidimensional [[1,2][3,4]] |
| Operators | + - * / % (arithmetic), && || ! (logics) |
| Enum | Named constants enum Status { Idle, Running = 32, Jump = 4 } |
| Functions | With return types, parameters, recursion |
| Classes | Fields, methods, Inheritance, constructors ClassName(), destructors ~ClassName() |
| Conditions | if/else, switch/case/default |
| Cycles | for, while, repeat(n), jump/POINT |
| Control | return, break, continue, delete |
| Library | include Path/SourceCode, a basic Math library written in DinoSource |
🔧 Integration
- ✅ GDScript → DinoSource: Registering native functions and variables to call GDScript inside DinoSource
- ✅ DinoSource → GDScript: Calling functions and accessing DinoSource data within GDScript
- ✅ Cross-platform: Works everywhere Godot Engine works (Windows, Linux, macOS, Web, Mobile)
🚀 Quick start
1. Open in Godot
- Launch Godot 4.x
- Open the
IDE.tscnscene
2. Write your first script
// 🦖 Hello DinoSource!
print("Hello World!");
int x = 10;
float y = 3.14;
string msg = "DinoSource is working!";
print(msg + " x=" + str(x) + ", y=" + str(y));
3. Launch! 🎮
- Click Run in the interface
- See the console output
📚 Code examples
🔁 Cycles and conditions
for (int i = 0; i < 5; i++) {
if (i % 2 == 0) {
print("Even: " + str(i));
} else {
print("Odd: " + str(i));
}
}
🏗️ Classes with a constructor and destructor
class Player {
string name;
int health = 100;
// Constructor
void Player(string n) {
this.name = n;
print("Player " + this.name + " created!");
}
// Destructor
void ~Player() {
print("Player " + this.name + " deleted");
}
void takeDamage(int dmg) {
this.health = this.health - dmg;
if (this.health <= 0) {
print(this.name + " died!");
}
}
}
// Usage
Player hero = new Player("Artyom");
hero.takeDamage(30);
delete hero; // The destructor will be called!
📦 Arrays and functions
var array = [10, 20, "Hi!", false];
string check(var _arr) {
string _text = "\n";
for (int i = 0; i < _arr.size(); i++) {
_text = _text + "arr[" + str(i) + "] = " + str(_arr[i]) + "\n";
}
return _text;
}
print("arr: " + check(array));
🔌 Integration with Godot
Registering a native function (GDScript → DinoSource)
func _ready():
var interpreter = DSInterpreter.new()
# Register the "godot_log" function to be called from DinoSource
interpreter.registerNativeFunc("godot_log", _godot_log)
func _godot_log(args: Array):
if args.size() > 0:
print("[DinoSource] " + str(args[0]))
return 1
// In the DinoSource code:
godot_log("Greetings from DinoSource!"); // Calls a GDScript function
// Return 1 from GDScript
Calling the DinoSource script from GDScript
# Running the code
var ast = parser.parse(lexer.LexerRun("int nmb = 16; print('Hello'); int DinoFunc(int a, int b) {return a+b;}"))
interpreter.run(ast)
# Getting a variable
var nmb = interpreter.getGlobalVar("nmb")
# Function call
var ret = interpreter.callFunc("DinoFunc", [4, 1])
print(ret) # 5
Changelog for version v0.93
No changelog provided for this version.