I am trying to add a mobile phone to my game. I have the speech communication over separate rooms working but am struggling with being able to send a text message. I really just want for the action ‘Text Bob about apple’ to work where both Bob and apple are not normally in scope i.e. a different location.
Before I code this fully I am just trying to work out the scope issues. I found some code in these forums that seems to do roughly what I want by creating a new IobjResolver. This is my minimal trial code:
startRoom: Room 'Start Room'
"This is the starting room. "
;
+ me: Actor
;
otherRoom: Room 'Other Room'
"This is the starting room. "
;
+ bob: Actor 'Bob' 'Bob'
"Its Bob. "
;
+ apple: Thing 'red apple' 'red apple'
"It is a red apple. ";
;
tFootball: Topic 'football';
VerbRule(TextAbout)
('text' | 'message') dobjList 'about' singleIobj
: TextAboutAction
verbPhrase = 'text/texting (what) (about what)'
;
DefineTIAction(TextAbout)
objInScope(obj)
{
//return obj.ofKind(Person);
return true;
}
createIobjResolver(issuingActor, targetActor)
{
return new TextIobjResolver(self, issuingActor, targetActor);
}
resolveFirst = DirectObject
execFirst = DirectObject
;
TextIobjResolver: IobjResolver
objInScope(obj) { return true; }
;
modify Actor
dobjFor(TextAbout)
{
check() { }
verify() { }
action()
{
textAboutMsg;
}
}
textAboutMsg
{
"{You/he} text{s} <<name>> about {the iobj/he}. ";
}
;
This is working for objects, but when I try to use it to bring a topic into scope it fails and I get a ‘nil object reference’ from the following part of getNotifyTable()
foreach (local cur in curObjs)
{
/* add each item in the object's notify list */
foreach (local ncur in cur.getObjectNotifyList())
tab[ncur] = true;
}
This is getting beyond my coding abilities so I am just wondering why this doesn’t work when topics work for ask/tell commands when they are out of scope in a similar way to what I am trying to implement. Alternatively is there a better way altogether to handle indirect objects that you want to bring into scope from other locations?
Thanks for any advice.