Skip to content

Instantly share code, notes, and snippets.

View HybridDog's full-sized avatar
💭

HybridDog

💭
  • We store your personal data in the United States. See our privacy policy for more information.
View GitHub Profile
minetest.register_node("workbench:3x3", {
description = "WorkBench",
tile_images = {"workbench_3x3_top.png","workbench_3x3_bottom.png","workbench_3x3_side.png"},
paramtype2 = "facedir",
groups = {choppy=2,oddly_breakable_by_hand=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
diff --git a/skins/init.lua b/skins/init.lua
index 8ae6759..b6e59b2 100644
--- a/skins/init.lua
+++ b/skins/init.lua
@@ -27,7 +27,7 @@ dofile(skins.modpath.."/meta.lua")
dofile(skins.modpath.."/players.lua")
skins.update_player_skin = function(player)
- name = player:get_player_name()
+ local name = player:get_player_name()
@HybridDog
HybridDog / make_links.sh
Created July 30, 2015 18:48
a minecraft > minetest texture pack linker, linking is better than copying because its faster and the script only needs to be executed once
@HybridDog
HybridDog / crash_mod_file.lua
Last active August 29, 2015 14:26
error in error handling
local near_player = {x=0, y=0, z=0}
local please_crash = "foo"
minetest.register_node(":default:tmp", {
on_dig = function()
please_crash()
end
})
minetest.after(3, function()
@HybridDog
HybridDog / tnt_mapgen.lua
Created September 24, 2015 17:16
tnt mapgen
local c_air = minetest.get_content_id("air")
local c_tnt = minetest.get_content_id("tnt:tnt")
minetest.register_on_generated(function(minp, maxp)
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local data = vm:get_data()
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
for i in area:iterp(minp, maxp) do
if data[i] ~= c_air then
local function inform_near_players(pos, msg)
for _,player in pairs(minetest.get_objects_inside_radius(pos, 10)) do
if player:is_player() then
minetest.chat_send_player(player:get_player_name(), msg)
end
end
end
function apn(pos, placer, itemstack)
local grop = minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "myuno")
local current_pos
local actual_node_get = minetest.get_node_or_nil
local function temp_node_get(pos, ...)
current_pos = pos
return actual_node_get(pos, ...)
end
local actual_turnon = mesecon.turnon
function mesecon.turnon(...)
@HybridDog
HybridDog / ldecay_speed_test.lua
Last active May 7, 2016 05:44
how often those functions get executed in three seconds
local os_clock = minetest.get_us_time
local TIME = 3*1000000
local function time_sth(fct, ...)
local start = os_clock()
local fin = start
local total = 0
while fin-start < TIME do
fct(...)
total = total + 1
-- maximum distance a protector can have
local MAX_DISTANCE = 10
local function get(tab, pname,z,y,x)
local data = tab[pname]
if data then
local data = tab[z]
if data then
data = data[y]
if data then
local TIME = 0.5
local clock = minetest.get_us_time
local us = TIME * 1000000
local function benchmark_function(fct, ...)
local start = clock()
local fin = start
local total = 0
while fin - start < us do
fct(...)