]> git.lizzy.rs Git - furrybot.git/blob - random.lua
d095746dc5351e0c6358a0a07f81eb71c2340400
[furrybot.git] / random.lua
1 local http, env, storage
2 local C = minetest.get_color_escape_sequence
3
4 function furrybot.commands.rolldice(name)
5         furrybot.ping_message(name, "rolled a dice and got a " .. furrybot.random(1, 6, furrybot.colors.system) .. ".", furrybot.colors.system)
6 end
7
8 function furrybot.commands.coinflip(name)
9         furrybot.ping_message(name, "flipped a coin and got " .. furrybot.choose({"Heads", "Tails"}, furrybot.colors.system) .. ".", furrybot.colors.system)
10 end
11
12 function furrybot.commands.choose(name, ...)
13         local options = {...}
14         if #options > 1 then
15                 furrybot.ping_message(name, "I choose " .. furrybot.choose(options, "", furrybot.colors.system) .. ".", furrybot.colors.system)
16         else
17                 furrybot.error_message(name, "Not enough options")
18         end
19 end
20
21 return function(_http, _env, _storage)
22         http, env, storage = _http, _env, _storage
23 end