Hi,Nick
After learning this link. I tried to make the test.Got a strange results.
Now I say I want to get what.I went to a new world.So the need to draw a new map.I am not a programmer.But I love MUD and MUSHclient.
After the study, I made the following efforts.
I have completed most of the function map.Lack is, how to get the path from one room to another room.I can make the map data me like this.
map = {
{ vnum = 1, name = "Entrance", exits = { south = 4, east = 2 } },
{ vnum = 2, name = "Kitchen", exits = { west = 1, east = 3, south = 5 } },
{ vnum = 3, name = "Garden", exits = { west = 2, south = 6 } },
{ vnum = 4, name = "Livingroom", exits = { north = 1, east = 5 } },
{ vnum = 5, name = "Bedroom", exits = { north = 2, west = 4 } },
{ vnum = 6, name = "Toilet", exits = { north = 3, west = 5 } },
{ vnum = 7, name = "Nowhere", exits = {} },
}
But paint a room, the room can not automatically return to the current_room.I hope to have a path.I made the attempt.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Example_Mapper"
author="Nick Gammon"
id="63e6909083318cf63707c044"
language="Lua"
purpose="Example mapper"
save_state="y"
date_written="2014-10-22"
requires="4.61"
version="1.0"
>
<description trim="y">
<![CDATA[
AUTOMATIC MAPPER ... by Nick Gammon
ACTIONS
mapper help --> this help (or click the "?" button on the bottom right)
]]>
</description>
</plugin>
<aliases>
<alias
match="mapper help"
script="OnHelp"
enabled="y"
>
</alias>
<alias
match="mapper test"
script="test"
enabled="y"
>
</alias>
---------################ Here is my own to add. ##############-----
<alias
match="find test"
script="find_test"
enabled="y"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
-- mapper module
require "mapper"
require "tprint"
-- configuration table
config = { }
rooms = {
[1] = {
name = "Town Square",
exits = { n = 2, s = 3, e = 4}
},
[2] = {
name = "The Inn",
exits = { s = 1 }
},
[3] = {
name = "Butcher",
exits = { n = 1 }
},
[4] = {
name = "Main Street",
exits = { w = 1, e = 5 }
},
[5] = {
name = "West Main Street",
exits = { w = 4 }
},
} -- example rooms table
-- -----------------------------------------------------------------
-- mapper 'get_room' callback - it wants to know about room uid
-- -----------------------------------------------------------------
function get_room (uid)
room = rooms [uid]
if not room then
return nil
end -- if not found
room.area = "The swamp" -- OK, let's assume every room is in this area
room.hovermessage = room.name
return room
end -- get_room
-- -----------------------------------------------------------------
-- Plugin Install
-- -----------------------------------------------------------------
function OnPluginInstall ()
-- initialize mapper
mapper.init {
config = config, -- ie. colours, sizes
get_room = get_room, -- info about room (uid)
show_help = OnHelp, -- to show help
}
mapper.mapprint (string.format ("MUSHclient mapper installed, version %0.1f", mapper.VERSION))
end -- OnPluginInstall
-- -----------------------------------------------------------------
-- Plugin Help
-- -----------------------------------------------------------------
function OnHelp ()
mapper.mapprint (string.format ("[MUSHclient mapper, version %0.1f]", mapper.VERSION))
mapper.mapprint (world.GetPluginInfo (world.GetPluginID (), 3))
end
-- -----------------------------------------------------------------
-- test
-- -----------------------------------------------------------------
function test (name, line, wildcards)
mapper.draw (1) -- draw room 1
end -- test
---------################ Here is my own to add. ##############-----
function find_test ()
myuid = 5
a, b, c = mapper.find_paths(1,
function (myuid)
return uid == wanted, -- wanted room?
uid == wanted -- stop searching?
end)
print(a)
print("b = "..b)
print("c = "..c)
tprint(a)
end
]]>
</script>
</muclient>
|