In Lua.
A classic.
-- Set boolean metatable | |
debug.setmetatable(false, { | |
__add = function(a, b) | |
if b == nil then | |
return b + a | |
end | |
return a or b | |
end, | |
__mul = function(a, b) | |
if b == nil then |
crosshair = {} | |
function crosshair:set_meta(meta) | |
return setmetatable(self, {__index = function(self, index) | |
if crosshair[index] ~= nil then | |
return crosshair[index] | |
end | |
if meta[index] ~= nil then | |
return meta[index] | |
end |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.util.function.BiFunction; | |
import java.util.concurrent.ThreadLocalRandom; | |
import java.util.function.BiConsumer; | |
import java.util.function.Function; | |
import java.util.function.Supplier; | |
/** |
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).") |
-- 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 |
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"], |
-- 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 { |
-- Table helpers | |
table_ext= { | |
tablecopy = function(t) | |
return table.copy(t) | |
end, | |
count = function(table) | |
local count = 0 | |
for _ in pairs(table) do |
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") |