vocksel / elixir Goto Github PK
View Code? Open in Web Editor NEWA build system that compiles Lua source code into a ROBLOX compatible XML file
License: MIT License
A build system that compiles Lua source code into a ROBLOX compatible XML file
License: MIT License
The current pattern is return\s+.*(\s+)?$
, which will not pick up the following:
return function()
print("Hello, World!")
end
I'm currently looking to implement ModRemote into one of my projects and I discovered that it was not being picked up by the module detection pattern.
This is our current matching pattern:
r"return\s+\S+(\s+)?$"
And this is ModRemote's return statement:
return setmetatable(remote, remoteMetatable)
The problem lies with \S
in the pattern, which matches anything other than a space, tab or newline.
This works for a function without parameters, which is why it initially got committed. But if you're coding with spaces between your parameters, you're going to find that your modules aren't being picked up if you return a function with arguments.
When Elixir comes in contact with a .rbxmx
file in the source directory it should strip away the <roblox>
tag and then merge the rest of the XML with the hierarchy.
local file = assert(io.open("source/Assets/Model.rbxmx")
local content = file:read("*a")
file:close()
content = content:gsub("</?roblox.->", "")
content
now holds the contents of a model without the <roblox>
tags, so it can be easily imported into the model being compiled.
A common practice in ROBLOX is to put ModelScripts inside of other Scripts (even other ModuleScripts) to break up the source code, while still keeping everything modular. This is currently not possible in Elixir because no operating system actually lets you put files inside other files, only folders.
We can use a simple naming convention to determine the file's in-game parent:
src/
Module.lua
Module.Child.lua
Module.Child.AnotherChild.lua
When implemented, the above would compile to the following:
This would require an overhaul of the current compiler but I think it could be worthwhile.
"Beautify" meaning to put each XML tag on its own line, and indenting the lines for easier readability. So instead of the model being condensed onto one line (with only Lua files adding newlines):
<Tag><AnotherTag><ThirdTag>Hello, World!</ThirdTag></AnotherTag></Tag>
Each tag would have its own line, with proper indentation:
<Tag>
<AnotherTag>
<ThirdTag>Hello, World!</ThirdTag>
</AnotherTag>
</Tag>
This would be provided under options.beautify
and set to false by default. This would be a nice optional feature to have for people that want to be able to read their compiled source code.
As it stands, a human would not be able to easily parse the model.
This is happening when using a ModelCompiler
directly. Everything works as intended from the command line. Given a directory structure of:
src/
Modules/
Hello.lua
SayHello.lua
And this build script:
from elixir.compiler import ModelCompiler
compiler = ModelCompiler("src/", "model.rbxmx")
compiler.compile()
This gives us a model whose root directory is a blank string:
NevermoreEngine past b9b5a8 no longer requires a custom processor. It should be marked as legacy in the README.
Right now, Elixir creates a top-level folder when compiling the model.For example, given the following directory structure:
src/
Module.lua
Script.lua
You will get a model with the same contents, unless you set the model_name
argument to change src
to something else. While this does come with the benefit of keeping all your code in a single place, it's also restrictive.
A better approach would be to remove this, and the user can add an extra folder to contain their source code if they really want everything together.
This also ties into recent changes to Nevermore. In its latest update, it was refactored to just manage ModuleScripts and RemoteEvents/RemoteFunctions. It's no longer about being a game framework. This means you shouldn't be grouping your server and client scripts with all of your modules anymore.
Nevermore requires an instance named Nevermore
to exist in game.ServerScriptService
. That's easy enough if we change the name of the top-level Folder (by either renaming it, or using the model_name
parameter), but we are then required to group our server and client code with our modules, which is not ideal..
The module detection works just fine for regular variables, but when trying to return a function the regex does not recognize it. Elixir is then compiling what should be a module to a Script
.
This works fine:
local module = {}
function module.hello()
print("Hello, World!")
end
return module
But this does not, because we're returning a function. The regex matches \w
(alphanumeric characters, plus underscores), which does not pick up parenthesis.
function hello()
print("Hello, World!")
end
return hello()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.