intfiction.org

The Interactive Fiction Community Forum
It is currently Sun May 19, 2013 7:33 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Mar 23, 2011 5:38 pm 
Offline

Joined: Wed Jun 09, 2010 2:15 pm
Posts: 4
In TADS3, I am trying to create a TIaction where the indirect object of the command will be an out of scope item that relates to a spell in my game. I have the scope adjusted to include the spell objects but the library doesn't appear to check scope rules for indirect objects which leads to the "you see no ... here" response. I haven't found where the library makes the assumption that all indirect objects must be visible.

Does anyone know which methods on the action class needs adjustments to allow for a global indirect object in a command?


Top
 Profile Send private message  
 
PostPosted: Wed Mar 23, 2011 6:27 pm 
Offline

Joined: Tue Apr 27, 2010 1:02 pm
Posts: 797
Here's one way I've handled scope and visibility for offstage indirect objects. In my case these were rooms but it should be obvious how to adapt that; just generate a list of the appropriate objects and plug it into the getScopeList() functions.

Code:
// put all rooms in scope for USE WITH
modify UseWithAction
    objInScope(obj) { local scope = getScopeList(); return scope.indexOf(obj); }
    getScopeList()  { return scope_ + allRooms.lst(); }

    createIobjResolver(issuingActor, targetActor)
    {
        return new CustomIobjResolver(self, issuingActor, targetActor);
    }

    resolveFirst = DirectObject
    execFirst = DirectObject
;

// make rooms available as indirect objects for USE WITH
CustomIobjResolver: IobjResolver
    objInScope(obj) { return true; }
    getScopeList()  { return scope_ + allRooms.lst(); }
;


Here, the objInScope(obj) and getScopeList() functions in the UseWithAction object handle scope resolution for the direct object, and the corresponding functions in the CustomIobjResolver handle it for the indirect object. The code is similar but not quite identical; I had to lobotomize objInScope(obj) on the indirect resolver in order to make things work.

(The execFirst / resolveFirst modifications aren't strictly necessary, but I found that the default responses tended to be more logical that way.)

I also needed a custom precondition for my UseWith action that would let objects through verification even if they were not visible to the player.

Code:
// can only USE WITH rooms and visible objects
objUsable: PreCondition
    verifyPreCondition(obj)
    {
        if (obj != nil && !(gActor.canSee(obj) || obj.ofKind(Room)))
        {
            inaccessible(&mustBeVisibleMsg, obj);
        }
    }
;

modify Thing
    dobjFor(UseWith)   { preCond = [objUsable] }       // is direct object usable?
    iobjFor(UseWith)   { preCond = [objUsable] }       // is indirect object usable?
;


Top
 Profile Send private message  
 
PostPosted: Thu Mar 24, 2011 12:30 am 
Offline

Joined: Wed Jun 09, 2010 2:15 pm
Posts: 4
Thanks for the info. I tested the modified version of your code and it appears to be working so far.


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 2 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:  
cron
Powered by phpBB® Forum Software © phpBB Group