I have an NPC known simply as agent until he is engaged in conversation, where he reveals his name to be Bo.
I want to reflect that new knowledge in the Actor object’s vocab property so that a command like give Bo the letter will work once his name is known.
I have a setName(str) method in the Actor object…
setName(str)
{
local oldName = name;
name = str;
proper = true;
otherGuy.addVocabWord(oldName, MatchNoun);
}
This code is modeled after an example cribbed from the Adv3Lite tutorial, where the flight attendant becomes Angela during a conversation.
When I call the setName() method, the Actor name property changes as expected, but the command give bo the letter fails because there is no bo.
I don’t understand why my example is not working when it appears to work in the tutorial. What am I missing?
Here’s the test bed code…
[code]
#charset “us-ascii”
#include <tads.h>
#include “advlite.h”
versionInfo: GameID
IFID = ‘445C38A3-AD1B-4729-957A-F584600DE5C1’
name = ‘test’
byline = ‘by Jerry Ford’
htmlByline = ‘by
Jerry Ford’
version = ‘1’
authorEmail = ‘Jerry Ford jerry.o.ford@gmail.com’
desc = ‘Testing Actor name change.’
htmlDesc = ‘Testing Actor name change.’
;
gameMain: GameMainDef
initialPlayerChar = me
paraBrksBtwnSubcontents = nil
;
me: Actor ‘me’ @room
“The main man.<.p>”
isHim = true
person = 2
;
- letter: Thing ‘letter’
“The letter for Bo.<.p>”
;
room: Room ‘room’
“The room. <.p>”
;
otherGuy: Actor ‘agent;;man person;him’ @room
desc = “The agent stands in the middle of the room. <.p>”
setName(str)
{
local oldName = name;
name = str;
proper = true;
otherGuy.addVocabWord(oldName, MatchNoun);
}
;
- HelloTopic
“Hello, you say. What’s your name? \b
Bo. The name’s Bo, the other guy replies. <.p>
<<otherGuy.setName(‘Bo’)>>”
; - GiveTopic @letter
“Oh, Bo, huh? I have a letter for you, you say. <.p>”
;
[/code]
Jerry