Difference between revisions of ""How do I...?""

From ADRIFT 5 Manual Wiki
Jump to: navigation, search
(Moved large section "Allow for a Screen Display which Refreshes for each New Location?" to its own page)
Line 119: Line 119:
  
 
For example, "take crate" would be in the command field and in game the player could tell the npc to take the crate by typing "say take crate to robot" or "robot, take crate". While both would work, the latter is more natural and follows the syntax for giving commands to npc's that are used in other games.
 
For example, "take crate" would be in the command field and in game the player could tell the npc to take the crate by typing "say take crate to robot" or "robot, take crate". While both would work, the latter is more natural and follows the syntax for giving commands to npc's that are used in other games.
 
== Allow for a Screen Display which Refreshes for each New Location? ==
 
 
When anyone is playing your adventure, the default screen display is set so that the screen will scroll up as the Player Character (PC) moves around. However, some players prefer that the location text should refresh when moving into a new location. If you want to allow the player the option to do this in your game, this is one way that you should do it:
 
 
First of all, define a new variable. You can call this what you like, in my games I just call it "scroll" but you should put an underscore in front (i.e. "_scroll") so that it will always be at the top of the variable list when you need to put it into a restriction or an action. This variable will be initally 0 and will be set to 1 when the player choses the "SCROFF" option we will be programming later.
 
 
You will also need a "keypress" message for when the location text changes as a result of an action by the player. You want the player to be able to read any messages that a task will display before the screen refreshes with the new location description. In my adventures I have a message that appears in green under the text like so:
 
 
 
<b><centre><font color = green>Press the Space Bar to Continue.....</font></center><br>
 
<waitkey></b>
 
 
 
The <waitkey> line will pause the Runner until a key is pressed. As you will be inserting this message in lots of tasks, you do not want to have to type the whole message every time. The easiest way of doing this is to define a text override with something like <mytext> as the original text and the replacement text as the "keypress" message as above.
 
 
Now, whenever the player moves to another location, the LOOK task is activated to display the location description, so if we want the screen to refresh when the PC moves to another room, we must redefine this task. The Look task is in the "Look and Examine" folder within the Standard Library folder in the Folders window on the left of the screen, as below.
 
 
 
[[File:LookTask.jpg]]
 
 
 
When you open this task you will see in the default message box <b>DisplayLocation[%LocationOf[%Player%]%]%</b> in blue, plus an alternate description which is displayed if the location is dark and the PC is not carrying a light source. What is useful at this stage is if you rename this alternate description, so just right-click on the "alternate description" tab and rename it to something like "Dark Locations".
 
 
Next you should open a new alternate description, so either right-click on the task and select "Add Alternate Description" or move your cursor to the right of the "Dark Locations" tab and you will see a tab appear which when you click on it will add and open an alternate description. Rename the tab for this description as (for example) "Scroll On". What you should do now is go back to the default description and highlight <b>%DisplayLocation[%LocationOf[%Player%]%]%</b>. You need to copy this then delete it from the default description window. Now open the new "Scroll On" tab and paste what you have just copied into the message box. In the restriction box above the message window you should define the restriction as "Variable _scroll must be equal to 0" then "Start Description with". After you have done this click on the "Apply" button to save the changes without closing the task.
 
 
Now you repeat the above step to create a second alternate description, calling this one (e.g.) "Scroll Off". However, before you paste the completion message into the box type <cls> first then paste the message immediately after this so that it reads:
 
 
 
<b><cls>%DisplayLocation[%LocationOf[%Player%]%]%</b>
 
 
 
The restriction for this message must be "Variable _scroll must be equal to 1" then "Start Description with". Now open the Actions tab and add the action "Set variable _scroll to 1". Click apply to save what you have done,
 
 
The final step before we save and close the re-defined task is to move the "Dark Locations" tab to the right so that it is after the two new tabs, so just click on it and while holding the mouse button down drag it to the right. You will see two red arrows above and below the bar which indicate where it is to be placed, so when these are visible to the right of the "Scroll On" and "Scroll Off" tabs, release the mouse button.You can now click on OK to save and close the task.
 
 
Now we need to create the two tasks which will either turn the screen scrolling off or on again. You will have to decide what commands you want the player to use, I myself use SCROFF (for Scroll Off) and SCRON (to turn screen scrolling back on again). So in the folder that you want these tasks to reside, right-click and choose NEW TASK. Call the first one Scroll Off (as screen scrolling is on by default) and in the command line box you just type scroff, and in the message box underneath type your completion message, e.g. "Screen Scrolling is now turned off, as below:
 
 
 
[[File:Scroff.jpg]]
 
 
 
" Click "Apply" to save what you have just done. Now click on the Restrictions tab and add the restriction "Variable _scroll must be equal to 0". In the message box for this restriction you should type "Screen Scrolling is already turned off." in case the player types "Scroff" when it is already off. Next you should click on the Actions tab and enter the action "Set variable _scroll to 1", then click on OK to save and close this new task.
 
 
To create the task for "Scroll On" you can do it the proper way and create a new task. However, one shortcut I frequently use is to copy and paste the first task you created and alter it accordingly. So right-click on the "Scroll Off" task and paste it into the same folder. Open the copied task and make the following changes: Change the title from "Scroll Off" to "Scroll On", the command line to "scron" and the completion message to "Screen Scrolling has now been turned back on." On the Restrictions tab alter the restriction to "Variable _scroll must be equal to 1" and the default message to "Screen Scrolling is already turned on." On the Actions tab change the action to "Set variable _scroll to 0". You can now click OK to save and close the task.
 
 
We will of course need to tell the player about the new options that are available to them and the simplest way of doing this can be a couple of lines At the bottom of the title page for your adventure, e.g. "To turn Screen Scrolling Off, type SCROFF and press Enter." and below that "To turn Screen Scrolling On again, type SCRON and press Enter."
 
 
Now you have given the player the option to turn screen scrolling off, you must allow for this when creating any task which alters the location text in any way with a LOOK action, for example if a previously hidden object is found by the PC and appears in the current location. What you need to do is make sure there is at least one blank line after the completion message for any such task, then create an alternate description. This is where we type the shortcut <mytext> into the message box for the alternate description so that the "keypress" message is substituted by the text override we created. Set the restriction for this message to "variable _scroll must be equal to 1 then display after default".
 
 
Now, if the player has chosen to turn screen scrolling off, when he or she performs an action which alters the location text, the screen will look like the image on the left and when any key is pressed the screen will refresh to the image on the right with the updated location text:
 
 
 
[[File:Game Screen.jpg]]
 
  
  
  
 +
<TABLE ALIGN=CENTER BORDER=1 WIDTH="50%"><TD WIDTH="33%" ALIGN=CENTER>[[Functions|<<< Functions]]</TD><TD WIDTH="34%" ALIGN=CENTER>[[Main Page#Intermediate Tutorials|Main Page]]</TD><TD ALIGN=CENTER>[[Adding a new command|Adding a new command >>>]]</TD></TABLE>
 
[[Category:Intermediate Tutorials]]
 
[[Category:Intermediate Tutorials]]

Revision as of 06:09, 7 January 2013

Create a locked door that can be opened with a key?

  • Make sure the two rooms that will be connected by the door are created and connected.
  • Create a group of type location and make the two rooms part of this group. This will allow you to make the door visible from the locations at each side of the door.
  • Create a new object of type dynamic - This is your key.
  • Create a new object of type static - This is your door.
    • Select Location Group from the Location of Object dropdown.
    • Select the door location group from the At Location Group dropdown.
    • Select the following properties for your door:
      • Object can be opened and closed (Selecting this allows you to select the next two dependant properties).
      • Open status - Leave as open for now.
      • Object can be locked (This adds Locked to the Open Status selections, and the Key for lock property).
      • Change Open status to locked.
      • Select your key object from the Key for lock dropdown.
  • Edit one of your door locations and select the Directions tab.
  • Add a new restriction to the direction that leads to the otherside of the door. Make this restriction:
    • Object - your door - must - be in state - open
    • Depending on your settings this restriction may be copied to the second location. If not duplicate the restriction in the second location.
  • The door will now block progress unless it is open.
  • Note: As of version 5.0.16 there is no Lock command in the standard library. You will need to create this yourself.

Create a torch that will run out of batteries?

This really needs integer properties to work, so will do a writeup once that's done. It could be done using a variable of course...

Create a dark room that the player needs a light source to see?

Add any rooms that would be dark without a light source to the location group Dark Locations.

Add any objects that are light sources to the object group Light Sources.

The Dark Locations group should override the short location description, and the tasks should prevent looking and examining things whilst in a dark location without a light source.

Make a lift platform rise up out of reach when i pull a lever

  • Create a static object in a room to represent the platform or elevator, and make it a container or surface so it can hold other objects.
    • Press the 'Add new property' button to create an Object Property and make it a state list with two states, eg. 'up' and 'down' and give the property a name eg. 'Lift Position'.
    • Make sure its selected for the lift object and set it to 'down'.
  • Create a Lever as a static object (either in the same room or another location).
  • Create a specific task that overrides 'pull' for your Lever object.
    • If the lever and lift are in the same room then write some text describing the lift going up, otherwise just say 'You hear the sound of machinery operating for a few seconds'
    • Give it a restriction 'Property Lift Position for Object Lift must be Down' and a failure message 'The Lever is already in the pulled position - you could try pushing it'
    • Create an action 'Set Property Lift Position of Object Lift to up'.
  • Do the opposite for a 'push lever' specific task, so when lift is up push lever will bring it down.

Now we need to describe the lift being in two different places, floor level and high in the air, in both the room description and the lift description. In both cases use the default description in the text box to describe the rest of the room, then add two Alternate Descriptions, one with the Restriction 'Property Lift Position for Object Lift must be Down' and describing the lift at ground level, and the other with 'Lift must be up' describing it high in the air and out of reach.

Now we just need to make sure that anything placed on (or in) the lift is out of reach when its raised.

  • Create a new location thats not connected to anywhere else.
  • In the pull lever task add an action to move everything on (or in) the lift to the new location.
  • In the push lever task add an action to move everything in the new location to on (or in) the lift.

Use a button to toggle between two different states

Using the previous example of a lift, rename the Lever to a Button, then change both the push and pull lever tasks to 'press button' tasks. Remove the text from the restrictions on both tasks. When the lift is down, only the task that raises the lift will pass its restriction. When the lift is up, only the task that lowers the lift will pass its restriction.

Create a notebook that the player can write in

  • Create a readable object (both "This object is readable" and "and description when read" selected).
  • Create a text variable called 'T1'
  • Use a "write %text%" general task to add lines to it, with the actions:

Set variable T1 to %PropertyValue[Object1,ReadText]%&"< br >"&%text%

(Where Object1 is the key of the notebook object)

and

Set property '... and description when read' of object 'notebook' to '%T1%

Example: Notepad.taf

You could also add a restriction that the player must be carrying the notebook to be able to write in it.

Ask the player to enter their gender when the game starts

Set the Player's gender property to "Male", and create a text variable called "NewGender"

Create a system task called "SetGender" that has the restriction [ Variable ][ NewGender ][ must be ][ equal to ][ "female" ]

Add the action [ Set property ][ The Player Character ][ Gender ] to [ Female ]


Create another system task "AutoRun" set to execute "Immediately" with two actions:

[ Set Variable ] [ NewGender ] to [ %PopUpChoice["Are you of the Female gender?", "female", "male"]% ]

[ Execute task ] [ SetGender ]

PopupChoice.taf


Switch the player point-of-view between different characters

The player does not need to always control the same character in the game, but can easily be switched to a different character using the following action:

[ Move ] [ Character ] [ The Player Character ] [ to switch places with ] [Character to play as].

Note that [ The Player Character ] (or %Player% if used in a function) will always return the character currently being controlled by the player, whereas Player is just the default name given to the character the player starts off controlling. So these will be one and the same in most cases, until a switch places action is run.

Display on screen the text that the player has typed in?

Say for example when we ASK a character ABOUT a subject, e.g. ASK FRED ABOUT BUSES, if what the player types in does not match the referenced text BUSES, e.g. if the player types in ASK FRED ABOUT CARS, unless the programmer has created a conversation topic with keywords that match that input, the default response from ADRIFT is "Fred doesn't appear to understand you."

At the present moment we are unable to directly edit the default message, however we can use a text override and the %text% function to change the message to one that will display what the player typed in, i.e. "CARS".

The first thing you need to do is open the Text Overrides folder which you will find in the main folders window. Right-click anywhere in the text overrides folder and a menu will appear, left-click on "Add Text Override" at the top and a new text override dialogue box will open. In the top dialogue box you type the text to be replaced, in this case "doesn't appear to understand you." (without the quotes!). Note that we do not specify the character name as we want to use this for all characters. In the bottom dialogue box we will type the text that you want to replace the default text with, e.g. "doesn't know anything about %text%." (again, without the quotes.) You will note that %text% will change colour to green. Lastly, click on the OK button to save the text override.

Now, when the player types in ASK FRED ABOUT CARS, the message that appears will be "Fred doesn't know anything about cars." You can use the %text% function in other ways to display the players input in messages.

Give commands to characters using format "Karen, get me a coffee"

Create a general task as follows:

Command: %character%{,} %text%

Restrictions: The player must have seen referenced character AND The player must be in the same location as referenced character.

Action: Say %text% to referenced character.

Task is repeatable.

To create commands for npc's to follow, you will need to make conversation items for them. Check the box for general commands and leave the rest unchecked. In the command field, type the syntax of the instruction as the player would type it.

For example, "take crate" would be in the command field and in game the player could tell the npc to take the crate by typing "say take crate to robot" or "robot, take crate". While both would work, the latter is more natural and follows the syntax for giving commands to npc's that are used in other games.


<<< FunctionsMain PageAdding a new command >>>