View gist:292a2b52ee18b4a92e02599b4b245674
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 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 |
View gist:493937b94dcdcea867b309872325fe61
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 new_env = {} | |
for k, v in pairs(_G) do new_env[k] = v end |
View init.lua
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
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
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
core.register_on_receiving_chat_messages(function(message) | |
core.display_chat_message(core.strip_colors(message)) | |
return true | |
end) |
View gist:5c279faa2f4dfd6fef4fdb4a9a36ba7a
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 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 .. ")" |
View gist:1baaf2a6e64cd75bfe97b05148c46e81
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
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 |