コメント
このコメントは、【トピック】どうして?へのコメントです。コメントの内容
コメントの内容(一番最初の投稿)
#データなど
setVariable("ムニー", "ムニー")
a = createArray()
a[0] = createArray()
a[0][0] = 3985 #id
a[0][1] = 100 #価格
a[1] = createArray()
a[1][0] = 3986
a[1][1] = 100
a[2] = createArray()
a[2][0] = 3777
a[2][1] = 100
setVariable("店にあるアイテム", a)
#お店処理
selectX = getSelectWindowX()
selectY = getSelectWindowY()
selectWidth = getSelectWindowWidth()
selectHeight = getSelectWindowHeight()
textId = createText(512 - 160, 16, 160, 64)
setSelectWindowRect(256, 100, 240, 200)
loop = true
speak("絵の具ちゃん:いらっしゃいませ。森の防具屋です")
gold = getVariable(getVariable("ムニー"))
items = getVariable("店にあるアイテム")
sellItems = getVariable("売れるアイテム")
itemList = createArray()
i = 0
while i < getArrayLength(items)
param = getItemParamWithId(items[i][0])
itemList[i] = getValueFromItemParam(param, getItemViewNameIndex()) + " " + toString(items[i][1])
i = i + 1
end
pushArray(itemList, "買わない")
while loop
setText(textId, getVariable("ムニー") + " " + toString(gold))
case speakWithSelect(3,"買う","売る","店を出る",
"絵の具ちゃん:いかがいたしますか?")
when 0
buyIndex = -1
buyIndex = speakWithSelectArray(itemList,
"絵の具ちゃん:どちらをお買い上げになりますか?")
if buyIndex >= getArrayLength(itemList) - 1
buyIndex = -1
end
if buyIndex >= 0
param = getItemParamWithId(items[buyIndex][0])
if items[buyIndex][1] > gold
speak("絵の具ちゃん:ムニーがたりません。")
elsif getValueFromItemParam(param, getItemTypeIdIndex()) == 0
if !giveItem(items[buyIndex][0])
speak("絵の具ちゃん:アイテムバッグがいっぱいです")
else
speak("絵の具ちゃんお買い上げありがとうございます。")
gold = gold - items[buyIndex][1]
end
else
if !giveEquipment(items[buyIndex][0])
speak("絵の具ちゃん:装備できませんでした。")
else
speak("絵の具ちゃん:お買い上げありがとうございます。")
gold = gold - items[buyIndex][1]
end
end
end
when 1
case speakWithSelect(3,"装備を売る","持ち物を売る","やめる",
"絵の具ちゃんどれを売っていただけるのでしょうか?")
when 0
i = 0
ct = 0
a = getEquipmentIdArray()
el = createArray()
ei = createArray()
while i < getArrayLength(a)
if a[i] >= 0
me = getEquipmentParamWithIndex(i)
el[ct] = getValueFromItemParam(me, getItemViewNameIndex())
ei[ct] = i
ct = ct + 1
end
i = i + 1
end
el[ct] = "やめる"
idx2 = speakWithSelectArray(el, "絵の具ちゃん:どの装備を売っていただけるのでしょうか?")
if idx2 == ct
else
price = 0
i = 0
priceLoopEnd = false
while i < getArrayLength(sellItems) && !priceLoopEnd
if sellItems[i][0] == a[ei[idx2]]
price = sellItems[i][1]
priceLoopEnd = true
end
i = i + 1
end
if priceLoopEnd
case speakWithSelect(2,"はい","いいえ",
toString(price) + "になりますが売っていただけますか?")
when 0
speak("絵の具ちゃん:売っていただきありがとうございます。")
gold = gold + price
removeEquipmentWithIndex(ei[idx2])
when 1
speak("絵の具ちゃん:まだ手放されないのですね。了解しました。")
end
else
speak("絵の具ちゃんまだ手放されないのですね。了解しました。")
end
end
when 1
a = getItemIdArray()
il = createArray()
ii = createArray()
i = 0
ct = 0
while i < getArrayLength(a)
if a[i] >= 0
mi = getItemParamWithIndex(i)
il[ct] = getValueFromItemParam(mi, getItemViewNameIndex())
ii[ct] = i
ct = ct + 1
end
i = i + 1
end
il[ct] = "やめる"
idx = speakWithSelectArray(il, "絵の具ちゃん:どちらのアイテムを売っていただけますか?")
if idx == ct
else
price = 0
i = 0
priceLoopEnd = false
while i < getArrayLength(sellItems) && !priceLoopEnd
if sellItems[i][0] == a[ii[idx]]
price = sellItems[i][1]
priceLoopEnd = true
end
i = i + 1
end
if priceLoopEnd
case speakWithSelect(2,"はい","いいえ",
toString(price) + "になりますが売っていただけますか?")
when 0
speak("絵の具ちゃん:売っていただきありがとうございます。")
gold = gold + price
removeItemWithIndex(ii[idx])
when 1
speak("絵の具ちゃん:まだ手放されないのですね。了解しました。")
end
else
speak("絵の具ちゃん:まだ手放されないのですね。了解しました。")
end
end
when 2
end
when 2
speak("絵の具ちゃん:またのご来店をお待ちしています。")
loop = false
end
end
setVariable(getVariable("ムニー"), gold)
setSelectWindowRect(selectX, selectY, selectWidth, selectHeight)
deleteText(textId)こうです
売れるアイテムは共通なので開始スクリプトに書いています
#データなど setVariable("ムニー", "ムニー") a = createArray() a[0] = createArray() a[0][0] = 3985 #id a[0][1] = 100 #価格 a[1] = createArray() a[1][0] = 3986 a[1][1] = 100 a[2] = createArray() a[2][0] = 3777 a[2][1] = 100 setVariable("店にあるアイテム", a) #お店処理 selectX = getSelectWindowX() selectY = getSelectWindowY() selectWidth = getSelectWindowWidth() selectHeight = getSelectWindowHeight() textId = createText(512 - 160, 16, 160, 64) setSelectWindowRect(256, 100, 240, 200) loop = true speak("絵の具ちゃん:いらっしゃいませ。森の防具屋です") gold = getVariable(getVariable("ムニー")) items = getVariable("店にあるアイテム") sellItems = getVariable("売れるアイテム") itemList = createArray() i = 0 while i < getArrayLength(items) param = getItemParamWithId(items[i][0]) itemList[i] = getValueFromItemParam(param, getItemViewNameIndex()) + " " + toString(items[i][1]) i = i + 1 end pushArray(itemList, "買わない") while loop setText(textId, getVariable("ムニー") + " " + toString(gold)) case speakWithSelect(3,"買う","売る","店を出る", "絵の具ちゃん:いかがいたしますか?") when 0 buyIndex = -1 buyIndex = speakWithSelectArray(itemList, "絵の具ちゃん:どちらをお買い上げになりますか?") if buyIndex >= getArrayLength(itemList) - 1 buyIndex = -1 end if buyIndex >= 0 param = getItemParamWithId(items[buyIndex][0]) if items[buyIndex][1] > gold speak("絵の具ちゃん:ムニーがたりません。") elsif getValueFromItemParam(param, getItemTypeIdIndex()) == 0 if !giveItem(items[buyIndex][0]) speak("絵の具ちゃん:アイテムバッグがいっぱいです") else speak("絵の具ちゃんお買い上げありがとうございます。") gold = gold - items[buyIndex][1] end else if !giveEquipment(items[buyIndex][0]) speak("絵の具ちゃん:装備できませんでした。") else speak("絵の具ちゃん:お買い上げありがとうございます。") gold = gold - items[buyIndex][1] end end end when 1 case speakWithSelect(3,"装備を売る","持ち物を売る","やめる", "絵の具ちゃんどれを売っていただけるのでしょうか?") when 0 i = 0 ct = 0 a = getEquipmentIdArray() el = createArray() ei = createArray() while i < getArrayLength(a) if a[i] >= 0 me = getEquipmentParamWithIndex(i) el[ct] = getValueFromItemParam(me, getItemViewNameIndex()) ei[ct] = i ct = ct + 1 end i = i + 1 end el[ct] = "やめる" idx2 = speakWithSelectArray(el, "絵の具ちゃん:どの装備を売っていただけるのでしょうか?") if idx2 == ct else price = 0 i = 0 priceLoopEnd = false while i < getArrayLength(sellItems) && !priceLoopEnd if sellItems[i][0] == a[ei[idx2]] price = sellItems[i][1] priceLoopEnd = true end i = i + 1 end if priceLoopEnd case speakWithSelect(2,"はい","いいえ", toString(price) + "になりますが売っていただけますか?") when 0 speak("絵の具ちゃん:売っていただきありがとうございます。") gold = gold + price removeEquipmentWithIndex(ei[idx2]) when 1 speak("絵の具ちゃん:まだ手放されないのですね。了解しました。") end else speak("絵の具ちゃんまだ手放されないのですね。了解しました。") end end when 1 a = getItemIdArray() il = createArray() ii = createArray() i = 0 ct = 0 while i < getArrayLength(a) if a[i] >= 0 mi = getItemParamWithIndex(i) il[ct] = getValueFromItemParam(mi, getItemViewNameIndex()) ii[ct] = i ct = ct + 1 end i = i + 1 end il[ct] = "やめる" idx = speakWithSelectArray(il, "絵の具ちゃん:どちらのアイテムを売っていただけますか?") if idx == ct else price = 0 i = 0 priceLoopEnd = false while i < getArrayLength(sellItems) && !priceLoopEnd if sellItems[i][0] == a[ii[idx]] price = sellItems[i][1] priceLoopEnd = true end i = i + 1 end if priceLoopEnd case speakWithSelect(2,"はい","いいえ", toString(price) + "になりますが売っていただけますか?") when 0 speak("絵の具ちゃん:売っていただきありがとうございます。") gold = gold + price removeItemWithIndex(ii[idx]) when 1 speak("絵の具ちゃん:まだ手放されないのですね。了解しました。") end else speak("絵の具ちゃん:まだ手放されないのですね。了解しました。") end end when 2 end when 2 speak("絵の具ちゃん:またのご来店をお待ちしています。") loop = false end end setVariable(getVariable("ムニー"), gold) setSelectWindowRect(selectX, selectY, selectWidth, selectHeight) deleteText(textId)こうです
売れるアイテムは共通なので開始スクリプトに書いています