thinBasic Adventure Builder (TAB)

Text Adventure Tutorial


Part Five: Building the puzzles


Now we come to the Editors that are at the heart of the TAB program and execute the main game control...

The Script 1 Editor is a special list of entries which consist of conditions and actions which are scanned by TAB after every location has been described in the game but BEFORE exits and/or objects visible have been printed.
TAB does all the entries in this table, providing they exist starting at entry number 1 and continues to the end of the list. It then looks at the Script 2 entries before returning to the parser to get a new input or any further commands which may have been typed.
Script 1 is useful for adding a message to a location text or for printing extra info to a location. It can also be used for other things too.

The Response Editor is a list of entries constructed to take care of input commands from the player. When the player types a command from within the game, the parser examines the phrase typed and extracts variables v, n1/objn1/charn1, p and n2/objn2/charn2 i.e. the verb, first noun (be it an ordinary noun, object noun or character noun) any preposition and any second noun. (be it an ordinary noun, object noun or character noun)
The parser also removes any deletion words and devises a special string which is the Keyword string sentence equivalent to the input typed.
This information is then passed to the RESPONSE entries to find a match. So, TAB looks at each entry in turn until it finds one that corresponds. If it does then it looks at the conditions in that entry and if they are satisfied it carries out the actions in the entry in the order it meets them and then exits RESPONSE to look at the SCRIPT 2 entries.

The Script 2 Editor. This list of entries, again containing conditions and actions, is called by the TAB immediately AFTER Response but BEFORE getting the next phrase of input from the player or before a new input is requested. It is also called after each input 'timeout' has expired.
As with Script 1, ALL the entries are done in sequence and the Conditions and Actions are looked at in turn to see if anything needs to be executed.
Script 2 provides for the computer's turn at the game and to inform the player of any events which may have happened such as a car crashing, a secret panel opening or a bomb exploding etc. When TAB has scanned all the entries it makes a return to the parser for the next command or prompts the player for the next input.

You need to know a bit about what the entries in these Editors do; but in short they consist of 2 parts, part 1 is where you put the Conditions, and part 2 where you put in the Actions you want to take place.
For example you want to talk to someone, you have to show whether the Character is in the room, etc. those are the Conditions. Then whatever action you require to take place, for example a message to be shown stating what the Character says to you or does. You will see what I mean when you type in some entries into Responses Editor shortly.

You will use these 3 Editors to insert all the entries which the game will be able to interpret, and to devise the problems and puzzles which the player will encounter on his journey through the realm of your fantasy world.

Go to the Response Editor.

Examine the default entries present in the list. You will see that there are entries already provided in this list to take care of basic player commands such as 'getting', 'dropping', 'wearing', 'removing' objects and for commands such as 'inventory' 'wait', 'look' and the like. Spend a few moments examining this list. In fact all these Response entries already present are going to be necessary for the smooth running and execution of games, so it's best to keep these as they stand, and just add new entries as and when needed.

As you realize they are quite short sections of code. They will not be time consuming to insert and are quite easy to create and type in.
However, it should be borne in mind that you should construct these entries properly in the correct format, and using the rules which will be given, in order for your entries to function properly.
If you ignore the coding rules then doubtless your entry will not perform correctly and you may get an error report when you come to playtest your game. The error reports may indicate the entry list that is causing the error. If you find this happening then you must quit the game and go back to the Response Editor to put things right.

The format of each coding entry must contains 3 tags enclosed in square brackets:


After a [start] tag you must enter the CONDITIONS that make the entry work.

The first CONDITION in a Response entry is always a "WORDS CONDITION"

If there are any other conditions required then use the # hash symbol to separate them.

When the entry conditions have been typed in you then type the [acts] tag.

After this you type in any ACTION commands required.

If there is more than one action then use the # hash symbol to separate them.

When the entry ACTIONS are finished you close the entry with an [end] tag.


Roughly translated this means:

IF the words conditions match AND condition 1 is true AND condition 2 is true THEN
do action 1 THEN
do action 2 THEN
Exit the Response list.

Type the following entries into the Response Editbox so that they are at the top of the list. Note the WORDS CONDITIONS must be in lower case. HINT: Copy and paste the entries. It's much easier. :)

[start]unlock chest/unlock chest with key#here6#here2#closed6[acts]openobj6#cmessThe chest is now unlocked.[end]

[start]unlock chest/unlock chest with key#here6#opened6[acts]cmessThe chest is already unlocked.[end]

[start]unlock chest/unlock chest with key#here6#absent2[acts]cmessYou don't have a key![end]

[start]lock chest/lock chest with key#here6#opened6#here2[acts]closeobj6#cmessYou lock the chest with the silver key.[end]

[start]lock chest/lock chest with key#here6#closed6[acts]cmessThe chest is already locked![end]

[start]open chest#here6#opened6[acts]cmessOK.[end]

[start]open chest#here6#closed6[acts]cmessYou can't. it's locked.[end]

[start]close chest#here6#opened6[acts]cmessOK.[end]

[start]close chest#here6#closed6[acts]cmessYou can't. It's already closed.[end]

[start]eat sandwich#here1[acts]destroy1#cmessYum Yum... You greedily consume the egg sandwich.[end]

[start]eat sandwich#absent1[acts]cmessYou don't seem to own a sandwich!#done[end]

[start]dig/dig ground/dig with spade/dig ground with spade#here3#room=3#objloc2=0[acts]create2#cmessYou dig and uncover a small object...[end]

[start]dig/dig ground/dig with spade/dig ground with spade#here3[acts]You dig around for a bit but uncover nothing of interest.[end]

[start]dig/dig ground/dig with spade/dig ground with spade#absent3[acts]cmessYou have no digging tool.[end]

[start]give sandwich to farmer#here1#charpresent1#flag1=0[acts]destroy1#create3#flag1=1#cmessThe farmer gratefully accepts your gift. He drops a spade he was carrying and eats the sandwich hungrily.[end]

[start]give %objn1% to farmer#charpresent1#objlocn1=here[acts]cmessThe farmer politely refuses your gift.[end]

[start]give %objn1% to cat#charpresent2#objlocn1=here[acts]cmessThe cat ignores you and eyes you suspiciously...[end]

[start]talk to farmer#charpresent1#flag1=0[acts]cmessThe farmer greets you cheerily and comments on the fine weather. "I seem to have mislaid my lunch box and I am so hungry" he exclaims.

[start]talk to farmer#charpresent1#flag1=1[acts]cmessThe farmer chats a while and wishes you good luck on your quest.[end]

[start]talk to cat#charpresent2[acts]cmessThe cat stares at you in amazement![end]

Exit the Response Editor.

Click the Script 2 button to open that Editor

Type or copy and paste these entries to the top of the Script 2 List:

'sets the chest to be initially locked

[start]flag3=0#carried4[acts]objloc4=1#score+20#flag3=1#cmessAs you touch the knife it vibrates in your hand. An unearthly voice shatters the silence. "If thou wouldst claim the Sacred Knife of Dragoria and use its mystic powers then thou must first possess it three times."
A blinding flash of light causes the knife to disintegrate in a shower of sparks![end]

[start]flag3=1#carried4[acts]objloc4=6#score+20#flag3=2#cmessAs you hold the knife the strange voice returns - "Once more bold seeker thy aim to own this legendary prize is thwarted. Ha ha ha.."
The knife jumps out of your hand and spins in the air with increasing rapidity and vanishes in a cloud of smoke! Phew!![end]

[start]flag3=2#carried4[acts]objloc4=5#score+20#flag3=3#cmessThe knife seems to have a life of it's own!! Invisible hands seem to repeatedly raise and slash... raise and slash in a frenzied attack upon you. You struggle to protect yourself against the rain of blows!
Suddenly the knife has disappeared again and you realise the attack was just an illusion.[end]

[start]flag3=3#carried4[acts]score+40#cmessHaving discovered the knife once more, a fanfare sounds in the distance. A Psychic message from the Guardian of the Knife unfolds in your mind - "Congratulations, thou art chosen as worthy to own this famed treasure and control it's mystic powers."
The piercing tones of your 6am alarm call bring you to waking reality.
The adventure is over. You have solved the game.#score#pause6#gameover[end]

Go 'Back' to the Main Editor.


Go to the Vocabulary Editor.

Add the following words to the VERB listbox:


Add the following word entry in the ordinary NOUN listbox:

Go 'Back' to the Editor Main Menu.

This should have completed the short game, and you can 'Test Adventure' from beginning to end.
To win, the player must find and possess the knife 3 times.

Eventually there will be a manual/guide that better explains the TAB program and the coding language it uses. Remember TAB is still in Alpha stage. Things might change and probably will. There is a 'language.txt' file which briefly documents the conditions and actions included in the download. These exist to make the task of adventure authoring a little simpler and once you understand them you'll be incorporating your own designer entries into your game with consummate ease.

If you don't wish to build this example now, or are just curious as to the final result, here is the finished database to download and open in the TAB Player.


Copyright catventure 2015 , All Rights Reserved.