Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import os
class Section:
def __init__(self, name):
self.name = name
self.entries = []
self.sections = []
class Entry:
#[macro_use] extern crate clap;
fn main() {
clap_app!( myapp =>
(@group output =>
(@attributes +multiple +required)
(@arg out: -o --out <PATH> requires("media_transfer")
"Directory to output media files and index. \
If --index is passed the index be written there instead of here.")
(@arg index: --index <PATH> "Path to the index file to output."))
DEBUG:clap:Parser::propogate_settings;
DEBUG:clap:Parser::get_matches_with;
DEBUG:clap:Parser::create_help_and_version;
DEBUG:clap:Parser::create_help_and_version: Building --help
DEBUG:clap:Parser::create_help_and_version: Building --version
DEBUG:clap:Parser::get_matches_with: Begin parsing '"-o"' ([45, 111])
DEBUG:clap:Parser::is_new_arg: arg="-o", Needs Val of=None
DEBUG:clap:Parser::is_new_arg: Does arg allow leading hyphen...false
DEBUG:clap:Parser::is_new_arg: Starts new arg...-
DEBUG:clap:Parser::is_new_arg: Starts new arg...true

Ideally we'd just keep each mod in a separate lua_State and make mods pass data amongst themselves through a Minetest API. This would improve security and probably make mod-level multithreading easier, but it would break just about all mods. Without this we're limited to a "best guess" as to what mod is running. During init time this guess is fairly accurate, but after init time it's a mess.

For example, even at init time I think the following sandbox escape is possible (although I haven't actually tested it):

minetest.conf:
    secure.trusted_mods = trusted
mods/trusted/depends.txt
    untrusted
mods/trusted/init.lua:
 untrusted()
diff --git a/mods/bucket/init.lua b/mods/bucket/init.lua
index 3751cfe..eeff992 100644
--- a/mods/bucket/init.lua
+++ b/mods/bucket/init.lua
@@ -58,17 +58,18 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
return
end
+ local node = minetest.get_node_or_nil(pointed_thing.under)
+ local ndef
diff --git a/wrench/init.lua b/wrench/init.lua
index 214544c..f127c15 100644
--- a/wrench/init.lua
+++ b/wrench/init.lua
@@ -1,286 +1,60 @@
--[[
- Wrench mod
- Adds a wrench that allows the player to pickup nodes that contain an inventory with items or metadata that needs perserving.
- The wrench has the same tool capability as the normal hand.
- To pickup a node simply right click on it. If the node contains a formspec, you will need to shift+right click instead.
@ShadowNinja
ShadowNinja / gist:7459124
Last active December 28, 2015 06:39
Minetest serverlist to YAML
import json, yaml, urllib.request, io
io.open("yamllist.txt","w").write(
yaml.dump(
json.loads(
urllib.request.urlopen("http://servers.minetest.net/list")
.read().decode("utf-8")
)
)
).close()
@ShadowNinja
ShadowNinja / gist:6833004
Created October 4, 2013 21:23
Particle tables
diff --git a/builtin/deprecated.lua b/builtin/deprecated.lua
index 333f64c..4251549 100644
--- a/builtin/deprecated.lua
+++ b/builtin/deprecated.lua
@@ -46,3 +46,64 @@ setmetatable(minetest.env, {
return rawget(table, key)
end
})
+
+--
--- Iterator over positions of a cube.
-- @param pos Reference to starting position (lowest x, y, and z coordinates). Note that this is overwritten.
-- @param size Size of the cube
local function iterCube(pos, size)
local startx, starty = pos.x, pos.y
local endx, endy, endz = pos.x + size, pos.y + size, pos.z + size
pos.x = pos.x - 1
return function()
if pos.x < endx then
pos.x = pos.x + 1
-- "copies" is an internal parameter
function table:deepcopy(copies)
if type(self) ~= "table" then
return self
end
local t = {}
copies = copies or {}
copies[self] = t
for k, v in pairs(self) do
t[copies[k] or table.deepcopy(k, copies)] = copies[v] or table.deepcopy(v, copies)