This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Table helpers | |
table_ext= { | |
tablecopy = function(t) | |
return table.copy(t) | |
end, | |
count = function(table) | |
local count = 0 | |
for _ in pairs(table) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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).") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
OlderNewer