NIL isn't Lua


(Posted 2 months ago) tricky

This is not an official Blitz project, but since BlitzMax has support for Lua scripting, this can be interesting for the Blitz community anyway.

The Star Story game I showed earlier does use an engine written in BlitzMax, but scenarios and spells and many more things have been scripted in Lua. Something I hate about Lua is that everything never declared or defined is just a 'nil' value (I always used "strict" mode in BlitzMax for a reason), Lua also does not have class support, switch support and some other things, so here goes my extension to Lua, and yes, the Lua engine within BlitzMax should (although I've not yet tested it, since my main focus is now C#) support it.

NIL is a language on its own, written in pure Lua code, and will real-time translate its code to Lua. Fun part, functions and variables defined in Lua will be recognized by NIL and vice versa. To put it even stronger, NIL has class support and classes defined in NIL can be used easily in Lua

void Hello()
    print("Hello World")
end

Hello()

Will translate to:

function Hello()
    print("Hello World")
end

Hello()

Setting up NIL in BlitzMax! Should be easy. There are multiple ways to do it, but I'll go for the simplest method now:

  1. Copy NIL.lua into your Blitz project --> https://github.com/jpbubble/NIL-isn-t-Lua
  2. Create a file named "MyScript.nil" and write your NIL script in there.
  3. Create a "start.lua" file and put in the next two commands in it:
      NIL = require "NIL"
            NIL.Use("MyScript.nil")

    Well, now NIL should be working in your BlitzMax project. APIs for NIL to use can just be done the same way as you can do with normal Lua, no matter if you use brl.maxlua or pub.lua, or well, whatever you can think off, it should all work. Is NIL better than Lua? That depends on how you wanna script. For my own needs NIL fills some voids Lua has... Other than that everybody should decide for themselves what is better. NIL is currently still in prototype stage, so you should keep that in mind in your expectations of it, and as I am putting NIL to the test now in a very big project, I'm still fixing stuff or expanding the language as things go. ;)

(Posted 2 months ago) RonTek commented:

This is great stuff Tricky, thanks for sharing!

Have you also thought about proposing your changes to the Lua community?

(Posted 2 months ago) tricky commented:

Perhaps I should, shouldn't I? Not sure if Lua itself should be changed, though, it's simplicity is great for scripting small addons, but if you have large stuff scripted in it, then NIL can be an option... I've been in a few communities regarding Lua, and let's suffice to say I'm glad I'm no longer there.... Then again, there are more programming communities like that (unfortunately).... But at least, thanks for your support...

Now my wiki is a bit straight to the point... Perhaps I should first write a beginner's tutorial for it. ;)

(Posted 2 months ago) RonTek commented:

I think this is great and if something like this makes stuff more easier then it should not be ignored, perhaps make it as a plugin instead if the language supports it?

Anyways, keep it up as you are into something here and a beginner's guide should help more.

(Posted 2 months ago) tricky commented:

Well yeah, NIL already works as a kind of plug in, and I chose this path in order to make any Lua based interpreter (using Lua 5.1 or later). In preparation for my tutorial I did release QuickNIL, a program written in C#, that automatically imports NIL in Lua, therefore allowing you to easily prototype NIL scripts in order to learn the language (it also supports pure Lua code, which is only natural since NIL itself was written in Lua). I was a bit inspired by how TypeScript enhances JavaScript. And this is a (not yet really playable) RPG game I'm trying to create with NIL as scripting language in order to put the language to the test. I tell ya, many bugs in NIL that I already fixed, were only discovered thanks to that project.

When it comes to the tutorial itself, I'm looking to find an easy way to set them up and also attach a comment section to each lesson, so I can answer questions about the language, easily (and without costs, as er.. I'm poor).

Anyway thanks for your encouraging talk. I've been in a miserable state the last few weeks, so I could use to peptalk (not just about NIL, but in general).

(Posted 1 month ago) RonTek commented:

Sure thing, but that is still awesome. I actually prefer coffeescript over typescript, but it seems TS is now making waves.

(Posted 1 month ago) tricky commented:

I've tried neither to be honest, as I've always been more on server side scripting (in php) than client side. Although I've had a few weeks of JavaScript training by a professional programmer, and there I was also introduced to the idea behind TypeScript and so the first ideas for NIL were born during that training, and well that is now coming to fruition I suppose. As long as I don't have a good way to set up a site, I've decided to set at least something up in OpenOffice, and I've posted what I got so far here. This guide for NIL has been set up for the absolute beginner in coding in general, but hey, the experienced coder can already see how NIL works in there. Loops are planned as my next move for that guide, and after that the stuff that Lua really doesn't support (normally) like the usage of classes, groups, casing, quickmeta and macros. Not necesarily in that order. 😉😎

(Posted 1 month ago) RonTek commented:

good to know. I don't mind both PHP and JS as I have gotten used to it over the years doing web stuff.

hey, that's another step with your guide and perhaps you can add example sources like what they do on most pdf coding ebooks.

(Posted 1 month ago) tricky commented:

hey, that's another step with your guide and perhaps you can add example sources like what they do on most pdf coding ebooks.

There are already some of those. For starters the assignments in my book want you to write some code, but in the appendixes, you can see I did those assignments myself as well showing you my code. :) Not to mention that I already used some code to explain things in general. But maybe I should add a few actual programs and a few small silly games, to demonstrate the language even more, eh?

(Posted 1 month ago) RonTek commented:

That's awesome! You can also add tags to you topic so this post will be added under toolbox and will be easy to find as a BlitzMax resource if you like. the guide is on top of this page

(Posted 1 month ago) tricky commented:

Just to let you know NIL now got its own homepage, Discord server, and Forum.

(Posted 1 month ago) RonTek commented:

Just to let you know NIL now got its own homepage, Discord server, and Forum.

That's awesome.

Reply To Topic

Please log in to reply