Skip to content

Instantly share code, notes, and snippets.

View octacian's full-sized avatar

Elijah Duffy octacian

View GitHub Profile
@octacian
octacian / lua.md
Last active April 1, 2018 02:45
My thoughts on Lua: what is missing and what should be changed

This documents the features and adjustments that I would personally like to see integrated with Lua, although this amount of tweaking and additions could likely make a project implementing them to be considered an entirely different language. The affect on performance and feasibility of these suggested features should be carefully considered previous to beginning the implementation of any.

Missing Features

@octacian
octacian / near.lua
Created September 3, 2017 14:37
Run a function for every node adjacent to the position provided.
local function for_adjacent_nodes(pos, func, ...)
-- Check that the required parameters (base position and function to execute) are valit
if type(pos) == "table" and func then
-- Define adjacent node positions
local nodes = {
{x=pos.x + 1, y=pos.y, z=pos.z},
{x=pos.x - 1, y=pos.y, z=pos.z},
{x=pos.x, y=pos.y + 1, z=pos.z},
{x=pos.x, y=pos.y - 1, z=pos.z},
{x=pos.x, y=pos.y, z=pos.z + 1},
@octacian
octacian / rebase.txt
Created May 30, 2017 03:19
Basics of git rebase
-- Fetch origin (NOT pull)
git fetch origin
-- Make sure your on the master branch (not required if you already know you are)
git checkout master
-- Rebase
git rebase origin/master
-- If you are alerted to any conflicts, resolve them and run the following 2 commands (no git commit needed)
@octacian
octacian / env.lua
Created January 29, 2017 03:12
digicompute main env functions
-- [function] run code
function digicompute.run_code(code, env)
if code:byte(1) == 27 then
return nil, "Binary code prohibited."
end
local f, msg = loadstring(code)
digicompute.log(dump(f)..", "..dump(msg))
if not f then return false, msg end
setfenv(f, env)
@octacian
octacian / cooking.lua
Created January 13, 2017 21:20
Minetest Cooking Recipe Example
minetest.register_craft({
type = "cooking",
output = "default:bronze_ingot",
recipe = "hammer:hammer",
})
@octacian
octacian / machines.lua
Created January 2, 2017 15:35
ME Chest
-- microexpansion/machines.lua
local chest_formspec =
"size[8,10]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"list[current_name;main;0,0.3;8,4;]" ..
"list[current_player;main;0,5.5;8,1;]" ..
"list[current_player;main;0,6.73;8,3;8]" ..
@octacian
octacian / init.lua
Last active November 9, 2016 15:43
Lua IO Test
-- init.lua
local modpath = minetest.get_modpath("io")
minetest.log("action", modpath)
local f = io.open(modpath)
f:close()