Difference between revisions of "Mapping script"

From Mudlet
Jump to navigation Jump to search
Line 1: Line 1:
 
Mudlet's mapper is split into two parts for the best compatibility on all MUDs - the display and functions in Mudlet, and a per-MUD Lua script that tracks where you are, allows mapping and provides aliases for using the mapper.
 
Mudlet's mapper is split into two parts for the best compatibility on all MUDs - the display and functions in Mudlet, and a per-MUD Lua script that tracks where you are, allows mapping and provides aliases for using the mapper.
  
Pre-made mapping scripts are available from [http://forums.mudlet.org/search.php?keywords=mapping+script&terms=all&author=&sc=1&sf=titleonly&sr=topics&sk=t&sd=d&st=0&ch=400&t=0&submit=Search Mudlet forums]. If you'd like to code your own, see the [http://mudlet.org/asciidoc/manual.html#mapperApi Mapper API].
+
Pre-made mapping scripts are available from [http://forums.mudlet.org/search.php?keywords=mapping+script&terms=all&author=&sc=1&sf=titleonly&sr=topics&sk=t&sd=d&st=0&ch=400&t=0&submit=Search Mudlet forums].  
  
If you're making your own mapper script, please do:
+
= Making your own mapping script =
  
''mudlet = mudlet or {}; mudlet.mapper_script = true''
+
If you'd like to code your own mapping script, see the [http://mudlet.org/asciidoc/manual.html#mapperApi Mapper API] and read on for a short tutorial.
  
At initialization, to let Mudlet know that a mapping script exists in the profile.
+
To start off, create a new script that'll be included with your mapping script (can even place it into the script folder for your mapping script), and have it do:
 +
 
 +
<lua>
 +
mudlet = mudlet or {}; mudlet.mapper_script = true
 +
</lua>
 +
 
 +
This'll let Mudlet know that a mapping script is installed, so it won't bother you or whoever else installs your script with a warning that one is necessary.
 +
 
 +
Next, you want to hook into Mudlet's gotoRoom(id) function and the user clicking on a room in the visual map - for that, define your own ''doSpeedWalk()'' function. Mudlet will store the directions / special exits commands your script will need to take in the ''speedWalkDir'' table, and the room IDs you'll pass through in the ''speedWalkPath'' table:
 +
 
 +
<lua>
 +
function doSpeedWalk()
 +
  echo("Path we need to take: " .. table.concat(speedWalkDir, ", ") .. "\n")
 +
  echo("Rooms we'll pass through: " .. table.concat(speedWalkPath, ", ") .. "\n")
 +
end
 +
</lua>
 +
 
 +
''speedWalkPath'' is especially useful for making sure you're still on the path. Most Mudlet mapping scripts keep track of how many rooms along the path they have visited so far and check upon arrival into a new room to make sure it's still on the path.
 +
 
 +
That's it! From here, you'd want to build a walking script that'll send the commands to walk you along the path, along with aliases for the user to use.

Revision as of 22:29, 14 June 2011

Mudlet's mapper is split into two parts for the best compatibility on all MUDs - the display and functions in Mudlet, and a per-MUD Lua script that tracks where you are, allows mapping and provides aliases for using the mapper.

Pre-made mapping scripts are available from Mudlet forums.

Making your own mapping script

If you'd like to code your own mapping script, see the Mapper API and read on for a short tutorial.

To start off, create a new script that'll be included with your mapping script (can even place it into the script folder for your mapping script), and have it do:

<lua> mudlet = mudlet or {}; mudlet.mapper_script = true </lua>

This'll let Mudlet know that a mapping script is installed, so it won't bother you or whoever else installs your script with a warning that one is necessary.

Next, you want to hook into Mudlet's gotoRoom(id) function and the user clicking on a room in the visual map - for that, define your own doSpeedWalk() function. Mudlet will store the directions / special exits commands your script will need to take in the speedWalkDir table, and the room IDs you'll pass through in the speedWalkPath table:

<lua> function doSpeedWalk()

 echo("Path we need to take: " .. table.concat(speedWalkDir, ", ") .. "\n")
 echo("Rooms we'll pass through: " .. table.concat(speedWalkPath, ", ") .. "\n")

end </lua>

speedWalkPath is especially useful for making sure you're still on the path. Most Mudlet mapping scripts keep track of how many rooms along the path they have visited so far and check upon arrival into a new room to make sure it's still on the path.

That's it! From here, you'd want to build a walking script that'll send the commands to walk you along the path, along with aliases for the user to use.