-
-
Save usysrc/acadfa415919c95200bc79ca7dbbe0bb to your computer and use it in GitHub Desktop.
LuaForkWishes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Better Lua | |
-- my wishes for a Lua fork or patches for gamedev | |
-- vars are local scope by default | |
function defineVars() | |
a = 1 | |
end | |
print(a) -- prints nil | |
-- define globals | |
global a = 1 | |
-- concise operators / Compound assignment statements | |
a += 1 | |
a -= 1 | |
a *= 1 | |
a /= 1 | |
-- better table insert/removal and iterators | |
items = {} | |
item = "sword" | |
add(items, item) | |
del(items, item) | |
-- can be used while iterating | |
for item in all(items) do | |
del(items, item) | |
end | |
-- add/delete by key/index or object and be iteration-safe | |
del(items, item) | |
del(items, 1) | |
add(items, item, 1) | |
-- function keyword shorthand alias | |
makenewthing = function() | |
return fn() | |
-- especially good for anonymous functions | |
end | |
end | |
-- better require (like require in nodejs) | |
require "mathUtils" -- looks first in local package folder not in project top level | |
-- no more (...):match("^(.+)%.[^%.]+") matching for finding the package folder |
something like add(items, item, 1) similar to table.insert(items, 1, item)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example to add by index?