Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ A question about mapper.lua.

A question about mapper.lua.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Lzkd   (28 posts)  Bio
Date Wed 05 Nov 2014 10:08 AM (UTC)

Amended on Wed 05 Nov 2014 10:10 AM (UTC) by Lzkd

Message
Hello,

I'm from China.Please forgive my English is not good enough.I have some experience using MUSHclient.But I never use mapper.lua.

Can you give me a tutorial on how to use mapper.lua, or link.I want to get this information through MUSHclient.
Top

Posted by Lzkd   (28 posts)  Bio
Date Reply #1 on Wed 05 Nov 2014 10:08 AM (UTC)

Amended on Wed 05 Nov 2014 10:14 AM (UTC) by Lzkd

Message
Hello,

I'm from China.Please forgive my English is not good enough.I have some experience using MUSHclient.But I never use mapper.lua.

Can you give me a tutorial on how to use mapper.lua, or link.I want to get this information through MUSHclient
Quote:

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 = {} },
}



I just get this data will be enough.I can own the data in a text or SQLite.
Thank you very much for taking the time to read my post.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 05 Nov 2014 08:01 PM (UTC)
Message
Please read this:

Template:post=12635 Please see the forum thread: http://gammon.com.au/forum/?id=12635.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Lzkd   (28 posts)  Bio
Date Reply #3 on Thu 06 Nov 2014 02:35 AM (UTC)
Message
Thank you for your attention.I'll go and read.
Thank you once again.
Top

Posted by Lzkd   (28 posts)  Bio
Date Reply #4 on Thu 06 Nov 2014 01:41 PM (UTC)
Message
Nick Gammon said:

Please read this:

(post=12635)


Hi,Nick

I think I understand this link.But I hope in my code, do not use plug-in.I try to modify the plugin, but failed.
Could you please give me a not plug-in examples or link.Thank you again.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 06 Nov 2014 08:17 PM (UTC)
Message
What went wrong? Post your code please. I don't have an example which is not in a plugin.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Lzkd   (28 posts)  Bio
Date Reply #6 on Fri 07 Nov 2014 01:37 PM (UTC)

Amended on Fri 07 Nov 2014 01:41 PM (UTC) by Lzkd

Message
Hi,Nick

Considering the different situation of each MUD.I chose to test this picture of the situation

http://gammon.com.au/images/mapper/mapper_show_simple_mud.png


I thought I could code for removing unwanted.The final results are as follows.

Quote:


-- mapper module
require "mapper"

-- 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

Top

Posted by Lzkd   (28 posts)  Bio
Date Reply #7 on Fri 07 Nov 2014 01:46 PM (UTC)

Amended on Fri 07 Nov 2014 02:06 PM (UTC) by Lzkd

Message
Then I run.

Quote:

/test()


The last error code.

Quote:


Run-time error
World: mapper-test
Immediate execution
D:\MUSHclient\lua\mapper.lua:215: attempt to call upvalue 'supplied_get_room' (a nil value)
stack traceback:
D:\MUSHclient\lua\mapper.lua:215: in function 'get_room'
D:\MUSHclient\lua\mapper.lua:933: in function 'draw'
[string "Script file"]:86: in function 'test'
[string "Command line"]:1: in main chunk


I don't know, what I missed code.I believe, just some local error.But I can't find this mistake.Thank you very much for your help.
Thank you again, you spend valuable time to read this post.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Fri 07 Nov 2014 07:56 PM (UTC)
Message
You are testing outside a plugin, therefore OnPluginInstall was not called (this is called when a plugin is loaded).

Your code works if you do this:


/OnPluginInstall ()  -- load mapper (do this once)


Then:


/test ()  -- draw room 1

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #9 on Fri 07 Nov 2014 07:58 PM (UTC)

Amended on Fri 07 Nov 2014 07:59 PM (UTC) by Nick Gammon

Message
You could remove this too if you want:


-- -----------------------------------------------------------------
-- Plugin Help
-- -----------------------------------------------------------------
function OnHelp ()
mapper.mapprint (string.format ("[MUSHclient mapper, version %0.1f]", mapper.VERSION))
mapper.mapprint (world.GetPluginInfo (world.GetPluginID (), 3))
end


But if you do the mapper "help" button won't work. But that code wouldn't work anyway because GetPluginInfo is only relevant inside a plugin.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Lzkd   (28 posts)  Bio
Date Reply #10 on Sat 08 Nov 2014 12:04 AM (UTC)
Message
Thank you very much for your help.I think I can continue to the back of the code.
Thank you again, you spend precious time to pay attention to my post.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #11 on Sat 08 Nov 2014 02:18 AM (UTC)
Message
I think some of the miniwindow stuff will not work so well if you are not using a plugin. Also, if you make a plugin (as in my example thread above) then it is much, much easier to distribute it to your friends, rather than getting them to add scripts, triggers, etc. to their individual worlds.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Lzkd   (28 posts)  Bio
Date Reply #12 on Sat 08 Nov 2014 09:01 AM (UTC)

Amended on Sat 08 Nov 2014 09:16 AM (UTC) by Lzkd

Message
Nick Gammon said:

I think some of the miniwindow stuff will not work so well if you are not using a plugin. Also, if you make a plugin (as in my example thread above) then it is much, much easier to distribute it to your friends, rather than getting them to add scripts, triggers, etc. to their individual worlds.



Hi,Nick

Thank you for your guidance.I am in today's code work, also felt the question you said.The same code, plugins environment is very good, whereas the error.
I think we should listen to your advice, to give up the previous ideas, let mapper.lua run in the plug-in environment.This can avoid a lot of strange errors.

I'm in the process of reading mapper.lua, have a new problem.
Quote:

start_speedwalk (path) -- starts speedwalking. path is a table of directions/uids
build_speedwalk (path) -- builds a client speedwalk string from path
cancel_speedwalk () -- cancel current speedwalk, if any
check_we_can_find () -- returns true if doing a find is OK right now
find (f, show_uid, count, walk) -- generic room finder
find_paths (uid, f) -- lower-level room finder (for getting back a path)


I believe, these functions can be finished in the map, in the map of the one uid for other uid walking.But I can't let it run correctly.
Could you please give me a examples or link.Thank you again.
Thank you for the use of valuable time, read my post.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #13 on Sat 08 Nov 2014 07:34 PM (UTC)
Message
There are examples of most of those in this plugin:

https://github.com/nickgammon/plugins/blob/master/Realm_Of_Magic_Mapper.xml

Quote:

But I can't let it run correctly.


If that doesn't help post what you are doing, and what happens.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Lzkd   (28 posts)  Bio
Date Reply #14 on Sun 09 Nov 2014 03:45 AM (UTC)

Amended on Sun 09 Nov 2014 06:39 AM (UTC) by Nick Gammon

Message
Nick Gammon said:

There are examples of most of those in this plugin:

https://github.com/nickgammon/plugins/blob/master/Realm_Of_Magic_Mapper.xml

Quote:

But I can't let it run correctly.


If that doesn't help post what you are doing, and what happens.


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>

Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


88,847 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.