-
-
Save anonymous/c496631346b028d0852f to your computer and use it in GitHub Desktop.
fun fun fun!
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("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