TADS 3: Troubleshooting with unusual scope

#1

I’ve been having this problem lately, I’ve been trying to fix it for over a week now, and I’m totally stumped, and feeling quite stupid. To describe my problem, I’ll put it this way: Say, in the game I am trying to create, the player character is a robot, who can detach one of their “eyes” and leave it in another room. While that “eye” is in the other room, the player will be able to examine objects in that room no matter where they are in the game world.

I’ve managed to put the objects from the room into the player’s scope, but whenever I attempt to examine one of the objects, I receive this error:

nil object reference

i_object.basicExamine() + 0xF i_object.mainExamine() + 0xD i_object.fromPOV(player, player, &mainExamine) + 0x1E i_object.actionDobjExamine() + 0x21 TAction [994f].execAction() + 0x29 Action [994f].doActionOnce() + 0xB5 TAction [994f].doActionMain() + 0x6E Action [994f].doAction(player, player, nil, nil) + 0x7A executeAction(player, nil, player, nil, obj#994f (predicate(Examine))) + 0x10A func#27575() + 0x30

basicExamine() { /* check the transparency to viewing this object */ local info = getVisualSenseInfo(); local t = info.trans; // (this is where the code snags)

If anyone knows what may be happening here, and how to fix it, please let me know. I’m certain this is possible, I just lack the necessary understanding of scope to make it happen. Thank you!

0 Likes

#2

It’s quite hard to point out an error in your code without actually seeing and testing your code :wink: But never mind, I don’t know much about controlling scope, its quite low level stuff. Instead I’ll show you portion from my own game where I have a cctv screen on which player can see a different room. I’m using SenseConnector and after first examining screen, I’ll put the other end in the room with the player and player can see, but not touch etc. whatever is in the room. Please note the example is cut from the middle of the game source code so may not be completely working as such, but definitely look on SenseConnector class. It’s a multiloc object therefore its location is manipulated with either at run time with moveIntoAdd or listing a list of locations in locationList property. transSensingThru controls what is transmitted and in my case that the connector transmits only sight and only in one direction. That’s it.

controlRoom: BaseRoom 'Control room';

+ cctvScreen: Thing 'cctv screen' 'cctv screen'
    "This is a television screen... <<showScreen>> "

    showScreen()
    {
        if(!cctvLink.isIn(self))
            cctvLink.moveIntoAdd(self);

        "<.p> ";
        robotRoom.roomRemoteDesc(me);
    }
;

/***************************************************************************/

robotRoom: BaseRoom 'Room with robot'
    desc()
    {
        if(me.isIn(controlRoom)) roomRemoteDesc(me);
        else
            "You are in robot room... ";
    }

    roomRemoteDesc(actor)
    {
        "You see a robot room on the screen... ";
    }
;

cctvLink: SenseConnector, Intangible 'tv transmission' 'tv transmission'
    "<<cctvScreen.desc>> "

    locationList = [robotRoom]
    transSensingThru(sense)
    {
        if(me.isIn(robotRoom)) return opaque;
        else return sense == sight ? transparent : opaque;
    }

    isListed = nil
    isListedInContents = nil

    hideFromAll(action)
    {
        return !action.ofKind(ExamineAction);
    }

    dobjFor(Examine) { verify() { inherited(); } }

    dobjFor(LookIn) asDobjFor(Examine)
    dobjFor(Search) asDobjFor(Examine)
;
0 Likes

#3

Thank you so much! :smiley: Of course it would be something as simple as that… I knew skipping the “SenseConnector” section of the tutorial would come back to bite me in the rear. Moving the connectors around with the player is causing a couple other problems to crop up, but they are trivial in comparison. Again, thank you so much for your help!

0 Likes