Difference between revisions of "Advanced Said() Strings - Part 1"

From SCI Wiki
Jump to navigationJump to search
(Sierra Script conversion)
 
(One intermediate revision by one other user not shown)
Line 10: Line 10:
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">(if (Said('look>'))
+
<syntaxhighlight lang="sci">
  (if (Said('/wall'))Print("The wall is covered in paint."))
+
(if (Said 'look>')
  (if (Said('/floor'))Print("The floor is covered in dust."))
+
(if (Said '/wall') (Print {The wall is covered in paint.}))
  (If (Said('[/!*]'))Print("You are in a room with a floor and a wall.")) // this will handle just "look" by itself
+
(if (Said '/floor') (Print {The floor is covered in dust.}))
  (if (Said('/*'))Print("You don't see anything interesting about it.")) // This will handle "look anyword"
+
(if (Said '[/!*]') (Print {You are in a room with a floor and a wall.})) ; this will handle just "look" by itself
)</syntaxhighlight>
+
(if (Said '/*') (Print {You don't see anything interesting about it.})) ; this will handle "look anyword"
 +
)
 +
</syntaxhighlight>
  
 
If you wanted to handle 'look around' just like look, you could do:
 
If you wanted to handle 'look around' just like look, you could do:
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci">(if (Said('look>'))
+
<syntaxhighlight lang="sci">
  (if (Said('/wall'))Print("The wall is covered in paint."))
+
(if (Said 'look>')
  (If (Said('/floor'))Print("The floor is covered in dust."))
+
(if (Said '/wall') (Print {The wall is covered in paint.}))
  (If (Said('[/around]'))Print("You are in a room with a floor and a wall.")) // This will handle just "look" by itself, and also "look around"
+
(if (Said '/floor') (Print {The floor is covered in dust.}))
  (if (Said('/*'))Print("You don't see anything interesting about it."))
+
(if (Said '[/around]') (Print {You are in a room with a floor and a wall.})) ; this will handle just "look" by itself, and also "look around"
)</syntaxhighlight>
+
(if (Said '/*') (Print {You don't see anything interesting about it.}))
 +
)
 +
</syntaxhighlight>
  
 
Note that more specific Said clauses should always come before more general ones.
 
Note that more specific Said clauses should always come before more general ones.
Line 32: Line 36:
 
Consider the following example:
 
Consider the following example:
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci" class="cs">(if (Said('give/food/dog'))
+
<syntaxhighlight lang="sci">
  Print("You give the food to the dog.")
+
(if (Said 'give/food/dog')
)</syntaxhighlight>
+
(Print {You give the food to the dog.})
 +
)
 +
</syntaxhighlight>
  
 
One thing to note is that the order of words in the Said string doesn't necessarily match the order that the words are typed in by the user. There is more meaning to the Said string than that. The above clause will respond positively to the user typing "Give food to the dog", or even "Give dog the food". However, surprisingly (and fortunately), it will not match "Give food the dog". Rather than the particular word order in a sentence, the three parts of the above clause correspond to sentence parts.
 
One thing to note is that the order of words in the Said string doesn't necessarily match the order that the words are typed in by the user. There is more meaning to the Said string than that. The above clause will respond positively to the user typing "Give food to the dog", or even "Give dog the food". However, surprisingly (and fortunately), it will not match "Give food the dog". Rather than the particular word order in a sentence, the three parts of the above clause correspond to sentence parts.
Line 40: Line 46:
 
Similarly:
 
Similarly:
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
<syntaxhighlight lang="sci" class="cs">(if (Said('point<up/flashlight'))
+
<syntaxhighlight lang="sci">
  Print("You point the flashlight up, and see something curious.")
+
(if (Said 'point<up/flashlight')
)</syntaxhighlight>
+
(Print {You point the flashlight up, and see something curious.})
 +
)
 +
</syntaxhighlight>
  
 
This will respond to "point flashlight up", but not "point up flashlight". (Note: FreeSCI may have some bugs here that make it behave differently than the Sierra parser).
 
This will respond to "point flashlight up", but not "point up flashlight". (Note: FreeSCI may have some bugs here that make it behave differently than the Sierra parser).

Latest revision as of 14:25, 27 February 2016

Chapter 1 - Advanced Said() Strings - Part 1

More About Said Statements

This chapter explains some common Said usage patterns that aren't fully explained in the other tutorials.

"Look" vs. "Look thing"

Often, you might want to enclose all your 'look' handlers in one if statement, but still support just "look" all by itself.

Code:
(if (Said 'look>')
	(if (Said '/wall') (Print {The wall is covered in paint.}))
	(if (Said '/floor') (Print {The floor is covered in dust.}))
	(if (Said '[/!*]') (Print {You are in a room with a floor and a wall.})) ; this will handle just "look" by itself
	(if (Said '/*') (Print {You don't see anything interesting about it.})) ; this will handle "look anyword"
)

If you wanted to handle 'look around' just like look, you could do:

Code:
(if (Said 'look>')
	(if (Said '/wall') (Print {The wall is covered in paint.}))
	(if (Said '/floor') (Print {The floor is covered in dust.}))
	(if (Said '[/around]') (Print {You are in a room with a floor and a wall.})) ; this will handle just "look" by itself, and also "look around"
	(if (Said '/*') (Print {You don't see anything interesting about it.}))
)

Note that more specific Said clauses should always come before more general ones.

More complex Said strings

Consider the following example:

Code:
(if (Said 'give/food/dog')
	(Print {You give the food to the dog.})
)

One thing to note is that the order of words in the Said string doesn't necessarily match the order that the words are typed in by the user. There is more meaning to the Said string than that. The above clause will respond positively to the user typing "Give food to the dog", or even "Give dog the food". However, surprisingly (and fortunately), it will not match "Give food the dog". Rather than the particular word order in a sentence, the three parts of the above clause correspond to sentence parts.

Similarly:

Code:
(if (Said 'point<up/flashlight')
	(Print {You point the flashlight up, and see something curious.})
)

This will respond to "point flashlight up", but not "point up flashlight". (Note: FreeSCI may have some bugs here that make it behave differently than the Sierra parser).

That sums up more about said statements.

 

< Previous: Advanced SCI Tutorials Introductions Next: Chapter 2 - Regions and Locales >