Skip to content

Instantly share code, notes, and snippets.

View gist:292a2b52ee18b4a92e02599b4b245674
local function run(user_mod_code)
local env = table.copy(_G)
local user_function, message = loadstring(user_mod_code)
if not user_function then return nil, message end
setfenv(user_function, env)
return pcall(user_function)
end
@red-001
red-001 / init.lua
Last active May 3, 2017
test code for #5255
View init.lua
core.register_chatcommand("test_pr", {
func = function(name, _)
local player = core.get_player_by_name(name)
local pos = player:getpos()
pos = {x = math.floor(pos.x+0.5),y=math.floor(pos.y+0.5),z=math.floor(pos.z+0.5)}
print("pos:" .. dump(pos))
print("test1:" .. dump(minetest.find_node_near(pos, 4, "default:water_source", true)))
print("test2:" .. dump(minetest.find_node_near(pos, 4, "default:water_source", false)))
print("test3:" .. dump(minetest.find_node_near(pos, 4, "default:water_source")))
end,
View init.lua
core.register_on_receiving_chat_messages(function(message)
core.display_chat_message(core.strip_colors(message))
return true
end)
View gist:5c279faa2f4dfd6fef4fdb4a9a36ba7a
local ESCAPE_CHAR = string.char(0x1b)
core = {}
function core.get_color_escape_sequence(color)
return ESCAPE_CHAR .. "(c@" .. color .. ")"
end
function core.get_background_escape_sequence(color)
return ESCAPE_CHAR .. "(b@" .. color .. ")"
@red-001
red-001 / gist:1baaf2a6e64cd75bfe97b05148c46e81
Created Apr 22, 2017
list of undocumented CSM functions
View gist:1baaf2a6e64cd75bfe97b05148c46e81
find_node_near
string_to_pos
get_node_level
override_chatcommand
get_day_count
get_mod_storage
get_node_max_level
pos_to_string
splittext
string_to_area