intfiction.org

The Interactive Fiction Community Forum
It is currently Wed Jun 19, 2013 10:30 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: gAction Tracing
PostPosted: Sun Jun 05, 2011 12:45 am 
Offline

Joined: Sun Mar 01, 2009 8:02 pm
Posts: 904
Here's a nice little puzzle. At what point in the command execution cycle (and yes, I looked in that article in the Tech Manual, and it doesn't seem to have this information) is gAction reset to nil?

It seems to happen before daemons are run. I'm attempting to bypass the running of a daemon when gActionIn(AskAbout, TellAbout) ... and it doesn't work. That test always returns false, so the daemon runs anyhow. I can only conclude that at some point gAction is being reset to nil.

I've been able to kludge around it by setting a flag in the afterAction for the me object and then testing the value of the flag in the code for the daemon, but that's a bit messy. Is the value of the most recent action stored anywhere even after gAction is reset to nil?


Top
 Profile Send private message  
 
 Post subject: Re: gAction Tracing
PostPosted: Sun Jun 05, 2011 5:10 am 
Offline

Joined: Thu Jan 28, 2010 3:57 am
Posts: 166
I don't know the exact point at which gAction is set to nil, but I'm pretty sure you're right that it's before any daemoms are run. I also don't know of anywhere where the last action is stored as standard. In my current WIP I do roughly what you've tried, namely add a lastAction property to the me object and then modify Action thus:

Code:
modify Action
    beforeActionMain()
    {
        if(gActor == me && !isImplicit && !ofKind(SystemAction))
            me.lastAction = self;
    }
;


You may or may not want to include the check for excluding the storing of implicit actions depending what you want to use the stored information for.

Storing the complete action in this way (rather than just setting a flag) allows you to get at the complete set of details about the immediate past action (I'm using it in connection with a series of ExtraHints, of the kind we put in Mrs Pepper's Nasty Secret), for which purpose I also defined a number of convenient macros:

Quote:
#define gActionWas(action)\
(me.lastAction != nil && me.lastAction.actionOfKind(action##Action))
#define gLastDobj (me.lastAction.getDobj())
#define gLastIobj (me.lastAction.getIobj())
#define gLastTopic (me.lastAction.getTopic())
#define gLastTopicText (gLastTopic.getTopicText.toLower())


Hopefully there's something here you can adapt for your own use.

-- Eric


Top
 Profile Send private message  
 
 Post subject: Re: gAction Tracing
PostPosted: Sun Jun 05, 2011 12:01 pm 
Offline

Joined: Sun Mar 01, 2009 8:02 pm
Posts: 904
Thanks, Eric. That's much more thorough, and may prove to have other uses as my game develops. All I'm needing to do at the moment is check for AskAbout and TellAbout.

I'm using your Scenes.t extension (and by the way, you didn't put a byline in the code comments ... such modesty!) rather than an AgendaItem. An AgendaItem will pause if the NPC is in conversation, but a daemon won't. Hence the need to check for those actions.


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