コメント
このコメントは、【トピック】使えないアイテムの店の作り方へのコメントです。コメントの内容
コメントの内容(一番最初の投稿)
きゅうり(投稿日:2011/10/27 19:10/27/11)
case speakWithSelect(2,"買う","買わない",
"200マイルのライトを買いますか?")
when 0
#①
if getVariable("お金") < 200
speak("マイルが足りません")
else
setVariable("お金",getVariable("お金") - 200)
setFlag("ライト",true)#②
speak("ありがとうございます。")
end
when 1
speak("またきてね♪")
end
問題点
①
def文は定義するだけでは実行されません。(この場合は使わなければok)
②
「true」ではなく「rue」になっていた。
以上を直したスクリプトが↑です。
また、どこでも同じように使えるように、
#開始スクリプト
def buyItem(price0,price1)
case speakWithSelect(2,"買う","買わない",
price1,"マイルの",price0,"を買いますか?")
when 0
if getVariable("お金") < price1
speak("マイルが足りません")
else
setVariable("お金",getVariable("お金") - price1)
setFlag(price0,true)
speak("ありがとうございます。")
end
when 1
speak("またきてね♪")
end
end
#使うとき
buyItem("ライト",200)
#「立てるフラグ(購入時に入手できるアイテムの名前)、値段」の順番
と書くのもokです。
case speakWithSelect(2,"買う","買わない", "200マイルのライトを買いますか?") when 0 #① if getVariable("お金") < 200 speak("マイルが足りません") else setVariable("お金",getVariable("お金") - 200) setFlag("ライト",true)#② speak("ありがとうございます。") end when 1 speak("またきてね♪") end問題点
①
def文は定義するだけでは実行されません。(この場合は使わなければok)
②
「true」ではなく「rue」になっていた。
以上を直したスクリプトが↑です。
また、どこでも同じように使えるように、
#開始スクリプト def buyItem(price0,price1) case speakWithSelect(2,"買う","買わない", price1,"マイルの",price0,"を買いますか?") when 0 if getVariable("お金") < price1 speak("マイルが足りません") else setVariable("お金",getVariable("お金") - price1) setFlag(price0,true) speak("ありがとうございます。") end when 1 speak("またきてね♪") end end#使うとき buyItem("ライト",200) #「立てるフラグ(購入時に入手できるアイテムの名前)、値段」の順番と書くのもokです。