Skip to content

Instantly share code, notes, and snippets.

Avatar
💡
Developing

Lars Müller appgurueu

💡
Developing
View GitHub Profile
@appgurueu
appgurueu / init.lua
Last active Mar 9, 2022
Shuts down the server if it lags too much ("antilag" Minetest mod init.lua)
View init.lua
local min_lag = 1 -- in seconds
local min_times = 10 -- has to occur 10x
local times = 0
minetest.register_globalstep(function(lag)
if lag < min_lag then
times = 0
else
times = times + 1
if times >= min_times then
minetest.request_shutdown("Server shutting down due to high latency (lag).")
@appgurueu
appgurueu / default_bones.lua
Last active Mar 9, 2022
Gets default bone positions from glTF files (for Minetest)
View default_bones.lua
-- helper function
local function quaternion_to_rotation(q)
local rotation = {}
local sinr_cosp = 2 * (q[4] * q[1] + q[2] * q[3])
local cosr_cosp = 1 - 2 * (q[1] * q[1] + q[2] * q[2])
rotation.x = math.atan2(sinr_cosp, cosr_cosp)
local sinp = 2 * (q[4] * q[2] - q[3] * q[1])
if sinp <= -1 then
@appgurueu
appgurueu / markdown_to_bbcode.js
Created Apr 7, 2020
Converts Markdown to BBCode
View markdown_to_bbcode.js
const md = require('mark-twain');
const parse5 = require('parse5');
tags = {
"strong": "b",
"em": "i",
"u": "u",
"code": "icode",
"h1": ["h", "b"],
"h2": ["size=150", "color=#115098"],
@appgurueu
appgurueu / init.lua
Created Mar 7, 2020
Minetest Waypoint Testmod
View init.lua
-- Use this to test waypoint capabilities
minetest.register_chatcommand(
"test_waypoints",
{
description = "tests waypoint capabilities",
func = function(name)
local player = minetest.get_player_by_name(name)
minetest.chat_send_all(
"regular: " ..
player:hud_add {
@appgurueu
appgurueu / init.lua
Last active Mar 9, 2022
modlib - init.lua - template
View init.lua
-- Table helpers
table_ext= {
tablecopy = function(t)
return table.copy(t)
end,
count = function(table)
local count = 0
for _ in pairs(table) do
@appgurueu
appgurueu / generate_bg.py
Last active Oct 6, 2018
Generate MT Background for Website Python Script
View generate_bg.py
import PIL
import random
from PIL import Image
size=(60,40)
dirtlevel=3*16
gravellevel=5*16
dirt=Image.open("default_dirt.png")
gravel=Image.open("default_gravel.png")
@appgurueu
appgurueu / PHPExample.php
Created Aug 17, 2018
Small PHP Example, WTFPL
View PHPExample.php
<!doctype html>
<!-- Template for lua_api.html -->
<html lang="en">
<body data-spy="scroll" data-target="#contenttable" data-offset="15" style="background: url('background.png') no-repeat center center fixed;background-size: 100% 100%;background-repeat: no-repeat;image-rendering:optimizeSpeed">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Example">
<meta name="author" content="Lars Müller">