Skip to content

Instantly share code, notes, and snippets.

@usysrc
Last active August 26, 2016 13:27
Show Gist options
  • Save usysrc/acadfa415919c95200bc79ca7dbbe0bb to your computer and use it in GitHub Desktop.
Save usysrc/acadfa415919c95200bc79ca7dbbe0bb to your computer and use it in GitHub Desktop.
LuaForkWishes
-- 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
@moechofe
Copy link

example to add by index?

@usysrc
Copy link
Author

usysrc commented Aug 26, 2016

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