Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Weird phantom direction bug...

A topic by ChristopherMerriner created Jun 12, 2020 Views: 143 Replies: 18
Viewing posts 1 to 8

Here's a strange thing: at a certain point in my game (when a couple of integers are incremented, and Booleans set) a peculiar phantom 'south' direction suddenly appears in all my locations! It's listed but you can't go that way. I'm spending time now trying to figure out what in the code has triggered it, but if this is something obvious and/or a know bug then that would save a lot of effort.

Thanks.

Host

First I've heard of this, if you can narrow it down, I'll certainly fix it.

In the Adventuron version? Or the DAAD version?

In Adventuron. I am trying to chase it down now. I know what integer it is that triggers it when incremented, but there is a bunch of downstream stuff that happens after that, so I need to test everything.

Host

Are you matching "s _" or "south _" anywhere in your code?

Yes, I am.  Would that trigger it?

Host (1 edit)

Yes, that would trigger it. Please can I see the code that you are matching with s _ , and for what purpose you are doing it?

Adventuron scans inside the on_command {} table for what looks like matching of directions, and adds in those directions to the exit list dynamically. The scanning is aware of additional inner if statements like:

: match "s _" {
   : if (is_at "stream") {
      : goto "moor";
   }
}

In the above case, it would add a SOUTH exit to the stream location.

What I'm really interested in is why you overrode the south command and why it's not appropriate to list the exit.

I use it in a few places:

1. When I leave this room, I want a message to be printed and to reset a number of flags (I'm leaving a room where I've been snooping around, opening the safe, etc so I want to leave it as I found it:


: match "s _"  {
   : if (is_at "secretarys_office") {
         : print "You make sure you leave the room as you found it!" ;
         : pocket "keyring" ;
         : door_operation door = "secretary_door"  operation = "lock_close" ;
         : if (safeopen) {
         : set_false "safeopen" ;
         }
         : if (safeunlocked) {
            : set_false "safeunlocked" ;
         }
         : if (draweropen) {
            : set_false "draweropen" ;
         }
         : goto "corridor7" ;
         : press_any_key ;
         : redescribe;
      

2. When I leave this room, I want a message to printed the first time that happens:

: match "s _"  {

:  if (is_at "bobsroom") {
      : if (bobstuff==6&&bobother==3) {
      : print "leaving room information" ;
      : increment "bobstuff" ;
      : goto "corridor2" ;
      : press_any_key ;
      : redescribe;
      

3. Here there are some doors mentioned in the description (that are just there for scenery). I thought that rather than create a locked door in each location,  I'd just do this:

: match "s _" {

: if (is_at "corridor5") {
      : print "There was a locked door in the way." ;


...I'm also matching "n_" elsewhere, but that is not causing phantom norths...

There is definitely some connection with another counter that I am incrementing. This increments at certain points in the game, after which the game is set to a new state (the player is put in another room etc). Before that change happens: no phantom souths. They appear afterwards.

Host

Hmmm, please save  the code as it is now, so I can study it later if possible.

Then use the fix I just updated.

I fixed it! 

The full offending match statement is below:

---

: match "s_"  {
   : if (is_at "secretarys_office") {
         : print "MESSAGE" ;
         : pocket "keyring" ;
         : door_operation door = "secretary_door"  operation = "lock_close" ;
         : if (safeopen) {
         : set_false "safeopen" ;
         }
         : if (safeunlocked) {
            : set_false "safeunlocked" ;
         }
         : destroy "safe" ;
         : if (draweropen) {
            : set_false "draweropen" ;
         }
         : goto "corridor7" ;
         : press_any_key ;
         : redescribe;
   }
   : if (is_at "corridor5") {
      : print "There was a locked door in the way." ;
   }
**OFFENDING CODE BELOW**
   : if (traptor==3){
  :  if (is_at "bobsroom") {
      : if (bobtell==6&&bobask==3) {
      : print "MESSAGE" ;
      : increment "bobask" ;
      : goto "corridor2" ;
      : press_any_key ;
      : redescribe;
      }
      }
   }
}

---

I changed the offending bit to:

 :  if (is_at "bobsroom") {
  : if (traptor==3) {
      : if (bobtell==6&&bobask==3) {
      : print "MESSAGE";
      : increment "bobask" ;
      : goto "corridor2" ;
      : press_any_key ;
      : redescribe;
      }
       }
      }

And it works (of course, I have no idea why, but breathe a sigh of relief and carry on!)

Host

To disable on_command {} direction scanning, you can use the following settings:

game_settings {
   exit_list_calculation_type = basic
}

But, please, before you do this, I'd like to know why you were matching "s _" (code snippet and explanation if possible) and why Adventuron was suggesting south as a direction inappropriately. It usually works very well.

...for some reason, that snippet of code gives me an error when I try to add it?

Host (1 edit)

My mistake, should be :

game_settings {
   exit_list_calculation = basic
}
Submitted

I used to have trouble with this as well. I now use exit_list_calculation = basic as a matter of course. In this way, it will only show the exits in the connections{} section (subject to any barriers you have set up) and won't scan your match statements to show exits that you might not want to show.

As a matter if interest, in what contexts is the match statement scanning useful rather than just using connections? Presumably some scenario that I haven't encountered yet.

Host (1 edit)

Connection scanning in explicit match commands pre-dates the barrier mechanism.

It essentially lets adventuron know when a direction will lead somewhere not covered by the connection map (like directions in a maze for example), or context specific enter and exits, or directions.

I think I'm going to change adventuron to use basic exit list calculations by default. The barrier mechanism is far more reliable at blocking and enabling conditional exits, but the mechanism can still be switched on for games with mazes (where connections mappings are dynamic and made via the on_command {} block.

Submitted

Why on earth would mazes need this? Mazes aren't dynamic. Not unless they use random connections and that's a very bad practice anyway.

Bad practice, but de rigueur in the 1980s, I recall (from spending many frustrating turns in mazes, back in the day).

Submitted

This ain't the 1980s. If you put a maze with random exits nowadays, you'll get crucified. Even so, the maze will always show you the exits, it's the destination that's random.

Sadly, this is true. Although doubtless there are a few 1980s adventure game masochists  still about, who would relish a game full of random mazes and  (for good measure) non-reciprocal exits that lead to a totally  different location in the reverse direction. There is a niche for everything!