1

テキスト ファイルをランダム テーブルとして解釈し、それらをロールする Python スクリプトを作成しています。このスクリプトは、Sublime Text 内から実行するとうまく機能します。たとえば、ST のビルド ウィンドウからの出力は次のとおりです。

Getting random from 2500: Gold music box
Getting random from 2500: Eye patch with a mock eye set in blue sapphire and moonstone
Getting random from 2500: Fine gold chain set with a fire opal
Getting random from 2500: Embroidered silk adn velvet mantle set with numerous moonstones
Getting random from 2500: Gold music box
Getting random from H: Wand of the war mage, +3
Getting random from H: Weapon, +3
Getting random from H: Staff of frost
Getting random from CR 17 Hoard Items: Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
Getting random from CR 17 Hoard: 46000 gp, 34000 pp, and Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
46000 gp, 34000 pp, and Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
Number of arguments: 1 arguments.
Argument List: ['D:\\programming\\python-table-thing\\Table.py']

Windows コマンド プロンプトからも機能します。

D:\programming\python-table-thing>python Table.py
Getting random from 7500: Jeweled gold crown
Getting random from E: Potion of supreme healing
Getting random from E: Potion of storm giant strength
Getting random from 8: Animal Shapes
Getting random from E: Spell scroll (Animal Shapes)
Getting random from E: Universal solvent
Getting random from CR 17 Hoard Items: Jeweled gold crown,  Spell scroll (Animal
 Shapes), Potion of storm giant strength, Potion of supreme healing, Universal s
olvent
Getting random from CR 17 Hoard: 42000 gp, 24000 pp, and Jeweled gold crown, Spe
ll scroll (Animal Shapes), Potion of storm giant strength, Potion of supreme hea
ling, Universal solvent
42000 gp, 24000 pp, and Jeweled gold crown, Spell scroll (Animal Shapes), Potion
 of storm giant strength, Potion of supreme healing, Universal solvent
Number of arguments: 1 arguments.
Argument List: ['Table.py']

ただし、Cygwin (Mintty を使用) では正しく動作しません。私が知る限り、Cygwinでは改行なしで奇妙な場所に改行が挿入されているように見え、行の終わりがその始まりを上書きします。

$ python Table.py
Getting random from 2500: Platinum bracelet set with a sapphire
Getting random from 2500: Jeweled anklet
Getting random from 2500:
Getting random from E: Potion of supreme healing
Getting random from E: Potion of supreme healing
Getting random from 8: Demiplane
)etting random from E: Spell scroll (Demiplane
Getting random from E: Arrow of slaying
Getting random from 9: Mass Heal
)etting random from E: Spell scroll (Mass Heal
, Arrow of slayingmiplanealingd Items: Platinum bracelet set with a sapphire
, Arrow of slayingmiplanealingd: 42000 gp, 28000 pp, and Platinum bracelet set with a sapphire
, Arrow of slayingmiplanealingum bracelet set with a sapphire
Number of arguments: 1 arguments.
Argument List: ['Table.py']

端末の表示だけの問題ではありません。私はそれをファイルにパイプしようとしましたが、同じ問題が発生しました。

これは Cygwin または Mintty の問題であると想定していますが、役立つと思われる場合に使用しているソース コードを次に示します: http://pastebin.com/4bJ4LC8h

4

0 に答える 0