VirtualFriend™ 2 HyperText
All the hyper text codes of VirtualFriend.
Last Modified 19990528

This document describes some of the more technical aspects of VirtualFriend 2.
Before you use these commands, we recommend trying to get the job done using the built-in scripting tools of VirtualFriend.
If you Print this document, use Landscape Mode!

VirtualFriend is a trademark of Haptek Inc.

OverView
Syntax
Event Reference
Action Reference
Buttons Reference
Notes
Document History
What is Haptek™ Hypertext ?
Haptek™ Hypertext is similar to other forms of hypertext, such as HTML, but is specific to Haptek™'s applications.  It is not HTML. 

The Basic Idea behind hypertext is to give the author of a VirtualFriend™ script more control over the program and the viewer's experience. For example, if you want Roswell the alien to say "OW!" when you click the mouse on him, use HyperText! More complicated examples of hypertext include re-defining the operation of  the border buttons, and the creation of in-the-window animated buttons that float in front of the VirtualFriend™. 

The Model by which hypertext works is this: 
Certain things the user does in VirtualFriend™ are considered "Events", or triggers.  These are things like clicking on the VirtualFriend™, pressing one of the border buttons, pressing the Home button, etc. Any Event may be linked up to any of the "Actions" defined in VirtualFriend™.  Actions are things like loading a new background, switching to a new script, hiding the control panel, or starting ro stopping the CD player.  Any Event may trigger any Action.  HyperText is the way the author of a script connects events to actions. 
Along with matching up Events with Actions, a "Parameter" may also be associated with an action.  The parameter is a string, which is typically a filename, but can also be commands specific to that action. See Syntax, below. 

Some Examples: The following are lines which could be included in a .vfe script, or typed in singly to the text-entry window. Each line is given exactly as it would appear in a script, or ready to be copy-and-pasted into the text entry window, followed by a description of the example in italics.  Also look at the scripts which ship with VirtualFriend™.

\ht_vflclick_switchto_[leftclick.vfe] \ht_vfrclick_switchto_[rightclick.vfe] 
If the user left-clicks on any VirtualFriend™, immediately load and play the script "leftclick.vfe". If the user right-clicks, switch to "rightclick.vfe"

\ht_switchto_[nextscript.vfe] 
Load and begin playing the script "nextscript.vfe".  This would typically be used at the bottom of a script, to continue speaking in another one.  For example, both "leftclick.vfe" and "rightclick.vfe" from the previous example could contain this line at the bottom, and then when the user left-clicked, he or she would first see leftclick.vfe, followed by nextscript.vfe, and similarly if he or she had right-clicked.

\ht_background_[bg128.jpg] 
Load the image "bg128.jpg" into the background.

 

Syntax of a hypertext command:
 
Events are things which the User has Done, such as clicked the mouse or pushed a particular button. 
Actions are things which the Program Does, such as switch to a different text file. 
Events and actions are case-insensitive. 
Arguments apply to the Action.  Arguments vary from action to action.  For example, the speak action interprets Argument as a sentence to speak, while the background action interprets it as the filename of a background image. 
Format Example
\ht_EVENT_ACTION_[ARGUMENT] \ht_vflclick_speak_[You clicked me!] 
When the left mouse button is clicked on the VirtualFriend™, 
say "You clicked on me!".
\ht_ACTION_[ARGUMENT] \ht_speak_[You clicked me!] 
say "You clicked on me!". 
This is used to perform an action right away, without waiting for an event.
\ht_EVENT \ht_vflclick 
When the left mouse button is clicked on the VirtualFriend™, 
do nothing. 
This is used to clear out the associated action from an event. Note
"Quotes" may be used instead of [brackets], but brackets are recommended.  If the argument has no spaces in it, neither quotes nor brackets are neccessary.


 
 
EVENTS
Command Description Examples See Also
all All events. \ht_all
Clear all events 
\ht_all_speak_"An Event!"
Say "An Event!" when any event happens.
 
CmdRapAll Big Play button.    
CmdSage Wisdom button.    
CmdShutUp Big ShutUp button.    
CmdReset Home button.    
WrldLClick Left Mouse click on the world. \ht_vflclick_speak_"Ya Missed Me!"  
WrldRClick Right Mouse click on the world. \ht_vfrclick_speak_"Try again!"  
VFLClick Left Mouse click on any vf. \ht_vflclick_speak_"Ya Got Me!"  
VFRClick Right Mouse click on any vf. \ht_vfrclick_switchto_"choices.txt"  
VF0LClick Left Mouse click on first vf. 
This event happens before the vflclick event, but they both do happen.
\ht_vf0lclick_html_"http://www.roswell.com"  
VF0RClick Right Mouse click on first vf. 
Note that when the user clicks the right mouse button, it does not switch friends.
   
VF1LClick Second vf.    
VF1RClick      
VF2LClick Third vf.    
VF2RClick      
VF3LClick Fourth vf.    
VF3RClick      
ClipArtAny Any clipart button was pressed. \ht_clipartany_speak_"good."  
ClipArtLeft (Not implemented) 
A left-side clipart button was pressed.
   
ClipArtTop (Not implemented) 
A top clipart button was pressed.
   
ClipArtTop1 (Not implemented) 
A first row top clipart button was pressed.
   
ClipArtTop2 (Not implemented) 
A second row top clipart button was pressed.
   
ClipArtRight (Not implemented) 
A right-side clipart button was pressed.
   
ButPanelShow Show controls button. \ht_butpanelshow_speak_"Now you see the controls" PanelShow
ButPanelShut Shut control panels button.   PanelShow
ButPanelNext Next control panels button.   PanelShow
ButBigEdit Big Edit button. \ht_butbigedit_speak_"Here is a big edit for you." BigEd
KeyEnter The enter key in the main speech-input field.    
KeyAny Any key except enter in the main speech-input field. \ht_keyany_speak_[Good \ht_keyany_speak[Okay]]  
 

 
 
ACTIONS
Command Description Arguments  Examples See Also
(none) The Default Action for an event.    \ht_all
Clear all events 
\ht_vflclick
Clear the Left Click event.
 
switchto Aborts the current sentence, loads a new script, and begins playing it. Filename of script \ht_switchto_[hey.vfe] html
speak Speak the argument. 
This will not happen if speech is already happening. 
Note that with brackets, you may nest hypertext commands with the speak action.
Sentence to speak. \ht_speak_"Here we are."
\ht_keyany_speak_[Good
(continued) 
\ht_keyany_speak[Okay]]
1
wisdom Generates and speaks a new wisdom. Name of wisdom, ("wise") for default. \ht_wisdom  
background Load an image to the background. 
Image sizes should be a power of 2 in both directions.
(256x256, 512x512, etc) 
Filename of image. 
May be .jpg or .bmp; .hap files do NOT work.
\ht_background_"bg128.jpg"
texture Load a texture to the current vf. Filename of image. 
Must be .hap.
\ht_texture_"goof.hap"
nptexnn PreLoad a Non-Proprietary Texture to an n.p.-slot. 
nn is 00 - 99.
Filename of image. 
May be .jpg or .bmp; .hap files do NOT work.
\ht_ptex00_"B1Up.jpg"
(continued) 
\ht_ptex01_"B1Dn1.bmp"
ptexnn PreLoad a Proprietary Texture to a p.-slot. 
nn is 00 - 99.
Filename of image. 
Must be .hap.
\ht_ptex00_"faceA.hap"
(continued) 
\ht_ptex01_"faceB.hap"
switchtexnn Switch facial texture to pre-loaded texture. 
Uses the P bank.
     
switchbackgroundnn Switch to pre-loaded background. 
Uses the NP bank.
     
cd Issue a CD command. [play cdaudio]
[stop cdaudio]
[next]
[previous]
[pause]
[resume]
[set cdaudio door open]
[set cdaudio door closed]

play from a track until end of cd 
[play cdaudio from X]

play from track X stopping at the beggining of track Y 
[play cdaudio from X toi Y]

change the volume of the CD 
[set cdaudio audio all off]
[set cdaudio audio all on]
[set cdaudio left off]
[set cdaudio left on]
[set cdaudio right off]
[set cdaudio right on]
 

 

\ht_cd_"next"
 
 
 
 
 
 
 
 

\ht_cd_[play cdaudio from 5]
 
 

\ht_cd_[play cdaudio from 1 to 2]

you can be more specific if you want, and specify from track:minute:second:millisecond  to track:minute:second:millisecond like this: 
\ht_cd_[play cdaudio from 01:00:32:00 to 12:55:54:22]

\ht_vflclick_cd_[play cdaudio]

 
lights Control lights. 
The lights need to be already in the scene; i.e. specified in the .vf file. 
Only for directional lights.
[L n C r g b P1 x y z]
n = light number 
rgb = color 
xyz = Direction 
Note, this pattern may be repeated any number of times within the argument, to control all the lights in one fell swoop. 
Note, n = -1 is the ambient light.
\ht_lights_[L 1 C 1 0 0 P1 0 0 -1 L 2 C 0 1 0]
Set light 1 to be red, pointing away from camera, light 2 to be blue, without changing its direction. 
 
guibut Special GUI Buttons (clipart buttons) commands. [ON] - Show buttons 
[OFF] - Hide Buttons 
[LOAD name] - Load a preset set.
\ht_vflclick_guibut_on
\ht_vfrclick_guibut_off
\ht_guibut_[load CDPlayer]
 
    [but= [bnn] txt= [Text Content] bmp= [filename]]
Completely redfine a clipart button. 
b = bank: 0, 1, 2 for left, top, right. 
nn = number: 0 to 15 for top bank, 0 to 6 for left and right banks.
\ht_guibut_[
but= [L01]
txt= [\ht_texture_"data/bmp/yammap.hap" \ya I am a yam!]
bmp= [data/bmp/yam.hap]]
 
html Send a file to the default Web Browser. The URL. \ht_html_[http://www.haptek.com] 
\ht_html_[file://c:\myfile.html]
htmlcon
htmlcon Special commands that control the html action. [prefix pfx]
Sets the url prefix. 
This prefix is always prepended to any URL by the html action.  This to make it somewhat easier to transition from local URLs to online URLs. 
pfx may include spaces.
\ht_htmlcon_[prefix http://www.haptek.com/]
Now \ht_html_[index.html] will bring up 
http://www.haptek.com/index.html 

\ht_htmlcon_[prefix file://c:\localsite\]
Now \ht_html_[index.html] will bring up 
file://c:\localsite\index.html 
 

html
Download a file from the web Not implemented.    html
htmlcon
panelshow Show or shut the control panel. NAME
SHUT
NEXT

  "show" causes the last panel  shown to be shown. Open and Close are synonyms for Show and Shut.

\ht_panelshow_"show"
\ht_panelshow_"next"
\ht_panelshow_"shut"
\ht_panelshow_"Chat"
\ht_panelshow_"Customize"
\ht_panelshow_"Script"
\ht_panelshow_"Licensing"
\ht_panelshow_"Authoring"
BPShw
BPNxt
BPSht
BigEd Show or shut a Big Edit. SHOW n
SHUT n

n is optional, it is the number of the big edit window to use.  If it is omitted, the next window in line is used. 
Open and Close are synonyms for Show and Shut. 
 

\ht_biged_show
\ht_biged_"shut"
BBE
         
         
         

BUTTON COMMANDS
 
The list of button commands
Examples

Description:

 The Hyper Buttons  can be thought of as sprites, regions, animations, pictures, or buttons that can be created at runtime .  The  Hyper Buttons can also be though of as 3d objects in the world with you're character that can be set at a specific depth (that is to say, your character can hide behind them). They define an area in the VirtualFriend™ Window which can trigger an action when the User clicks it. This region can consist of any number of images which can play like an animation, or can contain no images, and simply defines an invisible, but active, region in the VirtualFriend™ character Window. You can think of a button with no images as a Hotspot on the background image(like a hotspot on an image map on a web page). 

 The Coordinate System used to define the button world:

 In order for your buttons to always appear in the same place in your characters's ever changing 
world, the coordinate system is based on percentages of the entire window (that's the window where your vf lives) 
0 is 0%, and, 1 is 100%, hence, if you wanted to specify 32% you would type .32. 

Also, the coordinate system starts from the bottom left corner with x increasing to the right, and y increasing 
uppward.  (play arround with defining the region, and it'll become more clear, see below for more details
 

Button Images:

 The images you define a button with need to hold to a couple of rules. 
 1: they must be of dimension that are a power of 2. Such as 32 X 32 or 128 X 1024 etc... 
 2: the upper left pixel in the image will be used as a transparent color, so make sure it's the 
  color you want it to be, or half your image could be invisible. 

NOTE: Currently the only working transparent colors are White (255,255,255) and Black (0,0,0) 

Button Types:

These two letter names will be used in defining and redefining the type of a button 

pp     push pop button.           This is a button that displays one image when at rest, and then a two frame animation when clicked 

tg      toggle button.                This is a button which toggles through the images contained in the button. Each time it is clicked, it 
                                              it goes to the next image in the button. You could use this to do a slide show. 

an     animated button.           This currently defaults to an animate once button. 
ao     animate once button.     This button plays through all the images in the button and finishes with the first image displayed. 

al      animate loop button.     This is a button that play through all the images in the button over and over, in a loop. 
 
 
 

Defining a Button:
 

 As with all hypertext commands, the command to define a hyper button begins with \ht. 
The generalized full command apears like this: 

\ht_defbuttonXX_type_action_" x1 , y1 , x2 , y2 , command/filename , image1.bmp , image2.bmp , ... , imageN.bmp" 
 

 where 'XX' is a numeric identifier such as 01 or 99 (don't forget the 0 in front if there is only 1 number.) 
         (you will use this identifier in any future corespondence with the button you created.) 

 where 'type' is one of the button types described above

 where 'action' is one of the actions described above

 where  'x1 , y1 , x2 , y2 , ' define the rectangular region the button lives in. 
 x1 and y1 specify one corner, and x2 and y2 specify the other corner diagonally related to the first 
 corner. 

 where  'command/filename' is the command/filename/parameter associated with the specified action. 

 where  'image1.bmp , image2.bmp , ... , imagen.bmp' is an optional list of images that belong to this button 
 Take note that the order in which they are listed is the order in which they will appear if animated 
 or toggled. There can be 1, none, or many images listed. 
 

Examples:
 
 

Example 1: A Push pop button

 Suppose that you have 2 images called 'button1.bmp' and 'button2.bmp' and you want your button to look 
 like a normal button, such that when you push it it shows your button2.bmp image, then it shows button1.bmp 
 again.  Now, suppose that when the button is clicked, you want your character to say "Hello Friend". 
 and you want it to be in the upper left quarter of your virtual friends world. You also want this button 
 to be known as 01. 

 your command would look like: 
   \ht_defbutton01_pp_speak_"0 , 0.5 , 0.5 , 0 , Hello Friend , button1.bmp , button2.bmp"

 that's it! 
 
 
 
 
 

Example 2: A button with no images / An invisible region

 \ht_defbutton05_pp_speak_"0 , 0.5 , 0.5 , 0 , I love you , "

  This would define a region in the upper left corner that would make your character say,"Hello Friend" 
 any time you clicked in it. 
 

 NOTE:  If there are no images, it really doesn't matter what you put as the type of button, 
as long as you put something! 
 
 
 
 
 
 

Example 3: Animating in a loop:

  \ht_defbutton05_al_speak_"0 , 0.5 , 0.5 , 0 , Hello Friend , f1.bmp , f2.bmp , f3.bmp , f4.bmp" 
 
 
 
 

Example 4: Animating once:

  \ht_defbutton05_ao_speak_"0 , 0.5 , 0.5 , 0 , Hello Friend , f1.bmp , f2.bmp , f3.bmp , f4.bmp"

Notice that the only difference between both of these examples is the type.  You specify 'al' for your animation 
to run in a loop, and you specify ao  for your animation to run once whenever it is activated. 

If your animation is running in a loop, that doesn't mean that the action associated with that button will run in a 
loop as well.  The action will still only happen when the button is activated(when the user clicks it). 
 
 

 

Command Description Argument Examples See Also
defbuttonnn  Defines a new button  the syntax is a little lengthy, 
See above for description .
See above for Examples.  
shownn If a button is hidden, makes the button visible. nn : the button identifier  \ht_show00  
hidenn If a button is visible, makes the button hidden. nn : the button identifier \ht_hide00  
settypenn Redifines the type of a button nn : the button identifier 

type identifier.

\ht_settype00_pp
\ht_settype01_tg
\ht_settype20_al
 
setspeednn Sets the speed in milliseconds that each frame should display for. nn : the button identifier 

[XXXXX]: The number of milliseconds to display each image in the button.

\ht_setspeed01_"1000"  
setactionnn Reset the action to be performed when a button is clicked. nn : the button identifier 
action_[parameter]
\ht_setaction01_speak_[Hi]
\ht_setaction00_switchto[x.txt]
 
activatenn This works exactly as though the user had clicked the button. It will play any animation,or toggle to the next frame, as well as perform whatever action is associated with the button. nn : the button identifier \ht_activate00

If you specify all buttons, like so: 
\ht_activate-1
the actions of the individual buttons will not be executed.

 
playanimenn This is just like the activatenn command, but the action  associated with the button is not performed. nn : the button identifier \ht_playanime00  
setdepthnn Sets the depth of the button relative to the button frame. nn : the button identifier 
[XXXXX]:the distance away from the button depth frame. 
The closest distance is -898 
and the furthest distance is 99 
\ht_setdepth01_[-500]
\ht_setdepth02_[-898]
3.
setlimitsnn This sets the "limits" of the animation of a button.  With this command you can tell the button what should be the first image diplayed, and what should be the last image displayed. The animation will then start on the first image, play all images in between, and end on the last image.  nn : the button identifier 
[first, last]: the first and last frame of the nanimation.
this is the default setting. 
\ht_setlimits00_[0,0]

start on frame 0 and end on frame 4 without going back to frame 0 
\ht_setlimits00_[0,4]

it would be nice if this played the animation in reverse, but currently it doesn't work. 
\ht_setlimits00_[4,0]
 

 
redefregionnn The redefines the region occupied by the button in the VirtualFriend™ Software window. You can use this to make the button bigger and smaller.df nn : the button identifier 
[ X1 , Y1 , X2 , Y2]
the coordinates defining a rectangular region for the button.
\ht_redefregion00_[0 , 0 , 1 , 1]
this makes the button the entire size of the VirtualFriend™ Software window. 

\ht_redefregion05_[0 , 0.5 , 0.5 , 1]
this makes the button the upper left quarter of the VirtualFriend™ Software window.

 
         


 
 
NOTES
1. Speak Action: Nesting immediate speaks within immediate speaks seems to not work. 
For example, \ht_speak_[hello \ht_speak[there]] 
In fact it seems to break subsequent hypertext calls.
2. nn Button Identifier Number : For all button command except for defbutton, you can specify -1 as the number of the button to mean all buttons. 
For example, \ht_setdepth-1_" 500 " 
or                  \ht_settype-1_al 
3. Button depth: Currently if a button appears in front of the VirtualFriend™ and the user tries to click on the button, They actually  click on the character.  This is bad and should be fixed.
4. The "immediate" form of hypertext, "\ht_ACTION_[ARGUMENT]" is often limited to being used once per line in a script.  This is because VirtualFriend™ parses the entire line, and the last action assigned to an event is the one that gets used.  Exception: Realizing the hinderance of this, many Actions are reworked so that they do not affect other immediate actions given on the same line.  Examples include Background, Texture, and guibut.