Skip to content

JekSun97/DinoSource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

DinoSource

DinoSource logo

Godot Engine Ko-Fi

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.


๐Ÿ“‹ Table of contents


โœ… Features

  • Basic Types and Operators
  • Functions and Scope
  • Classes with Constructors/Destructors
  • Arrays and Index Access

๐Ÿ”ค 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, 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. Clone the repository

git clone https://github.com/JekSun97/DinoSource.git
cd DinoSource

2. Open in Godot

  • Launch Godot 4.x
  • Open the IDE.tscn scene

3. 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));

4. 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));

๐Ÿ“ƒ Here you can find a large snippet of DinoSource code for study - Test ะกode.


๐Ÿ”Œ 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

๐Ÿค Participation in development

Any contributions are welcome! ๐Ÿ™Œ

๐Ÿ› Found a bug?

  1. Check it out Issues
  2. If not, create a new one with:
    • ๐Ÿ“‹ Steps to reproduce
    • ๐Ÿ’ป Godot version
    • ๐Ÿงช Minimal code example

๐Ÿ’ฌ Have an idea? Open Issue or Discussion!


๐Ÿ’– Support the project

Developing DinoSource is a hobby project, and your support is greatly appreciated! ๐Ÿ™

Ko-Fi


โš ๏ธ 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 ๐Ÿ’ป.

About

๐Ÿฆ– An interpreted programming language for the Godot Engine.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Contributors