ゲームでの例
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2021/08/23 15:02 UTC 版)
Informライブラリを使ったInformのソースコードの例を以下に示す。Inform 6を前提としている。Inform 7では全く文法が異なるが、レガシーコードであることを示すよう修正を加えれば、Inform 7でも使用可能である。 Constant Story "Hello World"; Constant Headline "^An Interactive Example^"; Include "Parser"; Include "VerbLib"; [ Initialise; location = Living_Room; "Hello World"; ]; Object Kitchen "Kitchen"; Object Front_Door "Front Door"; Object Living_Room "Living Room" with description "A comfortably furnished living room.", n_to Kitchen, s_to Front_Door, has light; Object -> Salesman "insurance salesman" with name 'insurance' 'salesman' 'man', description "An insurance salesman in a tacky polyester suit. He seems eager to speak to you.", before [; Listen: move Insurance_Paperwork to player; "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you."; ], has animate; Object -> -> Briefcase "briefcase" with name 'briefcase' 'case', description "A slightly worn, black briefcase.", has container; Object -> -> -> Insurance_Paperwork "insurance paperwork" with name 'paperwork' 'papers' 'insurance' 'documents' 'forms', description "Page after page of small legalese."; Include "Grammar";
※この「ゲームでの例」の解説は、「Inform」の解説の一部です。
「ゲームでの例」を含む「Inform」の記事については、「Inform」の概要を参照ください。
ゲームでの例
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2021/08/23 15:02 UTC 版)
以下は、上掲の "Hello World" の例をInform 7で書いて再実装したものである。Inform 7でのコンパイルで自動的にリンクされる "The Standard Rules" というライブラリを使っている。 "Hello World" by "I.F. Author" The story headline is "An Interactive Example". The Living Room is a room. "A comfortably furnished living room."The Kitchen is north of the Living Room. The Front Door is southof the Living Room. The Front Door is a closed locked door. The insurance salesman is a man in the Living Room. Thedescription is "An insurance salesman in a tacky polyester suit.He seems eager to speak to you." Understand "man" as theinsurance salesman. A briefcase is carried by the insurance salesman. The descriptionis "A slightly worn, black briefcase." Understand "case" as thebriefcase. The insurance paperwork is in the briefcase. Thedescription is "Page after page of small legalese." Understand "papers" or "documents" or "forms" as the paperwork. Instead of listening to the insurance salesman: say "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you."; now the player carries the insurance paperwork.
※この「ゲームでの例」の解説は、「Inform」の解説の一部です。
「ゲームでの例」を含む「Inform」の記事については、「Inform」の概要を参照ください。
- ゲームでの例のページへのリンク