Okay - hold on while I get things ready.
[EDIT] Got it!

Sorry if it's a bit rushed - it's 2:13 AM over here in Bahrain!!
Remember to copy and paste everything into your DB editor because it'll look ALOT

clearer
I've explained everything as if you were a beginner except for the last bit (lines 129-140). Don't hesistate to post the forum again regarding any doubts.
REM *********** CONVERSATION SYSTEM FOR RPGs ***************
REM By: HWT Date: 9th November 2005
`Set the camera stuff: just turning off Autocam so that I can position the camera
`where I want without a problem
autocam off
position camera 0,100,0
`Make environment: just a simple wireframe matrix (ground object) and positioning it
`so that everything's at the centre
make matrix 1,2500,2500,15,15
position matrix 1,-1250,0,-1250
rem Make The Participating Objects
`Step1: Make the player object (a sphere)
`Step2: Make the guy the player can talk to (a cube)
`Step3: Position the cube a little further away from the player
make object sphere 1,50
make object cube 2,50
position object 2,0,0,0
`Reset variables (you'll see what these are later)
timerstat=1
conversationstate=0
cursor=1
`Make arrays (you'll see what these are later) I load the data in the conversation.txt file
`into the conv$ array which will be used to display the text. It is much more convenient
`than having to clutter it all in 1 single program file
dim conv$(30) : load array "conversation.txt",conv$(30)
dim timer0(2)
REM MAIN PROGRAM LOOP
`Set the program to conduct a repeted loop at maximum sync rate
SYNC ON : SYNC RATE 0 : DO
rem Store old player positions: just a little trick to stop the player moving which is
`used when the conversation is being conducted.
oldx#=object position x(1)
oldz#=object position z(1)
rem Handle Movement of Player
`Step1: If up key is pressed then move the player object forward 5 units in the direction it's facing
`Step2: If down key is pressed then move the player object backward 5 units in the direciton it's facing
`Step3: If left key is pressed then rotate the player, about the y axis
` To do this all I've done is, first find the player object's current y angle,
` then subtract 3 from it and then find what is the wrapvalue for it. Wrapvalue
` just puts the angle within 0 to 360 degrees. E.g. wrapvalue of -10 is 360-10=350
`Step4: If right key is pressed then rotate the player about the yaxis in the opposite direciton
if upkey()=1 then move object 1,5
if downkey()=1 then move object 1,-5
if leftkey()=1 then yrotate object 1,wrapvalue(object angle y(1)-3.0 )
if rightkey()=1 then yrotate object 1,wrapvalue(object angle y(1)+3.0)
rem Updating Camera
`Step1: Point the camera at the player positions
`Step2: Position the camera so that it is above and behind the player. To do this, all
` I've done is find a position 50 units behind the player and use this to
` position the camera. I've done this using the newxvalue and newzvalue commands.
` This command is works like this. Give the current position of the player. Give
` the angle i.e. direction for calculating the new point. Give the number of
` units you want the point to be at. OF course, this is done for the x-axis AND
` z-axis because I need the camera to follow the player no matter what angle he
` faces.
point camera object position x(1),object position y(1),object position z(1)
position camera newxvalue(object position x(1),object angle y(1)+180.0,150.0),100,newzvalue(object position z(1),object angle y(1)+180.0,150.0)
rem Now we'll check for the interaction
`First, we use some maths to find the distance between the player and the guy he's talking
`to (let's call him Max). The formula for distance between 2 points in a straight line
`is [square root of] the difference between the square of each difference between the 2
`points (player's and `Max's position) for each axis (x and z). Sorry if you didn't
`understand that :) Search it out at google.com
playernpcx#=object position x(2)-object position x(1)
playernpcz#=object position z(2)-object position z(1)
distance#=sqrt( abs((playernpcx#^2) - (playernpcz#^2)) )
`If the distance is close enough, we'll indicate that it's possible to talk simply
`but putting the text "talk" above the player object's screen positions (object screen x
`and object screen y commands). The Set Text Opaque command is just to give an opaque
`background for the text.
if distance#<=55.0 then set text opaque : center text object screen x(1),object screen y(1)-100," TALK "
`If the distance is close enough and the conversation HAS NOT already been done (which
`is found out but the conversationstate variable), then ...
if distance#<=55.0 and conversationstate<>2
`... check if the enter key is pressed; if it is then change the conversationstate
`variable to 1; this is just a code number to indicate that the conversation must be
`conducted (see below)
if returnkey()=1 then conversationstate=1
endif
`If the conversation is going AND if the conversation hasn't reached it's end (which is
`indicated by the Cursor variable which is seen below).
IF CONVERSATIONSTATE=1 & CURSOR<=19
`Fix the position of the player object
position object 1,oldx#,0,oldz#
`Now we'll go thru all the lines of text in the array
`Here's a little trick for getting accurate time :) all I do is take the system time
`(using the "timer" command) at the first instant and store it in the array (first
`dimension of the array). Then I change the current array dimension to slot number 2
`using the timerstat variable and then continue to take the time.
timer0(timerstat)=timer() : timerstat=2 : timer0(timerstat)=timer()
`Now I just check the difference between the current time and the time at the first
`instant - if this is < 3000 (which is 3 seconds in real time) then display the
`current line of text. The current of text is stored in the conv$ array whose current
`array dimension is denoted by the cursor variable (which changes because we want to
`change from 1 line to the next.
if timer0(2)-timer0(1)<=3000
text 0,300,conv$(cursor)
else
`If the 3 seconds are up, then reset all the variables to start it all over again
`Also, increment the cursor variable so that the next time the loop runs over this
`set of commands the next line of text will be displayed
inc cursor
timer0(1)=0
timer0(2)=0
timerstat=1
endif
`If the conversation has ended i.e. all the lines of text have been run through then
`change the conversationstate variable to 2. By doing this we block that code above
`(see line 84)
if cursor>=19 then conversationstate=2
ENDIF
rem Here I'm just having fun - you do NOT have to go over this part.
`Here, I'm just having fun, just making the NPC move away from the player whenever he
`approaches after the conversation is done
if conversationstate=2
playernpcx#=object position x(2)-object position x(1)
playernpcz#=object position z(2)-object position z(1)
distance#=sqrt( abs((playernpcx#^2) - (playernpcz#^2)) )
if distance#<maxdistance# then yrotate object 2,chosenangle# : move object 2,10 : maxdistance#=400 else maxdistance#=55.0 : chosenangle#=rnd(360)
endif
SYNC : LOOP
HelloWorld Tommorrow