diff options
author | Kahrl <kahrl@gmx.net> | 2014-08-23 00:52:57 +0200 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2014-08-23 00:52:57 +0200 |
commit | 26f4a5c1109f99fed6d7941b870a94fa49642181 (patch) | |
tree | dbd72d8931b75151c6e63f98d42e483d552936e5 /games/minimal/mods | |
parent | 7940a4264ad19863f7fc7a32a665303ba766eed5 (diff) | |
download | minetest-26f4a5c1109f99fed6d7941b870a94fa49642181.tar.gz minetest-26f4a5c1109f99fed6d7941b870a94fa49642181.tar.bz2 minetest-26f4a5c1109f99fed6d7941b870a94fa49642181.zip |
Minimal game: add /dummyball <count> command
Diffstat (limited to 'games/minimal/mods')
-rw-r--r-- | games/minimal/mods/experimental/init.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua index 3e2e7787b..729191bce 100644 --- a/games/minimal/mods/experimental/init.lua +++ b/games/minimal/mods/experimental/init.lua @@ -254,6 +254,7 @@ minetest.register_entity("experimental:dummyball", { minetest.register_on_chat_message(function(name, message) local cmd = "/dummyball" if message:sub(0, #cmd) == cmd then + count = tonumber(message:sub(#cmd+1)) or 1 if not minetest.get_player_privs(name)["give"] then minetest.chat_send_player(name, "you don't have permission to spawn (give)") return true -- Handled chat message @@ -262,6 +263,12 @@ minetest.register_on_chat_message(function(name, message) minetest.chat_send_player(name, "you don't have permission to interact") return true -- Handled chat message end + if count >= 2 and not minetest.get_player_privs(name)["server"] then + minetest.chat_send_player(name, "you don't have " .. + "permission to spawn multiple " .. + "dummyballs (server)") + return true -- Handled chat message + end local player = minetest.get_player_by_name(name) if player == nil then print("Unable to spawn entity, player is nil") @@ -270,9 +277,11 @@ minetest.register_on_chat_message(function(name, message) local entityname = "experimental:dummyball" local p = player:getpos() p.y = p.y + 1 - minetest.add_entity(p, entityname) + for i = 1,count do + minetest.add_entity(p, entityname) + end minetest.chat_send_player(name, '"'..entityname - ..'" spawned.'); + ..'" spawned '..tostring(count)..' time(s).'); return true -- Handled chat message end end) |