| Message |
Now that I have been adding Lua scripting to SMAUG Fuss, I have been experimenting with the path-finding algorithm described in this post:
http://www.gammon.com.au/forum/bbshowpost.php?id=7306
The objective of this was to help newbies find their way around, by listing common locations (eg. baker, repairs, academy), and tell them the way to walk to get there. I am sure I have seen something similar in one of the pay MUDs.
This code is entirely implemented in Lua, except for the 3 lines of code needed to add the command handler into the commands list.
Here is an example of it in operation. First you can type "whereis" to find the known destinations:
whereis
This will show you how to get to commonly-used locations.
Type 'whereis [destination]' to get a suggested route (eg. 'whereis baker').
Destination : Room name
-------------------------------------------------------
Academy : Entrance to the Academy
Alchemist : The Alchemist's
Baker : The Darkhaven Bakery
Battleground : Battle Grounds
Butcher : The Butcher's Shop
Cathedral altar : The Cathedral Altar
Clothing : Annir's Clothing
Dairy : The Dairy Tent
East gate : Inside the Eastern Gate
Fountain : Darkhaven Academy
Headmistress : Darkhaven Academy
Healer : The Academy Healer
Inn : The Darkhaven Inn
Languages : Abbigayle's Language Lessons
Magic : The Wizard's Tent
North gate : Inside the Northern Gate
Repairs : The Blacksmith's Tent
Scrolls : The Scribe's Tent
Skills : The Laboratory of Skills and Spells
South gate : Inside the Southern Gate
Square : Darkhaven Square
Tailor : Annir's Clothing
Tavern : The Tavern
Weapons : Weaponry Shop
West gate : Inside the Western Gate
The exact list is under your control, as you edit a table of vnums that you want to be made available. Now you can choose one:
whereis repairs
To get to The Blacksmith's Tent walk: 5s 2e (se) 2s e s
This generates the shortest path from the current room to the selected room, using the algorithm mentioned before.
Here is another example:
whereis academy
To get to Entrance to the Academy walk: 5s 2e (se) 3e s
The list of destinations is in the Lua source file, it looks like this:
available_dests = {
butcher = 21057,
academy = 21280,
inn = 21069,
baker = 21060 ,
tavern = 21068,
dairy = 21061,
alchemist = 21054,
weapons = 21062,
square = 21000,
magic = 21055,
scrolls = 21051,
repairs = 21058,
clothing = 21066,
headmistress = 10300,
languages = 10306,
skills = 10303,
healer = 10319,
battleground = 10368,
fountain = 10300,
tailor = 21066,
["south gate"] = 21074,
["north gate"] = 21100,
["west gate"] = 21088,
["east gate"] = 21113,
["cathedral altar"] = 21194,
}
You can customize it to show as many or as few rooms as you want. The room descriptions are looked up, and the list sorted into alphabetic order. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|