Reverse Exits in Automapper

Posted by Emer on Sun 10 Jun 2018 11:11 AM — 3 posts, 13,552 views.

#0
Hello,
I am trying to adapt the automapper for TempestSeason.
My latest attempt is here: https://github.com/EmerFox/Mushclient-Plugins-for-Tempest-Season-Mud/blob/master/Tempest_Season_MAP.xml

I want it to automatically add reverse exits when walking around. I can see how it is done in the Example Mapper but I can't figure out how to put them into the sqlite database.

I tried pasting this in at line 712:
  dbcheck (db:execute (string.format ([[
        UPDATE exits SET touid = %s WHERE fromuid = %s AND dir = %s;
      ]],
          fixsql  (from_room),     -- previous room
          fixsql  (current_room),  -- destination room
          fixsql  (inverse_direction.last_direction_moved)  -- inverse direction (eg. "s")
          )))
  
    room.exits [inverse_direction [last_direction_moved]] = from_room  


That just creates exits in both directions for every room eg if a room has exits north and east, it adds exits south and west too. How do I make it add reverse exits but only when I move?
Amended on Sun 17 Jun 2018 10:00 AM by Emer
Australia Forum Administrator #1
This part is wrong:


       fixsql  (inverse_direction.last_direction_moved)  -- inverse direction (eg. "s")



To index into a table with a variable, you can't use the "dot notation" like that. That just looks for the key "last_direction_moved" not the variable (contents of last_direction_moved). It should be like your last line, in other words:


          fixsql  (inverse_direction [last_direction_moved])  -- inverse direction (eg. "s")
Amended on Sun 10 Jun 2018 11:35 PM by Nick Gammon
#2
Thank you. That makes sense.
I still have a problem with exits not being drawn properly and extra ones being drawn where they shouldn't exist but I think that is to do with the layout of the mud. There are some rooms with repeat names and descriptions and then there are lots of exits that are not compass directions eg go door, go path.
The owner seems keen to make the mud automappable but players can't see vnums so I'll ask him to change that.