Skip to content

Instantly share code, notes, and snippets.

/fun.lua Secret
Created Jul 1, 2015

Embed
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
else
count = tonumber(count)
end
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"
end
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
end
return true, ("You are having fun with %q pieces of %q!"):format(log_count, item_name)
end,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.