DEV Community

Kartik Patel
Kartik Patel

Posted on

Introduction to MSRL Web

Introduction to MiniScript and Raylib

Miniscript

MiniScript is a modern, elegant, and beginner-friendly programming language that’s surprisingly powerful yet simple. In many ways, it’s even easier to learn than Python or Lua.

It’s mostly used in game development, especially in environments and frameworks like Mini Micro (a retro-style coding sandbox) and Soda, which use MiniScript as their main scripting language.

What makes MiniScript stand out is its readable syntax, lightweight runtime, and ease of embedding — perfect for devs who want to add scripting support to their own games or tools without dragging in a massive dependency.

I have published many tutorials on MiniScript and Mini Micro. If you are interested, I suggest checking them out [Links at the end of the blog]

Raylib

On the other hand, we have Raylib, A simple and easy-to-use library that makes Game development fun than it ever was. Instead of bloating you in heavy UI, raylib lets you connect with the code itself.

Basically made for people who just wanna make games without wrestling with complicated engine setups...Like Me

Although I haven't published any blogs or videos on Raylib till now (Planning to upload soon), I suggest you check out a short video tutorial on FreeCodeCamp, which would give you a quite good understanding of Raylib in a Short Time. [The mentioned tutorial is for Raylib-C, which is not in the scope of today's blog.]

Combining Both

Together, MiniScript and Raylib make a killer combo — you can build games using Raylib’s rendering and system tools, while scripting logic and behavior in MiniScript.

Now, there are multiple ways to get MiniScript and Raylib working together, but today we are going to take a closer look at MSRL-Web, an attempt by @joestrout to make this Connection easier to use.

What is MSRL-Web??

MSRL-Web is basically a Raylib Binding to create 2D games and interactive graphics using MiniScript as a programming language.

Now this whole definition sounds very scary....It appears that it might be the hardest piece of tech to set up.

And actually, the reality is totally different, all you need is

  • Latest Release of MSRL-Web. DOWNLOAD HERE
  • A Code Editor (Even the inbuilt Notes Editor works)
  • A programming language that can handle HTTP requests

More in the 3rd requirement basically means you need a programming language that can connect your directory to the Web using a localhost port. In the official GitHub repo of MSRL-Web, they have suggested and indicated to use Python due to its simplicity, but personally, I use a compiled GO application, which starts a local server when opened using the MSRL-Web directory.

If you are confused about what to use, just pick up the Python path

  • If you have Python installed on your device
  • And you are comfortable with Python

Otherwise, you can use any programming language. Like I use GO.

Here is the Go program I use. Now I can just do go build server.go and use the exe every time.

package main

import (
    "fmt"
    "log"
    "net/http"
    "os/exec"
    "runtime"
    "time"
)

const port = "8000" 
const url = "http://localhost:" + port

func openBrowser(url string) {
    var err error

    switch runtime.GOOS {
    case "linux":
        err = exec.Command("xdg-open", url).Start()
    case "windows":
        err = exec.Command("cmd", "/c", "start", url).Start()
    case "darwin":
        err = exec.Command("open", url).Start()
    default:
        err = fmt.Errorf("unsupported platform: %s", runtime.GOOS)
    }

    if err != nil {
        fmt.Printf("Could not automatically launch browser. Please open %s manually. Error: %v\n", url, err)
    } else {
        fmt.Printf("Browser opened to %s\n", url)
    }
}

func main() {
    fs := http.FileServer(http.Dir("."))
    http.Handle("/", fs)

    go func() {
        time.Sleep(500 * time.Millisecond) 
        openBrowser(url)
    }()

    fmt.Printf("Server started! Access at %s\n", url)
    log.Fatal(http.ListenAndServe(":"+port, nil))
}
Enter fullscreen mode Exit fullscreen mode

For Python users, just run this command inside the MSRL-Web Folderpython3 -m http.server 8000

Inside the Folder

After downloading your MSRL-Web folder should look like this:

By Default, there wouldn't be any server.go and server.exe; it's built by me to run the server. It's only for the GO users discussed above

In most cases, you have no work with all these files, other than the ASSETS folder, which is the main workspace folder for you.

As of VERSION 0.2.0, your assets folder would seem like this:

The library folder has all the built-in libraries, which can be used using the import keyword.

Main.ms is the file that runs first in every program. This is where you code.

If you currently run a server, you would see something like this

Here you can clearly see a window that plays the Demo code [The default code in the Main.ms] and Console, which prints basic output, errors, and other things directed by Main.ms.

Now keep on playing with code, changing texture, trying out different things, and get familiar with this workspace and wait for my next blog, where I talk, teach, and chat....

Extras

  • Another way of running a local server without Python and Go is Redbean... It's also mentioned officially, although I am not much familiar with it.

LINKS

MINISCRIPT

MSRL-Web
Miniscript
Mini Micro
Miniscript Youtube Tutorials

RAYLIB

Raylib
FreeCodeCamp Course

SELF-PROMO

Youtube
Discord

Top comments (0)