3
2

More than 3 years have passed since last update.

Luaで湯婆婆を実装してみる

Last updated at Posted at 2020-11-09

初めに

元ネタ様:Javaで湯婆婆を実装してみる

このビックウェーブに乗るしかない
初投稿です

コード

Yubaba.lua
print("契約書だよ。そこに名前を書きな")
Name = io.read()
print("フン。"..  Name .."というのかい。贅沢な名だねぇ。")

Len = string.len(Name)

Seed = os.time()
math.randomseed(Seed)
rand = math.random(Len / 3) -1

cnt = 3 * rand + 1

newName = string.sub(Name,cnt , cnt + 2) 

print("今からお前の名前は".. newName .. "だ。いいかい、" .. newName .."だよ。分かったら返事をするんだ、" .. newName .. "!!")

実行例

最新版のZerBrainStudioで実行しました
Yubaaba.png

終わりに

Lua歴1ヶ月なのでまだ雑なところがあるかもしれないです

3
2
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2