intfiction.org

The Interactive Fiction Community Forum
It is currently Sat Sep 23, 2017 4:56 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jul 17, 2017 12:30 pm 
Offline

Joined: Sat Mar 18, 2017 2:52 am
Posts: 3
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:

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()

Code:
        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.


Top
 Profile Send private message  
 
PostPosted: Mon Jul 17, 2017 1:40 pm 
Offline

Joined: Sat Jul 16, 2011 3:48 pm
Posts: 250
Code:
VerbRule(TextAbout)
    ('text' | 'message') singleDobj 'about' singleTopic
    : TextAboutAction
    verbPhrase = 'text/texting (whom) (about what)'
;

DefineTopicTAction(TextAbout, IndirectObject)
    objInScope(obj)
    {
        return obj.ofKind(Actor);
    }
;

modify Actor
    dobjFor(TextAbout) { /* no change to your code */ }
    textAboutMsg
    {
        "{You/he} text{s} <<name>> about <<gTopic.getTopicText()>>. ";
    }
;


Top
 Profile Send private message  
 
PostPosted: Tue Jul 18, 2017 7:19 am 
Offline

Joined: Sat Mar 18, 2017 2:52 am
Posts: 3
That worked for me. Thanks for the help.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group