//Use Split to create your string list
stringlist = Split("Blah Blah;Blah this;Blah that", ";")
//Use GetRandomInt to select one, and ListCount to get the range
n = GetRandomInt(0, ListCount(stringlist) - 1)
// Use StringListItem to get the value
msg("The NPC says, '" + StringListItem(stringlist, n) + ".'")
<object name="object1">
<object name="object2">
</object>
</object>
<object name="object3">
<attr name="objectlistx" type="objectlist">object2</attr>
</object>
game.day_integer_stringlist = split ("1;2;3;4;5;6;7", ";")
show menu ("What day is it?", game.day_integer_stringlist, false) {
game.day_string = StringdictionaryItem (game.day_stringdictionary, result)
}
game.day_stringlist = split ("sunday;monday;tuesday;wednesday;thursday;friday;saturday", ";")
show menu ("What day is it?", game.day_stringlist, false) {
game.day_string = StringdictionaryItem (game.day_stringdictionary, result)
}
// let's see if I can remember how to do this, lol ~ its been a while ... Credit goes to Pixie's Spell Library for this ingenius usage of Dictionaries:
<attr name="opposing_magic_elementals_stringdictionary" type="simplestringdictionary">fire=water;water=fire;air=earth;earth=air</attr>
ice_dragon.elemental = "water"
fireball_spell.elemental = "fire"
'Cast' Verb on your 'spell' Objects (specific, non-global, non-dynamic, example):
spell = GetObject (fireball_spell)
enemy = GetObject (ice_dragon)
if (spell.elemental = StringDictionaryItem (opposing_magic_elementals_stringdictionary, enemy.elemental) ) {
enemy.life = enemy.life - (spell.damage * 2)
msg ("You do double the damage to the enemy, using the correct~opposing spell for its elemental vulnerability~weakness!")
} else if (spell.elemental = enemy.elemental) {
enemy.life = enemy.life + spell.damage
msg ("Doh!, You used the same elemental spell as the enemy's elemental, healing it instead of damaging it! You idiot!")
} else {
enemy.life = enemy.life - spell.damage
msg ("Your elemental spell, being neither the same nor opposite of the enemy's elemental, thus does its normal damage to the enemy.")
}
game.team = split ("joe;jim;john", ";")
foreach (team_member, game.team) {
do (team_member,"run_laps_script_attribute")
// output result conceptually:
// joe.runs_laps_script_attribute -> joe runs laps
// jim.runs_laps_script_attribute -> jim runs laps
// john.runs_laps_script_attribute -> john runs laps
}
// and the exact same thing:
game.team = split ("joe;jim;john", ";")
foreach (x, game.team) {
do (x,"run_laps")
// output result conceptually:
// joe.runs_laps -> joe runs laps
// jim.runs_laps -> jim runs laps
// john.runs_laps -> john runs laps
}
// and the exact same thing:
game.team = split ("joe;jim;john", ";")
foreach (item, game.team) {
do (item,"run_laps")
// output result conceptually:
// joe.runs_laps -> joe runs laps
// jim.runs -> jim runs laps
// john.runs -> john runs laps
}
// and the exact same thing:
game.team = split ("joe;jim;john", ";")
foreach (blahblahblah, game.team) {
do (blahblahblah,"run_laps")
// output result conceptually:
// joe.runs_laps -> joe runs laps
// jim.runs -> jim runs laps
// john.runs -> john runs laps
}
// Objectlist:
game.team = split ("joe;jim;john;jeff;jake;job;jab", ";")
for (team_member,0,0) {
do (ObjectListItem(game.team,team_member),"run_laps")
// joe.run_laps
}
for (team_member,6,6) {
do (ObjectListItem(game.team,team_member),"run_laps")
// jab.run_laps
}
for (team_member,2,2) {
do (ObjectListItem(game.team,team_member),"run_laps")
// john.run_laps
}
for (team_member,3,3) {
do (ObjectListItem(game.team,team_member),"run_laps")
// jeff.run_laps
}
for (team_member,0,2) {
do (ObjectListItem(game.team,team_member),"run_laps")
// joe.run_laps
// jim.run_laps
// john.run_laps
}
for (team_member,3,6) {
do (ObjectListItem(game.team,team_member),"run_laps")
// jeff.run_laps
// jake.run_laps
// job.run_laps
// jab.run_laps
}
for (team_member,0,6) {
do (ObjectListItem(game.team,team_member),"run_laps")
// joe.run_laps
// jim.run_laps
// john.run_laps
// jeff.run_laps
// jake.run_laps
// job.run_laps
// jab.run_laps
}
for (team_member,0,6,1) {
do (ObjectListItem(game.team,team_member),"run_laps")
// joe.run_laps
// jim.run_laps
// john.run_laps
// jeff.run_laps
// jake.run_laps
// job.run_laps
// jab.run_laps
}
for (team_member,0,6,2) {
do (ObjectListItem(game.team,team_member),"run_laps")
// joe.run_laps
// john.run_laps
// jake.run_laps
// jab.run_laps
}
for (team_member,0,6,3) {
do (ObjectListItem(game.team,team_member),"run_laps")
// joe.run_laps
// jeff.run_laps
// jab.run_laps
}
for (team_member,0,6,4) {
do (ObjectListItem(game.team,team_member),"run_laps")
// joe.run_laps
// jake.run_laps
}
for (team_member,0,6,5) {
do (ObjectListItem(game.team,team_member),"run_laps")
// joe.run_laps
// job.run_laps
}
for (team_member,2,6,1) {
do (ObjectListItem(game.team,team_member),"run_laps")
// john.run_laps
// jeff.run_laps
// jake.run_laps
// job.run_laps
// jab.run_laps
}
for (team_member,2,6,4) {
do (ObjectListItem(game.team,team_member),"run_laps")
// john.run_laps
// jab.run_laps
}
// I think you get the idea now... lol
Jay wrote:Is anyone paying you by the character?, lol
Jay wrote:As opposed to leaving an incorrect code sample with a caveat way at the end that someone might not get to (having to wade through all the volume that precedes it)?
<object name="Orc_Guard1">
<attr name="thingstosay" type="simplestringlist">xxx1;xxx2;xx3;etc4</attr>
</object>
<object name="Orc_Guard1">
<attr name="thingstosay" type="stringlist">
// whatever the syntax~format is its vertical form (which I really don't like... who+why use+uses this form???), I don't have it memorized~learned yet, I get a bit confused as to whether it needs 'key+item+value' or 'key~item + value', or just 'key~item~value', lol
</attr>
</object>
<function name="xxx">
Orc_Guard1.thingstosay = split ("xxx1;xxx2;xxx3;etc4", ";")
</function>
<function name="xxx">
Orc_Guard1.thingstosay = NewStringList ()
list add (Orc_Guard1.thingstosay, "xxx1")
list add (Orc_Guard1.thingstosay, "xxx2")
list add (Orc_Guard1.thingstosay, "xxx3")
list add (Orc_Guard1.thingstosay, "etc4")
</function>
<names type="stringlist">
<value>String one</value>
<value>String two</value>
<value>String three</value>
</names>
jaynabonne wrote:The stringlist format looks like this:<names type="stringlist">
<value>String one</value>
<value>String two</value>
<value>String three</value>
</names>
and it comes in really handy if your strings have semicolons in them. (You can't use the split or simplestringlist method in that case.) It's also more legible and less insanity inducing with longer strings.
string_list = Split("Blab blab|Blah; then blah", "|")
if (ListCount(Orc Guard.thingstosay) = 0) {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
msg ("The Orc says, '" + StringListItem(Orc Guard.thingstosay, n))
list remove (Orc Guard.thingstosay, StringListItem(Orc Guard.thingstosay, n))
}
else {
msg ("The Orc has nothing to say.")
}
The Pixie wrote:"jaynabonne"
The stringlist format looks like this:
<names type="stringlist">
<value>String one</value>
<value>String two</value>
<value>String three</value>
</names>
and it comes in really handy if your strings have semicolons in them. (You can't use the split or simplestringlist method in that case.) It's also more legible and less insanity inducing with longer strings.
You can still use Split, you just use a different character to split on. I often use the vertical pipe, |, as it is not used in prose.string_list = Split("Blab blab|Blah; then blah", "|")
Your way is perhaps better practice, but using Split way is less typing and is easier to show/explain on the forum as part of the code.
<thingstosay type="stringlist">
<value>An Ogre walks into a bar with flint and steel. The bartender lets him in but says, Don't start anything</value>
<value>Why do dwarves have such big nostrils?.......Because they have big fingers</value>
<value>Lord Talbert sent for his daughter, Vivian, North of here in Carn by the foothills of Shankspur Mountains but we stopped her coach and kidnapped her, she is being held in the prison hall.</value>
</thingstosay>
<speak type="script">
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
msg ("The Orc says, " + StringListItem(Orc Guard.thingstosay, n))
list remove (Orc Guard.thingstosay, StringListItem(Orc Guard.thingstosay, n))
if (ListCount (Orc Guard.thingstosay) = 0) {
// scripts
}
msg (Thats all I have for now.....)
</speak>
Forgewright wrote:By the way, how do you get those cool code boxes in you posts
[tag]Some text[/tag]
<thingstosay type="stringlist">
<value>"An Ogre walks into a bar with a flint and steel. The bartender lets him in but says, "Don't start anything."</value>
<value>"Why do dwarves have such big nostrils?.......Because they have big fingers."</value>
<value>"In the town of Carn, Lord Talbert sent for his daughter, Vivian, but we stopped her coach and kidnapped her just north of here by the foothills of Shankspur Mountains, she is being held in the prison hall."</value>
</thingstosay>
<displayverbs type="stringlist">
<value>Look at</value>
<value>Speak to</value>
<value>Attack</value>
</displayverbs>
<speak type="script">
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
}
else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
msg ("The Orc says, " + StringListItem(Orc Guard.thingstosay, n))
list remove (Orc Guard.thingstosay, StringListItem(Orc Guard.thingstosay, n))
}
</speak>
<attack type="script">
list remove (Orc Guard.displayverbs, "Look at")
list remove (Orc Guard.displayverbs, "Speak to")
this.temp_db = 0
this.temp_ob_now = 0
this.temp_ob_next = 0
this.temp_damage = 0
do (this, "doattack")
</attack>
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Eanatas">
<gameid>2b34a9e4-2f5d-4b03-b679-e3dbd5bf912b</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
<gridmap />
<appendobjectdescription />
<multiplecommands />
<defaultfontsize type="int">14</defaultfontsize>
<menufontsize type="int">10</menufontsize>
<attr name="autodescription_description" type="int">2</attr>
<attr name="autodescription_youcansee" type="int">4</attr>
<defaultbackground>WhiteSmoke</defaultbackground>
<pov type="object">player</pov>
<start type="script">
</start>
</game>
<command name="fly">
<script>
if (not IsSwitchedOn(player)) {
SwitchOn (player)
msg ("You spread your wings and take flight.")
}
else {
msg ("You are already flying.....")
}
</script>
</command>
<object name="Bristol">
<inherit name="editor_room" />
<object name="Mount Mormont">
<inherit name="editor_room" />
<object name="Karnuke Lair">
<inherit name="editor_room" />
<exit alias="south" to="Lair Ledge">
<inherit name="southdirection" />
</exit>
<exit alias="east" to="Stone Stairs">
<inherit name="eastdirection" />
</exit>
</object>
<object name="Stone Stairs">
<inherit name="editor_room" />
<exit alias="west" to="Karnuke Lair">
<inherit name="westdirection" />
</exit>
<exit alias="out" to="Forest Clearing">
<inherit name="outdirection" />
</exit>
</object>
<object name="Huge Cavern">
<inherit name="editor_room" />
<exit alias="west" to="Tunnel Ledge">
<inherit name="westdirection" />
</exit>
<exit alias="east" to="Lair Ledge">
<inherit name="eastdirection" />
</exit>
</object>
<object name="Lair Ledge">
<inherit name="editor_room" />
<exit alias="west" to="Huge Cavern">
<inherit name="westdirection" />
</exit>
<exit alias="north" to="Karnuke Lair">
<inherit name="northdirection" />
</exit>
</object>
<object name="Tunnel Ledge">
<inherit name="editor_room" />
<exit alias="west" to="Tunnel">
<inherit name="westdirection" />
</exit>
<exit alias="northwest" to="Prision Hall">
<inherit name="northwestdirection" />
</exit>
<object name="Lava Lake">
<inherit name="editor_object" />
</object>
<exit alias="east" to="Huge Cavern">
<inherit name="eastdirection" />
</exit>
</object>
<object name="Hags Den">
<inherit name="editor_room" />
<exit alias="north" to="Cave">
<inherit name="northdirection" />
</exit>
</object>
<object name="Cell 3">
<inherit name="editor_room" />
<exit alias="southwest" to="Prision Hall">
<inherit name="southwestdirection" />
</exit>
</object>
<object name="Cell 2">
<inherit name="editor_room" />
<exit alias="south" to="Prision Hall">
<inherit name="southdirection" />
</exit>
</object>
<object name="Cell 1">
<inherit name="editor_room" />
<exit alias="southeast" to="Prision Hall">
<inherit name="southeastdirection" />
</exit>
</object>
<object name="Prision Hall">
<inherit name="editor_room" />
<exit alias="west" to="Barrocks">
<inherit name="westdirection" />
</exit>
<exit alias="northwest" to="Cell 1">
<inherit name="northwestdirection" />
</exit>
<exit alias="north" to="Cell 2">
<inherit name="northdirection" />
</exit>
<exit alias="northeast" to="Cell 3">
<inherit name="northeastdirection" />
</exit>
<exit alias="southeast" to="Tunnel Ledge">
<inherit name="southeastdirection" />
</exit>
</object>
<object name="Supply">
<inherit name="editor_room" />
<exit alias="east" to="Barrocks">
<inherit name="eastdirection" />
</exit>
</object>
<object name="Tunnel">
<inherit name="editor_room" />
<alias>Tunnel</alias>
<exit alias="west" to="Cave">
<inherit name="westdirection" />
</exit>
<exit alias="east" to="Tunnel Ledge">
<inherit name="eastdirection" />
</exit>
<object name="Barrocks">
<inherit name="editor_room" />
<exit alias="south" to="Cave">
<inherit name="southdirection" />
</exit>
<exit alias="west" to="Supply">
<inherit name="westdirection" />
</exit>
<exit alias="east" to="Prision Hall">
<inherit name="eastdirection" />
</exit>
<object name="Orc Guard2">
<inherit name="editor_object" />
<inherit name="monster" />
<alias>Orc Guard</alias>
<attackasgroup />
<hurtbyweapon>A quit shot with your claws rips into the Guard.</hurtbyweapon>
<death>The Guard falls back and crashes to the floor.</death>
<lookwhendead>The guard didn't seem to want to fight. His face shows a certain puzzlement.</lookwhendead>
<level type="int">1</level>
<object name="Leather Helmet1">
<inherit name="editor_object" />
<inherit name="armour" />
<alias>Leather Helmet</alias>
<level type="int">1</level>
<price type="int">1</price>
</object>
<object name="Steel Mace">
<inherit name="editor_object" />
<inherit name="weapon" />
<damagedicesides type="int">6</damagedicesides>
<price type="int">3</price>
</object>
<object name="Woven Shirt">
<inherit name="editor_object" />
<inherit name="armour" />
</object>
<object name="Leather Boots">
<inherit name="editor_object" />
<inherit name="armour" />
<level type="int">1</level>
<price type="int">1</price>
</object>
</object>
</object>
<object name="Cave">
<inherit name="editor_room" />
<alias>Cave</alias>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="west" to="Mountain Path">
<inherit name="westdirection" />
<look>The cave is fairly large. Carved out of brown stone and mixed with black volcanic rock which shines from the sunlight coming in from the entrance to the outside to the west of you. The air is hot and blows passed you as it escapes outside. </look>
</exit>
<exit alias="north" to="Barrocks">
<inherit name="northdirection" />
</exit>
<exit alias="east" to="Tunnel">
<inherit name="eastdirection" />
</exit>
<exit alias="south" to="Hags Den">
<inherit name="southdirection" />
</exit>
<object name="Orc Guard">
<inherit name="editor_object" />
<inherit name="monster" />
<inherit name="namedmale" />
<hurtbyweapon>You slash into the guard with your claws. He begins to reel back but stands firm. Blood is pouring out of him.</hurtbyweapon>
<death>The guard clutches his chest and falls to the ground.</death>
<lookwhendead>Yep...He's dead. Laying lifeless on the cave floor. You notice a puzzled look on his face.</lookwhendead>
<attackasgroup />
<level type="int">1</level>
<inroomdescription>Standing Guard at the entrance to Mount Mormont is an orc.</inroomdescription>
<look>You've known this Orc for a while now. His name is Org. A bulky orc with huge muscles and attitude to go with it. The look on his face reads," I may be stupid, but I'm sure if you attack me, I'll stomp you anus into the rocks". </look>
<thingstosay type="stringlist">
<value>"An Ogre walks into a bar with a flint and steel. The bartender lets him in but says, "Don't start anything."</value>
<value>"Why do dwarves have such big nostrils?.......Because they have big fingers."</value>
<value>"In the town of Carn, Lord Talbert sent for his daughter, Vivian, but we stopped her coach and kidnapped her just north of here by the foothills of Shankspur Mountains, she is being held in the prison hall."</value>
</thingstosay>
<displayverbs type="stringlist">
<value>Look at</value>
<value>Speak to</value>
<value>Attack</value>
</displayverbs>
<speak type="script">
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
}
else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
msg ("The Orc says, " + StringListItem(Orc Guard.thingstosay, n))
list remove (Orc Guard.thingstosay, StringListItem(Orc Guard.thingstosay, n))
}
</speak>
<attack type="script">
list remove (Orc Guard.displayverbs, "Look at")
list remove (Orc Guard.displayverbs, "Speak to")
this.temp_db = 0
this.temp_ob_now = 0
this.temp_ob_next = 0
this.temp_damage = 0
this.temp_desc = 0
do (this, "doattack")
</attack>
<object name="Short Sword">
<inherit name="editor_object" />
</object>
<object name="Leather Armour">
<inherit name="editor_object" />
</object>
<object name="Leather Helmet">
<inherit name="editor_object" />
</object>
</object>
</object>
</object>
<object name="Swindon">
<inherit name="editor_room" />
<object name="Sowers Mill">
<inherit name="editor_room" />
</object>
</object>
<object name="Mountain Path">
<inherit name="editor_room" />
<exit alias="east" to="Cave">
<inherit name="eastdirection" />
</exit>
</object>
<object name="Bridgewater">
<inherit name="editor_room" />
</object>
<object name="Forest Clearing">
<inherit name="editor_room" />
<exit alias="in" to="Stone Stairs">
<inherit name="indirection" />
</exit>
</object>
<object name="Redditch">
<inherit name="editor_room" />
</object>
<object name="Minehead">
<inherit name="editor_room" />
</object>
<object name="Triverton">
<inherit name="editor_room" />
</object>
<object name="Ringwood">
<inherit name="editor_room" />
</object>
<object name="Banbury">
<inherit name="editor_room" />
</object>
<object name="Wells">
<inherit name="editor_room" />
</object>
<object name="Woking">
<inherit name="editor_room" />
</object>
<object name="Newbury">
<inherit name="editor_room" />
</object>
</object>
</asl >
<exit alias="north" to="Barrocks">
<inherit name="northdirection" />
</exit>
s = StringListItem(list, GetRandomInt(0, ListCount(list)-1))
index = GetRandomInt(0, ListCount(list)-1)
s = StringListItem(list, index)
if (index = 2) {
// do what you want
}
I try StringListItem(Orc Guard.thingstosay, 2) but this refers to the number of items in the stringlist and not the 0, 1, 2, order of the stringlist.
<object name="npc_1">
<alias>woman</alias>
<chat type="script">
msg ("Hi, my name is " + this.alias + ".")
</chat>
</object>
<object name="npc_2">
<alias>man</alias>
<chat type="script">
invoke (ScriptDictionaryItem (this.chat_scriptdictionary_attribute, StringListItem (this.chat_stringlist_attribute, GetRandomInt (0, ListCount (this.chat_stringlist_attribute) - 1))))
</chat>
<attr name="chat_stringlist_attribute" type="simplestringlist">woman;man;option3;option4;option5</attr>
<chat_scriptdictionary_attribute type="scriptdictionary">
<item key="woman">
firsttime {
msg ("That other npc, the woman, is known as 'Sarah'.)
npc_1.alias = "Sarah"
} otherwise {
msg ("Have you talked to Sarah yet?")
}
</item>
<item key="man">
msg ("Hi, my name is " + this.alias + ".")
if (this.alias = "man") {
this.alias = "Sam"
}
</item>
<item key="option3">
msg ("you chose option3")
</item>
<item key="option4">
msg ("you chose option4")
</item>
<item key="option5">
msg ("you chose option5")
</item>
</chat_scriptdictionary_attribute>
</object>
<verb>
<property>chat</property>
<pattern>chat</pattern>
<defaultexpression>"You can't chat with it."</defaultexpression>
</verb>
example (in pseudo-code):
(I'm using numbers for my Variables in this quick example for simplicity, but they can be Strings~text~words too, such as 'red', 'blue', and 'yellow' )
1 = msg ("Hi")
msg ("My name is HK")
msg ("I'm still learning to code.")
2 = msg ("What is your name?)
msg ("Nice to meet you, XXX.")
msg ("Do you know how to code (well)?")
3 = msg ("Well, I got to get back to learning to code.")
msg ("We should talk again.")
msg ("Bye XXX, and have a good day.")
forgewright wrote:I try StringListItem(Orc Guard.thingstosay, 2) but this refers to the number of items in the stringlist and not the 0, 1, 2, order of the stringlist.
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
}
else {
if (IsSwitchedOn(Orc Guard)) {
msg ("\" No talking. Only killing.\"")
}
else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
msg ("The Orc says, " + StringListItem(Orc Guard.thingstosay, n))
index = GetRandomInt(0, ListCount(Orc Guard.thingstosay)-1)
s = StringListItem(Orc Guard.thingstosay, index)
if (index = 2) {
set (Woman, "alias", Vivian)
}
list remove (Orc Guard.thingstosay, StringListItem(Orc Guard.thingstosay, n))
}
}
if ((ListCount(Orc Guard.thingstosay) = 0)) {
msg ("\"That's all I have for now.\"")
index = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
n = StringListItem(Orc Guard.thingstosay, index)
if ((index = 2)) {
set (Woman, "alias", Vivian)
msg ("(\"The Orc says, \" + StringListItem(Orc Guard.thingstosay, n)")
}
else {
list remove (Orc Guard.thingstosay, StringListItem(Orc Guard.thingstosay, n))
}
}
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
}
else {
if (IsSwitchedOn(Orc Guard)) {
msg ("\" No talking. Only killing.\"")
}
else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (Instr(s, "Vivian")) {
set (Woman, "alias", Vivian)
}
list remove (Orc Guard.thingstosay, s)
}
}
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
} else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (Instr(s, "Vivian")) {
set (Woman, "alias", "Vivian")
}
list remove (Orc Guard.thingstosay, s)
}
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
} else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (s = "Vivian") {
set (Woman, "alias", "Vivian")
}
list remove (Orc Guard.thingstosay, s)
}
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
} else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (Instr (s, "Vivian") = ToInt (n) ) {
set (Woman, "alias", "Vivian")
}
list remove (Orc Guard.thingstosay, s)
}
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
}
else {
if (IsSwitchedOn(Orc Guard)) {
msg ("\" No talking. Only killing.\"")
}
else {
keystring1 = StringListItem(Orc Guard.thingstosay, 2)
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (StartsWith(s, keystring1)) {
set (Woman, "alias", Vivian)
}
list remove (Orc Guard.thingstosay, s)
}
Forgewright wrote:The switched on orc guard line refers to whether he is switched on or not. Once he is attacked I switch him on so that line won't allow the player to "Speak to the orc anymore..only fight. That was the only way I could figure out how to do it.
This last script errors for: xxx
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
} else {
if (Orc Guard.IsSwitchedOn) {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (Instr (s, "Vivian") = n) {
set (Woman, "alias", "Vivian")
}
list remove (Orc Guard.thingstosay, s)
} else {
msg ("Don't make me angry...")
}
}
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
} else {
if (Orc Guard.IsSwitchedOn) {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (s = "Vivian") {
set (Woman, "alias", "Vivian")
}
list remove (Orc Guard.thingstosay, s)
} else {
msg ("Don't make me angry...")
}
}
Forgewright wrote:The "Instr" is new to me. The code retrieves the first random ListItem but gives the error:
Script.PNG
I know Boolean is a true or false statement and I assume the Int32 is Integer. Is S some how returning an Integer?
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
}
else {
if (IsSwitchedOn(Orc Guard)) {
msg ("\" No talking. Only killing.\"")
}
else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (not Instr(s, "Vivian") = 0) {
set (Woman, "alias", Vivian)
}
list remove (Orc Guard.thingstosay, s)
}
}
Instr("Do you know Vivian", "Vivian") returns 13
Instr("Do you know Mary", "Vivian") returns 0 (i.e., not found)
keystring1 = StringListItem(Orc Guard.thingstosay, 2)
//this needs to be outside the conversation block so it is executed only once and happens before any list modification
//running this again later will cause the key to change what text it's looking for.
if (ListCount(Orc Guard.thingstosay) = 0) {
msg ("\"Thats all I have for now.\"")
}
else {
if (IsSwitchedOn(Orc Guard)) {
msg ("\" No talking. Only killing.\"")
}
else {
n = GetRandomInt (0, ListCount(Orc Guard.thingstosay) - 1)
s = StringListItem(Orc Guard.thingstosay, n)
msg ("The Orc says, " + s)
if (StartsWith(s, keystring1)) {
set (Woman, "alias", Vivian)
}
list remove (Orc Guard.thingstosay, s)
}