Skip to content

Instantly share code, notes, and snippets.

View settingtypes-to-html.py
#!/usr/bin/env python3
import os
class Section:
def __init__(self, name):
self.name = name
self.entries = []
self.sections = []
class Entry:
View clap-ioob-crash.log
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
View clap-ioob-crash.rs
#[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."))
View Security_rant.md

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()
View iterCube.lua
--- 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
View tablecopy.lua
-- "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)
View gist:9194308
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 5536d0b..105843b 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1305,8 +1305,7 @@ minetest.get_player_ip(name) -> IP address string
Chat:
minetest.chat_send_all(text)
-minetest.chat_send_player(name, text, prepend)
-^ prepend: optional, if it is set to false "Server -!- " will not be prepended to the message
View gist:8089636
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
View gist:8061302
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 Dec 28, 2015
Minetest serverlist to YAML
View gist:7459124
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()