Skip to content

Instantly share code, notes, and snippets.

/fun.lua Secret

Created Jul 1, 2015
What would you like to do?
fun fun fun!
core.register_chatcommand("fun", {
params = "<count>",
description = "Have fun with entities!",
privs = {}, -- everybody is allowed to have fun!
func = function(name, param)
local count = string.match(param, "(%d+)$")
if not count then
count = 100
count = tonumber(count)
core.log("action", ("player %q is having a great time with %q entities!")
:format(name, count))
local player = core.get_player_by_name(name)
if player == nil then
core.log("error", "Unable to have fun, player is nil")
return false, "Unable to have fun, player is nil"
local p = player:getpos()
p.y = p.y + 1
local item_name = "default:sand"
local log_count = count
while count > 0 do
minetest.spawn_item(p, item_name)
count = count - 1
return true, ("You are having fun with %q pieces of %q!"):format(log_count, item_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment