Interception of movements from the dark

Before Go is not executed if the place is in darkness, but it is executed if the same place is in light.

Release 1 / Serial number 210412 / Inform v6.35 PunyInform v2.3
                                                               
Room1                                                          
You are in Room 1. Room 2 is west.                             
                                                               
You can see a torch (providing light) here.                    
                                                               
> w                                                            
*** Before GO Room1 ***                                        
Darkness                                                       
It is pitch dark here!                                         
                                                               
> e                                                            
Room1                                                          
You are in Room 1. Room 2 is west.                             
                                                               
You can see a torch (providing light) here.                    
                                                               
> get torch                                                    
Taken.                                                         
                                                               
> w                                                            
*** Before GO Room1 ***                                        
Room2                                                          
You are in Room 2. Room 1 is est.                              
                                                               
> e                                                            
*** Before GO Room2 ***                                        
Room1                                                          
You are in Room 1. Room 2 is west.
Code
!% -~S
!% $OMIT_UNUSED_ROUTINES=1

Include "globals.h";
Include "puny.h";

Object Room1 "Room1"
   with
      description "You are in Room 1. Room 2 is west.",
      Before [;
         GO: print "*** Before GO Room1 ***^";
      ],
      w_to Room2,
   has light;

Object -> torch "torch"
	with
		name 'torch',
	has light;

Object Room2 "Room2"
	with
      description "You are in Room 2. Room 1 is est.",
      Before [;
         GO: print "*** Before GO Room2 ***^";
      ],
      e_to Room1,
   has;

[ Initialise;
   lookmode = 2;
   location = Room1;
];
3 Likes

Thank you. Well spotted. This will be fixed in the next version of Puny.

2 Likes