intfiction.org

The Interactive Fiction Community Forum
It is currently Sun May 19, 2013 12:53 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Jul 27, 2012 6:09 pm 
Offline

Joined: Wed Jun 20, 2012 6:48 am
Posts: 17
I have a game where the player's avatar changes on a regular basis. I have this rule:

Instead of examining the player, say "true".

The problem is... when I type 'x me', it only works for the first avatar (Alice). When I change to the next avatar (Bob), the rule is completely ignored and I just get the Bob's description. If I change back to Alice, the rule fires.

To me it smells like the compiler has somehow managed to bake a reference to Alice into the rule. Certainly, if I do this:

Instead of examining Alice, say "Alice".
Instead of examining Bob, say "Bob".

...everything works as expected.

The big problem is: I cannot reproduce this as a minimal test case. Therefore whatever's going wrong must be something else in my 12000 word game. And I have no idea where to start debugging. Doing 'actions on' doesn't really help as it doesn't go into enough detail about what rules are being considered (plus, Inform's habit of always referring to the player as 'yourself' does make distinguishing between players tricky).

I've never seen a rule as simple as this completely fail to fire before. Any suggestions?


Top
 Profile Send private message  
 
PostPosted: Fri Jul 27, 2012 7:56 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 2127
Location: Burlington, VT
Have you done a rules trace (by typing "rules all" before examining the player when he is Bob)? One guess I'd make is that maybe you have a more specific "instead of examining..." rule that is firing before your "instead of examining the player" rule.


Top
 Profile Send private message  
 
PostPosted: Sat Jul 28, 2012 4:25 am 
Offline

Joined: Wed Jun 20, 2012 6:48 am
Posts: 17
Ah, I didn't know such a thing existed. Very useful...

With 'rules all', when I'm Bob, I see this:

[Rule "Instead of examining the player" does not apply.]
...
[Rule "standard examining rule" applies.]

When I'm Alice, of course, the first rule fires as expected.

Is there any way to get it to tell me what it thinks 'player' is in that rule?


Top
 Profile Send private message  
 
PostPosted: Sat Jul 28, 2012 5:58 am 
Offline

Joined: Wed Oct 27, 2010 6:15 pm
Posts: 239
A change to something like
Code:
Instead of an actor examining:
   showme the actor;
   showme the noun;
   showme the player;
   if the actor is the player and the noun is the player:
      say "true";
   otherwise:
      make no decision.
should do the trick. You might have to add rule-ordering lines to get it to fall the same place in the instead rulebook, which is important in case the culprit is a prior rule altering the action.


Top
 Profile Send private message  
 
PostPosted: Sat Jul 28, 2012 7:31 am 
Offline

Joined: Wed Jun 20, 2012 6:48 am
Posts: 17
That's very interesting.

'Instead of an actor examining' always fires, and always says 'true'. 'Instead of the player examining' never fires. According to 'rules all' this is the first rule that fires (unless it's possible for a rule to do something even when 'rules all' says 'does not apply'). The values of 'actor', 'noun' and 'player' are always as expected.

Still can't reproduce this in a test case, though. Next step is to start bisecting my game, which will be huge amounts of fun.


Top
 Profile Send private message  
 
PostPosted: Sat Jul 28, 2012 8:16 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 672
One thing you could try is changing the actor variable when you change the player variable, like so.

Code:
Changing is an action applying to one thing. Understand "Change to [something]" as changing.

Check someone changing (this is the block someone else changing rule):
say "Only you can do that!" instead.

Check changing (this is the standard check changing rule):
if the noun is not a person, say "You can't do that!" instead.

Carry out changing (this is the standard carry out changing rule):
now the player is the noun;
now the actor is the noun.

Report changing (this is the standard report changing rule):
say "You are now [the printed name of the noun].".


Hope this helps.

_________________
"Will you stop breaking the fourth wall? It's costing me an absolute fortune to replace it!"


Top
 Profile Send private message  
 
PostPosted: Sat Jul 28, 2012 6:06 pm 
Offline

Joined: Wed Jun 20, 2012 6:48 am
Posts: 17
Oh, for...

Here is a minimal test case.

Code:
"Examine thyself" by "David Given"

Place is a room.

Player Alice is a person. She is in Place. The description is "Alice's description."

Bob is a person. He is in Place. The description is "Bob's description."

When play begins:
   now the player is Player Alice;
   remove yourself from play.

Instead of examining the player:
   say "Examining rule fires."
   
Understand "become [any person]" as shapechanging.
Shapechanging is an action applying to one thing.

Instead of shapechanging an person:
   if the noun is the player:
      say "You're already [the noun].";
   else:      
      let old-player be the player;
      now the player is the noun;
      say "You become [the printed name of noun]."

test me with "x me / become bob / x me".


Simply change Alice's name from 'Player Alice' to 'Alice' and the problem goes away.

I bet what's going on is that the 'player' in the rule is being treated as shorthand for 'player alice' rather than the, you know, actual player.

I think this is a bug --- particularly since in the real game I have multiple objects with Player on the front, to distinguish them from the NPC version of the same object...


Top
 Profile Send private message  
 
PostPosted: Sat Jul 28, 2012 6:34 pm 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 984
Location: Gothenburg, Sweden
Hjalfi wrote:
I have multiple objects with Player on the front, to distinguish them from the NPC version of the same object

In general, you don't need to have a special version of Alice to play and another as NPC: when the player is Alice, you play the person Alice, and Bob is an NPC; when the player becomes Bob, Bob stops being an NPC, and you play him, while Alice becomes just another NPC.
But perhaps you have special reasons for having a player version of some or all persons. If so, just call your player version persons "PlayerAlice" or "Player_Alice" or "Player-Alice" or "PC Alice" etc. rather than "Player Alice" etc.

_________________
Man ska inte tro allt man tänker.


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

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] 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