Page 1 of 1

Fighter Game / UglyScript

Posted: Tue Dec 24, 2013 8:59 pm
by qwook
I'm currently working on a fighter game. There's nothing much to say about it other than it's my winter break project.

Here's the editor I made for it. I'm not using LoveFrames, so the GUI is built from the ground up.
Image

I coded it completely in UglyScript, a scripting language that I created.

For a few months I've been working on a scripting language that translates to Lua. I really loved the idea of MoonScript expanding the already powerful Lua with more intuitive syntax. But I wasn't satisfied with MoonScript at all, because it turned out looking like befunge or brainfuck, and even though it did add features to Lua that Lua was missing, MoonScript became way less legible than Lua. So I made my own language called UglyScript with the goal of being legible and intuitive without destroying core features of Lua.

This is an example of UglyScript being translated into Lua.
Image
The file on the right is pretty ugly right?

Features:
  • Syntax inspired heavily by Javascript and C++
  • Blocks and statements are wrapped in {}
  • class and class inheritance. you can use self.super to call super methods.
  • new keyword for creating new instances of a class
  • continue keyword for loops
  • for (local x;x;x++) {} loops
  • $ translates directly into "__" so you can have "jquery"-esque syntax.
  • Self-incrementing/decrementing using var++ or var--
  • Self operations using var+= or var*=
  • Bitwise operators |, &, <<, >> but they're translated into function calls. You have to define the functions yourself.
  • Comments can be created with either // or /* */
  • Tables and Arrays can be defined with either { } or [­ ]
  • Strings can have multiple lines
    • keys in a table can be defined as {key1: "test", key2: "test"}
    • or {key1 = "test"}
    • or {["key1"] = "test"}
  • You can use any word to describe local variables. I use "class names" but you're allowed to use local, var or whatever suits you.
  • You can define functions the same way, void blah () { } or int blah () { } or function blah () { }
    • to define a local function, you need to put "local" in front of the function definition.
    • anonymous functions are also supported.
  • One line blocks. you can do if (blahblah == true) return true; without using curly brackets.
  • The "." operator translates to ":" if being called as a function, otherwise to "."
  • The "::" operator always translates to "." and acts as a namespace operator.
Getting UglyScript to play well with Love2D is quite a pain, and you need a really specific workflow to get it going. Because of that, it will be a while before I release UglyScript.

Re: Fighter Game / UglyScript

Posted: Tue Dec 24, 2013 9:14 pm
by Roland_Yonaba
This sounds awesome. I like the concept.
But I don't think the name should be related the Lua output. Since the syntax is quite pretty, I won't vote for UglyScript.
I see the file extension you chose is '.sun'. Why not calling the language 'sun' ?
That would be quite fun, because Lua already means 'Moon' in portuguese, and it originated from SOL (and DEL), which already meant 'sun', still in portuguese...

Concerning the syntax, even though it looks nice, I don't feel like I am going to use it. Yes, there are some features borrowed from some languages that would be nice to have with Lua. I reckon that. But JS syntax doesn't looks as nice as Lua's, to me. :)
Anyway, keep it going, it looks really nice.

Re: Fighter Game / UglyScript

Posted: Tue Dec 24, 2013 10:06 pm
by Murii
This is really nice i`m looking forward to it!

Re: Fighter Game / UglyScript

Posted: Wed Dec 25, 2013 1:08 am
by Germanunkol
The GUI also looks really nice. Is it built in such a way that it could be shared as a library?
Or is it all written in ugly script - so sharing the .lua files wouldn't be any easy-to-read library?

Re: Fighter Game / UglyScript

Posted: Wed Dec 25, 2013 2:00 am
by qwook
Germanunkol wrote:The GUI also looks really nice. Is it built in such a way that it could be shared as a library?
Or is it all written in ugly script - so sharing the .lua files wouldn't be any easy-to-read library?
It is definitely built modularly, so you can load in the .lua files without having the UglyScript files, but you might be forced into using my class system.

Also, the legacy name was SunScript, but I jokingly called it UglyScript. I might continue calling it UglyScript because of SEO reasons and a domain using UglyScript is easier to find.
Roland_Yonaba wrote:Concerning the syntax, even though it looks nice, I don't feel like I am going to use it. Yes, there are some features borrowed from some languages that would be nice to have with Lua. I reckon that. But JS syntax doesn't looks as nice as Lua's, to me. :)
Anyway, keep it going, it looks really nice.
Really, the only thing borrowed from JS syntax is the ability to use "$". Everything else has been borrowed from C++, and I originally started designing this with the idea of being able to load C++ code into Lua as a form of "hot swapping".