Skip to content

Instantly share code, notes, and snippets.

@red-001
red-001 / gist:1baaf2a6e64cd75bfe97b05148c46e81
Created April 22, 2017 11:20
list of undocumented CSM functions
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
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 / init.lua
Created May 3, 2017 18:53
no colour
core.register_on_receiving_chat_messages(function(message)
core.display_chat_message(core.strip_colors(message))
return true
end)
@red-001
red-001 / init.lua
Last active May 3, 2017 21:33
test code for #5255
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,
local new_env = {}
for k, v in pairs(_G) do new_env[k] = v end
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