As said earlier in this book in the The Esc scripting language chapter of the Escoria Fundamentals section, Esc files are simple text files that describe the interactions in your game.
The first concept to know of when writing Esc files are the entry points.
Entry points define what commands are going to be executed for each action verb of your game, as defined in the ui/verb_menu.scn file.
The syntax for entry points is the following: :verb
where verb is one of the verbs of verb_menu. The entry point is then followed by a list of commands that will be executed when the player uses the verb action of the item. The list of command is interrupted at the next entry point, or at the end of the file.
For example:
:talk
say player "Hey there!"
say old_man "Hello there, how are you?"
:look
say player "It’s just an old man"
Additionally, there is one
special case for the use verb. When using this verb and an item with the property Use combine enabled, the next clicked item will receive a special kind of event, that will run a special kind of entry point: the :use
entry point with the first item as a parameter.
For example, when clicking on an item where Use combine is checked, with the global id itemA
and then clicking on a second item, the second item’s Esc file will run at the entry point :use itemA
. If the entry point doesn’t exist, it will just run the regular :use
entry point.
In our mini-game, if we give the bad bamboo to the god, he is angry, so the bamboo_god.esc file we have:
:use inv_bad_bamboo
set_state bamboo_god angry
Blocks are a mean to group multiple commands in your esc file.
It is useful by itself, to put together series of related actions, or when combining them with conditions as we will see in the next chapter.
Groups work in the following way: you put a >
symbol on a line by itself and write your commands on the following lines, by indenting them (by pressing the tab key) one step further.
For example:
>
say player "Let's put this conversation into a group!"
say old_man "Okay kid, sounds fine by me."
say player "Good!"
If you want to clearly explain what the next few lines of your code are doing, so that other people (or even your future self) easily understand what it’s about, using comments is a good practice.
To do so, just put a hash #
symbol at the beginning of the line.
Example:
# Save the fact that the player has read the introduction
set_global introduced true
You might not want to define every possible action in every Esc file of all the items of your game (although doing so often leads to more interesting and lively games).
Escoria has a mean to define the default action to be taken when no entry point is in one item’s Esc file.
To make use of that feature, all you have to do is to define the entry point for all the actions you want to have a default behavior in the game/fallbacks.esc file.
:use
debug "use fallback!"
say player "I can't do that"
:pick_up
debug "pick_up fallback!"
say player "That's not a good idea"
If player is not present on the scene, you can use the telon object instead.
Il y a une erreur de communication avec le serveur Booktype. Nous ne savons pas actuellement où est le problème.
Vous devriez rafraîchir la page.