Xelagot script by Who 230147


RPG Character Script - Voice activated - This is a "StringList" example for holding data files

Script
This script allows you to create and view simple character stats by answering the bot with the relative information.
This is designed as a very very simple example in response to the number of people who ask me how to do this.
From learning this script you should be able to create your own useful and complex RPG data scripts.
[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0°

[Script]
# by Who, 230147 last modified/created August 2000
#
# This is a simple verbal character generator script. It is designed to
# show the use of stringlists in keeping player records for a game or
# rpg. Although this script only verbally creates or views it is quite
# simple to add modification by bots or aother people.
# Note: the variable $dm is used to state your name so that the bot
# listens only to you. This avoids it getting any chatter from people
# about you at the time. Note the botscript will take any response as
# truth so you have to answer correctly.
# Please change the line after $dm and place your own name there.
# Note: the data will be saved in the bots script folder and the file
# will be called characters.txt - make sure you don't already have
# a script of this name as it will be overwritten.
var /s_mydata, $data, $temp, $player, &player, $dm
var %d1, $d1, %d2, $d2, %d3, $d3, %d4, $d4, %d5, $d5, %d6, %gold, %d7, $d7, %d8, $d8, %d9, $d9, %d10, $d10

$data = Characters.txt
%d1 = 1
%d2 = 2
%d3 = 3
%d4 = 4
%d5 = 5
%d6 = 6
%d7 = 7
%d8 = 8
%d9 = 9
%d10 = 10

Label adventure
$dm = Who          #<------------- Put your name here!!!!!! (instead of mine)
OnChatEvent Chat1
Say Do you wish to VIEW a character or CREATE a character?
Label adv2
Goto adv2
Label character
OnChatEvent Chat
Say Hello, Please state the characters name?
Label adv1
GoTo adv1
Label name
$d1 = $t
SListLoad /s_mydata $data
SListSetField /s_mydata $d1 %d1 $d1
SListSave /s_mydata $data
OnChatEvent Gender
Say What is their gender? male or female
label loop
GoTo loop
Label gender
OnChatEvent
$d2 = $t
SListSetField /s_mydata $d1 %d2 $d2
SListSave /s_mydata $data
Say What is their age?
OnChatEvent Age
label loop1
GoTo loop1
label age
OnChatEvent
$d3 = $t
SListSetField /s_mydata $d1 %d3 $d3
SListSave /s_mydata $data
Say What is the colour of their hair?
OnChatEvent Hair
label loop2
GoTo loop2
Label hair
OnChatEvent
$d4 = $t
SListSetField /s_mydata $d1 %d4 $d4
SListSave /s_mydata $data
Say What is the colour of their eyes?
OnChatEvent Eyes
label loop3
GoTo loop3
Label eyes
OnChatEvent
$d5 = $t
SListSetField /s_mydata $d1 %d5 $d5
SListSave /s_mydata $data
Say How much gold do they have?
OnChatEvent gold
label loop4
GoTo loop4
Label gold
%gold = $t
SListSetField /s_mydata $d1 %d6 %gold
SListSave /s_mydata $data
Sayconcat "Character " $player " completed"
ResetTo adventure

Label stats
OnChatEvent person
Say Please name character.
Label stats1
GoTo stats1
Label stats2
$temp = $t
SListLoad /s_mydata $data
SListGetFields /s_mydata $temp 6 $d1 $d2 $d3 $d4 $d5 %gold
IfString $d1 <> $t Goto stats3
Sayconcat $temp " is a " $d3 " year old " $d2 " with " $d4 " hair and " $d5 " eyes. "
Wait 3
Sayconcat $temp " is carrying " %gold " gold"
Wait 2
ResetTo adventure
Label stats3
Say There doesn't appear to be anyone by that name
ResetTo adventure

End

Event person
  GetChatPerson &p
  GetChatLine $t
  GetName $c &p
IfString $c <> $dm EndEvent
ResetTo stats2
EndEvent

Event Chat1
  GetChatPerson &p
  GetChatLine $t
  GetName $c &p
  GetPosition @a &p
IfString $c <> $dm EndEvent
IfString $t = "view" ResetTo stats
IfString $t = "create" ResetTo character
EndEvent

Event Chat
  GetChatPerson &p
  GetChatLine $t
  GetName $c &p
IfString $c <> $dm EndEvent
ResetTo name
EndEvent

Event Gender
  GetChatPerson &p
  GetChatLine $t
  GetName $c &p
  GetPosition @a &p
IfString $c <> $dm EndEvent
IfString $t = "male" ResetTo gender
IfString $t = "female" ResetTo gender
EndEvent

Event Age
  GetChatPerson &p
  GetChatLine $t
  GetName $c &p
  GetPosition @a &p
IfString $c <> $dm EndEvent
ResetTo age
EndEvent

Event Hair
  GetChatPerson &p
  GetChatLine $t
  GetName $c &p
  GetPosition @a &p
IfString $c <> $dm EndEvent
ResetTo hair
EndEvent

Event Eyes
  GetChatPerson &p
  GetChatLine $t
  GetName $c &p
  GetPosition @a &p
IfString $c <> $dm EndEvent
ResetTo eyes
EndEvent

Event Gold
  GetChatPerson &p
  GetChatLine $t
  GetName $c &p
  GetPosition @a &p
IfString $c <> $dm EndEvent
ResetTo gold
EndEvent

Alternativly you can download the script by selecting this link: char.zip