summaryrefslogtreecommitdiff
path: root/random.lua
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-09-13 14:23:48 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-09-13 14:23:48 +0200
commit35a58c7c70287b59530d9164b28c9eceb56f81ba (patch)
tree2c9c4fb9cc7e0fed5ab37bf19b3f5fa0d5e71c39 /random.lua
parent94dd1a6113aa2fa7bdd51dbca332eb167c1223cb (diff)
downloadfurrybot-35a58c7c70287b59530d9164b28c9eceb56f81ba.tar.xz
Split code into multiple files
Diffstat (limited to 'random.lua')
-rw-r--r--random.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/random.lua b/random.lua
new file mode 100644
index 0000000..d095746
--- /dev/null
+++ b/random.lua
@@ -0,0 +1,23 @@
+local http, env, storage
+local C = minetest.get_color_escape_sequence
+
+function furrybot.commands.rolldice(name)
+ furrybot.ping_message(name, "rolled a dice and got a " .. furrybot.random(1, 6, furrybot.colors.system) .. ".", furrybot.colors.system)
+end
+
+function furrybot.commands.coinflip(name)
+ furrybot.ping_message(name, "flipped a coin and got " .. furrybot.choose({"Heads", "Tails"}, furrybot.colors.system) .. ".", furrybot.colors.system)
+end
+
+function furrybot.commands.choose(name, ...)
+ local options = {...}
+ if #options > 1 then
+ furrybot.ping_message(name, "I choose " .. furrybot.choose(options, "", furrybot.colors.system) .. ".", furrybot.colors.system)
+ else
+ furrybot.error_message(name, "Not enough options")
+ end
+end
+
+return function(_http, _env, _storage)
+ http, env, storage = _http, _env, _storage
+end