DinoSource - is a full-fledged, open-source, interpreted programming language developed for the Godot Engine.
This language is useful for supporting modding in games, implementation in gameplay where programming is required, the syntax is easily modified, which allows you to easily create your own language syntax, or copy other popular languages, program tools where the programming language is used as a design tool.
- โจ Features
- ๐ Quick start
- ๐ Code examples
- ๐ Integration with Godot
- ๐ค Participation in development
- ๐ Support the project
- Basic Types and Operators
- Functions and Scope
- Classes with Constructors/Destructors
- Arrays and Index Access
| 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, 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 |
- โ 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)
git clone https://github.com/JekSun97/DinoSource.git
cd DinoSource- Launch Godot 4.x
- Open the
IDE.tscnscene
// ๐ฆ 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));
- Click Run in the interface
- See the console output
for (int i = 0; i < 5; i++) {
if (i % 2 == 0) {
print("Even: " + str(i));
} else {
print("Odd: " + str(i));
}
}
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!
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));
๐ Here you can find a large snippet of DinoSource code for study - Test ะกode.
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
# 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) # 5Any contributions are welcome! ๐
- Check it out Issues
- If not, create a new one with:
- ๐ Steps to reproduce
- ๐ป Godot version
- ๐งช Minimal code example
๐ฌ Have an idea? Open Issue or Discussion!
Developing DinoSource is a hobby project, and your support is greatly appreciated! ๐
โ ๏ธ Use at your own risk, the language may have hidden problems that I may not have yet discovered, you can create a topic in the problems section, or contribute a fix. Here you can see a list of upcoming improvements and their priority.
The language was originally developed for a gaming project where most of the gameplay - is programming ๐ป.
