Skip to content

Instantly share code, notes, and snippets.

/fun.lua Secret

Created July 1, 2015 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c496631346b028d0852f to your computer and use it in GitHub Desktop.
Save anonymous/c496631346b028d0852f to your computer and use it in GitHub Desktop.
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