DEV Community

Kartik Patel
Kartik Patel

Posted on

Learn Miniscript in Y Minutes

INTRO

A while ago, I had this galaxy–brain idea:

“Yo, why don’t I contribute a MiniScript article to Learn X in Y Minutes? That would be kinda cool.”

So, like the overconfident developer-student hybrid I am, I opened the LearnXInYMinutes repo, checked their docs, and saw the instructions:

“Just pick any existing language article and use it as a reference.”

Cool. Easy. No big deal.

Obviously, I picked the GDScript article because Godot supremacy 🛐
And then I started writing. And writing. AND WRITING.

I went full speedrun mode — forked the repo, made my own file, wrote the entire MiniScript version like a proud dev contributing to humanity.

Then I tried saving the file as:

miniscript.md

And boom.

ERROR.

File exists.
I was like, wait a minute....

That’s when I realised the most painful plot twist:

The MiniScript article was ALREADY DONE.
And written by THE CREATORS THEMSELVES.

😭😭😭

Bro, I felt like I spent 3 hours reinventing the wheel just to discover Ferrari already made it.

But honestly?
I learned a LOT by writing my version — syntax, structure, formatting, left-right-center.
So instead of crying in a corner, I decided:

Why not just upload my version here?
It’s bad. It’s weak. But it’s mine 🔥

So… enjoy my totally-not-official, definitely-not-perfect MiniScript “Learn X in Y Minutes” clone.

MiniScript is a modern, elegant, and easy-to-learn scripting language designed to be embedded in other applications. It's free, open-source, and has been under continuous development since 2016. You can use MiniScript in standalone tools like Mini Micro and Soda for game development. Thanks to community plugins, it also integrates with popular engines like Godot, Unity, Raylib, and MonoGame. With a clean syntax reminiscent of Python and Lua, its main advantages are ease of use and tight engine integration. This makes it a perfect choice for developers just starting their game development journey. ## Basics
Miniscript
// Single-line comments are written using slash symbol.

//Variables decelration
i = 8 //Integer
f = 1.2 //Float
b = true //Bool
s = "Hello, World!" //String
l = [1, false, "Dev"] // List - similar to Python,
// it can hold different types
// of variables at once.

m = {1:"one", 2:"two", 3:"three"}
// Map holds key-value pairs.

// Functions
foo = function()
end function //Must end with end function

add = function(first, second) //takes 2 parameters
    return first + second    // return keyword
    //returns any value
    //back to function call
end function

// Increases the Score
score = 0
score += 1
//Decrease the score
score -= 1
// Opperators such as *=, /= and %= can be also used
// These operators is just shorthand of
// score = score + 1

// Printing values
printing = function()
    print "I " + "love " + "Miniscript " + 2 //Miniscript
    //Allows mix of Data types
end function
//Prininting mutliple data types at onceis totally
//doable in Miniscript
//Pranthese can be used in function but its not the
//Intended way Miniscript should be coded
//Instead you can do the most in Minsicript
//without Prathese, expect some scenarios

// Math
doing_math = function()
    first = 8
    second = 4
    print first + second // 12
    print first - second // 4
    print first * second // 32
    print first / second // 2
    print first % second // 0
    print first ^ second // 4096
end function

//Comparison
compare = function()
    print 5 == 5// true  - equal to
    print 5 != 3// true  - not equal to
    print 5 > 3 // true  - greater than
    print 5 < 10// true  - less than
    print 5 >= 5// true  - greater than or equal to
    print 5 <= 4 // false - less than or equal to
    print "apple" == "apple"// true
    print "apple" != "banana"// true
    print "apple" < "banana"// true ("apple" comes first)
    print "zebra" > "apple"// true ("zebra" comes after)
end function

// Control flow
control_flow = function()
    x = 3
    y = 8.2
    y = 2 // y was originally a float,
    // but we can change its type to int
    // using the power of dynamic typing!

    if x < y then //then keyword is required
        print "x is smaller than y"
    else if x > y then
        print "x is bigger than y"
    else
        print "x and y are equal"
    end if //end if keyword is must

    if not x == y then print "X and Y are not same"
    //This is short if-else block, In this
    //end if block can be skipped
    a = true
    b = false
    c = false
    if a and b or not c then
        //And returns true
        //When all values
        //are true
        //Or returns true
        //When one of
        //The value is
        //true
        print "This is true!"
    end if

    for i in range(0, 20)
        print i //Prints from 0 to 20
    end for

    for i in ["two", 3, 1.0]
        print i //Prints the array
    end for

    x = 12
    y = 1

    while x > y
        print y
        y += 1
    end while

    x = 2
    y = 10
    while x > y
        print y
        y += 1
        if y == 7 then break
        //Break keyword exits the loop
    end while
    //end while ends a while block
    //Simmilairy end for ends a
    //for block
    //Same refers to a function
    //block and if-else block
end function
Enter fullscreen mode Exit fullscreen mode

Further Reading

Top comments (0)