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 ➜ Miniwindows ➜ Help with mapper

Help with mapper

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


Pages: 1 2  

Posted by Death   (55 posts)  Bio
Date Tue 08 Jan 2019 12:33 PM (UTC)

Amended on Fri 18 Jan 2019 06:47 AM (UTC) by Nick Gammon

Message
Hey Nick,

I've done my best to adapt the mapper you made, and it works quite well.
I've found that it looks quite beautiful when you require "aardmapper.lua" instead of mapper.lua; I love the resizing, and the general look of it all.

Everything is working well with my mapper, except I can't figure out how to make the CLICK to goto (click on map) or the mapper goto * function properly. With mapper.lua it works perfectly, but with aardmapper.lua, it doesn't. I can't seem to adapt it, or figure out what exactly is going on.

I'm getting this error when clicking on a room
"Run-time error
Plugin: AlterAeonMapper (called from world: Demonclient)
Function/Sub: mapper.mouseup_room called by Plugin AlterAeonMapper
Reason: Executing plugin AlterAeonMapper sub mapper.mouseup_room
DesktopMUSHclientluaaardmapper.lua:1187: attempt to call global 'findpath' (a nil value)
stack traceback:
DesktopMUSHclientluaaardmapper.lua:1187: in function 'full_find'
DesktopMUSHclientluaaardmapper.lua:1403: in function 'find'
DesktopMUSHclientluaaardmapper.lua:1556: in function DesktopMUSHclientluaaardmapper.lua:1536>"


and this when I am doing mapper goto *
Run-time error
Plugin: AlterAeonMapper (called from world: Demonclient)
Function/Sub: map_goto called by alias
Reason: processing alias ""
DesktopMUSHclientluaaardmapper.lua:1388: attempt to get length of local 'dests' (a nil value)
stack traceback:
DesktopMUSHclientluaaardmapper.lua:1388: in function 'find'
[string "Plugin: AlterAeonMapper"]:326: in function <[string "Plugin: AlterAeonMapper"]:312>



My code is located here.

https://pastebin.com/EsrTT3PB

I've scoured the forum for quite a while. Some of that code in there is not currently necessary, and some of it is from your recent post with the inquisition mapper. I'm just trying to figure it out.

Any guidance would help.

Cheers,

MasterVivi
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #1 on Tue 08 Jan 2019 07:17 PM (UTC)

Amended on Tue 08 Jan 2019 07:19 PM (UTC) by Fiendish

Message
Quote:
\Desktop\MUSHclient\lua\aardmapper.lua:1187: attempt to call global 'findpath' (a nil value)


Your call to mapper.init is insufficient for aardmapper.lua. You have to pass in a findpath implementation from your plugin.

Your init looks like this:

  mapper.init { config = config, get_room = get_room  }


But mine is more involved than that.
https://github.com/fiendish/aardwolfclientpackage/blob/d19bf291bada66c3cd9f76d3aec8b62baac3546c/MUSHclient/worlds/plugins/aard_GMCP_mapper.xml#L2952

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 08 Jan 2019 08:42 PM (UTC)
Message
Fiendish, if findpath is required you may want to check for that in init, like I do for get_room:


   supplied_get_room = t.get_room
   assert (type (supplied_get_room) == "function", "No 'get_room' function supplied to mapper.")


That way you get alerted earlier and with a more meaningful error message.

- Nick Gammon

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

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #3 on Tue 08 Jan 2019 11:21 PM (UTC)

Amended on Tue 08 Jan 2019 11:58 PM (UTC) by Fiendish

Message
Quote:
Fiendish, if findpath is required you may want to check for that in init

Lol. I don't exactly work on aardmapper.lua with interoperability with other people and other MUDs in mind. ^_^

It's fine if someone decides to borrow and modify it, but not having that check doesn't hurt me for two reasons:


  1. I consider the ability to interpret the error message
    aardmapper.lua:1187: attempt to call global 'findpath' (a nil value)
    to be a necessary skill when modifying code for a new context. It says exactly what happened and where.

    I don't have the peculiarities of aardmapper's usage of findpath memorized, so I just went to https://github.com/fiendish/aardwolfclientpackage/search?q=findpath to see where findpath is mentioned in my repository, and it showed me https://github.com/fiendish/aardwolfclientpackage/blob/2ad6646f861cacc41f92ffc9cc0394fe1677e1aa/MUSHclient/lua/aardmapper.lua#L989

  2. Aardwolf's mapper plugin is already written and debugged.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Death   (55 posts)  Bio
Date Reply #4 on Fri 11 Jan 2019 12:43 AM (UTC)

Amended on Fri 11 Jan 2019 12:47 AM (UTC) by Death

Message
Hey friends,


I've solved all of my issues, and everything is working well, thanks.

I've got quite an issue I need help with if you'd be so kind to help me work it out.


Currently, in my plugin, all directions with an undefined exit = 0 in my state file, and all directions with an exit defined = the vnum they go to.

Example:
  ["70409"] = {
    desc = "70409",
    area = "",
    fillcolour = 65280,
    fillbrush = 0,
    bordercolour = 16777215,
    name = "The Southern Road.",
    exits = {
      w = "70408",
      s = "70410",
      e = "0",
      },
    },


The main recall point in the game is vnum 0, and this makes WEIRD stuff happen to the mapper.

How do you reckon I can go about setting all of those undefined exits to -1, instead of 0, so that I can go in the main recall without destroying the whole mapper and ruining all rooms because it thinks its in other rooms, or continuously is fixing exits.


I tried doing it plugin side, here is the code.

-- -----------------------------------------------------------------
-- Here on "Exits:" line ----- we have changed rooms
-- -----------------------------------------------------------------

function process_exits (exits_str)
  
  -- genereate a "room ID" by hashing the room name, description and exits

  -- break up exits into individual directions
  exits = {}
  
  for exit in string.gmatch (exits_str, "%w+") do
    local ex = valid_direction [exit]
    if ex then
      exits [ex] = "0"  -- don't know where it goes yet
    end -- if
  end -- for

  -- add to table if not known
  if not rooms [uid] then
   rooms [uid] = { name = name, desc = uid, exits = exits, area=area, fillcolour=terrain_color[terrain], fillbrush=0, bordercolour=0xffffff }
  end -- if

  -- save so we know current room later on  
  current_room = uid


  
  -- call mapper to draw this rom
  mapper.draw (uid)

  -- try to work out where previous room's exit led  
  if expected_exit == "0" and from_room then
    fix_up_exit ()
  end -- exit was wrong
    
end -- process_exits


I tried changing
 exits [ex] = "0"  -- don't know where it goes yet
to -1, but it set ALL exits to -1, and wouldn't connect to the other rooms any more; it treated the room as a different area suddenly.

Do you think there is an easy fix to this?
Do you think I should be trying to make changes to my LUA file? I'd think it would be plugin side.

I'm not a professional coder like you guys, I'm just an amateur, but your guidance truly does help.

I appreciate your help...
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #5 on Fri 11 Jan 2019 02:50 AM (UTC)

Amended on Fri 11 Jan 2019 02:52 AM (UTC) by Fiendish

Message
I see "0" in more than one place in the code you posted, but you say you only changed one of them. Did you try changing the other one too? Are there other places that have "0" in your code? Did you try changing those as well?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Death   (55 posts)  Bio
Date Reply #6 on Fri 11 Jan 2019 07:50 PM (UTC)
Message
Hey fiendish,

I initially tried it, and it didn't work, but I guess I didn't change EVERY ONE. I've done it, and it's worked.

Thanks!
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #7 on Sun 13 Jan 2019 01:30 AM (UTC)
Message
Always glad to help!

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Death   (55 posts)  Bio
Date Reply #8 on Wed 16 Jan 2019 05:29 AM (UTC)

Amended on Wed 16 Jan 2019 05:30 AM (UTC) by Death

Message
Hey friends,

I've been building my database more and more using my state file, and it's becoming quite big, so I've adapted the materia magica plugin to work..

The map is building, and everything seems to be working, but my DATABASE file is not saving any data into it.

A database file was indeed created, but it remains empty.

The rooms draw, but when I reinstall the plugin, or close and reopen the client, it's all gone again..

What might be the problem?

My code is here

https://pastebin.com/GWJudaqT


Any help would be appreciated.... Cheers.

P.S. the database backup (manual) code in there doesn't work, I've not finished adding that in, I thought that might help with the problem, but I shouldn't try to band-aid fix the problem.
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #9 on Wed 16 Jan 2019 03:05 PM (UTC)

Amended on Wed 16 Jan 2019 03:10 PM (UTC) by Fiendish

Message
Do you know for sure that your save_room_to_database function is being called? If not, why not? If so, are the SQL commands in it failing?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #10 on Wed 16 Jan 2019 10:36 PM (UTC)
Message
Is the database indeed empty? Use the Sqlite3.exe command-line program to dump the contents of the rooms table.

eg.


select * from rooms;


You have show_database_mods as true, so you should see debugging displays when rooms are added.

- Nick Gammon

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

Posted by Death   (55 posts)  Bio
Date Reply #11 on Wed 16 Jan 2019 10:43 PM (UTC)
Message
The database is indeed empty, as I've used a program called "DB browser for SQLITE" and it only contains the blank tables.

I've got no messages saying any rooms have been added, only messages saying Fixed exit n from room 10103 to be to 36
(which lets me know when an exit was added to the room.)

Like I said, the rooms are drawing, but I'm getting NO debug messages for adding rooms via the database.


Any help would be appreciated; I've got no idea why this isn't working...
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #12 on Thu 17 Jan 2019 12:14 AM (UTC)

Amended on Thu 17 Jan 2019 12:26 AM (UTC) by Fiendish

Message
So save_room_to_database isn't being called. Look at where it's supposed to be called and check your assumptions.

A quick look at your process_exits function (where save_room_to_database gets invoked) shows ...


if not rooms [uid] then
   rooms [uid] = { name = name, description = uid, exits = exits, area=area, fillcolour=terrain_color[terrain], fillbrush=0, bordercolour=0xffffff }


thus ensuring that rooms[uid] is always populated.

Then you say

  current_room = uid


and

  local room = rooms [current_room]

and since uid and current_room are the same, room now always contains something because you already populated rooms[uid]

and then you only store something in the database if room is nil, which it is guaranteed to not be.


The basis for debugging a function that isn't being called is finding where it's supposed to be called, looking at the conditions that determine whether it gets called or not, and then walking backwards to see where those conditions are set the wrong way.


Reading the above in reverse, you should see:


if not room then
...
save_room_to_database


if not room then save_room_to_database...


room = rooms [current_room]


if not rooms[current_room] then save_room_to_database...


  current_room = uid


if not rooms[uid] then save_room_to_database...


if not rooms [uid] then
   rooms [uid] =  .... 


aha. rooms[uid] is never empty by the time it checks later whether it's empty, thus preventing it from ever getting put into the database.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Death   (55 posts)  Bio
Date Reply #13 on Thu 17 Jan 2019 09:16 PM (UTC)
Message
Hey friend, I've changed to the following code...

function process_exits (exits_str)

     -- generate a "room ID" by hashing the room name, description and exits
  -- break up exits into individual directions
  exits = {}
 for exit in string.gmatch (exits_str, "%w+") do
    local ex = valid_direction [exit]
    if ex then
      exits [ex] = "-666"  -- don't know where it goes yet
    end -- if
  end -- for
  if not rooms [current_room] then
   rooms [uid] = { name = name, roomdesc = uid, exits = exits, area=area, fillcolour=terrain_color[terrain], fillbrush=0, bordercolour=0xffffff }
  end -- if
  -- save so we know current room later on  
  current_room = uid


--  ColourNote ("rosybrown", "", roomdesc)
--  ColourNote ("olive", "", uid)
  
  local room = rooms [current_room]
  
  -- not cached - see if in database
  if not room then
    -- print ("Loading room", current_room, "from database")
    room = load_room_from_database (current_room)
  end -- not in cache
   
    
  
  if not room then
    -- print ("Added room", uid)  -- debugging
    -- print ("Name", name)
    -- ColourNote ("rosybrown", "", roomdesc)
     
    db:exec ("BEGIN TRANSACTION;") 	

    save_room_to_database (current_room, name, roomdesc)
    save_exits_to_database (current_room, exits)
    
    db:exec ("COMMIT;") 

    -- get it back now
    room = load_room_from_database (current_room)

  end -- if room not there
  
  -- call mapper to draw this rom
  mapper.draw (current_room)    -- redraw room with name

  -- try to work out where previous room's exit led  
  if expected_exit == "-666" and from_room then
    fix_up_exit ()
  end -- exit was wrong
  
end -- process_exits


What I've changed from
 if not rooms [uid] then
rooms [uid] = { name = name, roomdesc = uid, exits = exits, area=area, fillcolour=terrain_color[terrain], fillbrush=0, bordercolour=0xffffff }


to
  if not rooms [current_room] then
   rooms [uid] = { name = name, roomdesc = uid, exits = exits, area=area, fillcolour=terrain_color[terrain], fillbrush=0, bordercolour=0xffffff }


Now I'm getting rooms added to the database, but I'm popping an error..

Run-time error
Plugin: Materia_Magica_Mapper (called from world: Demonclient)
Immediate execution
[string "Plugin: Materia_Magica_Mapper"]:589: bad argument #1 to 'gmatch' (string expected, got table)
stack traceback:
[C]: in function 'gmatch'
[string "Plugin: Materia_Magica_Mapper"]:589: in function 'save_exits_to_database'
[string "Plugin: Materia_Magica_Mapper"]:113: in function 'process_exits'
[string "Trigger: Exits_Line"]:1: in main chunk

every time I enter a room.

When I type look again, it's fine, and when I walk back to the previous room, it fixes exits still.
The problem seems to be only when adding the room to the database. The room itself won't draw until I type look again, and I don't get the error code after looking again.


Hrm.. Is it because current_room is something that is saved and loaded into the database like this?

    save_room_to_database (current_room, name, roomdesc)
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #14 on Thu 17 Jan 2019 10:29 PM (UTC)

Amended on Thu 17 Jan 2019 10:51 PM (UTC) by Fiendish

Message
Quote:
FIXED initial problem.

Please don't remove the content of your posts after you get your answer. The forum is for everyone to learn from. Editing posts to remove their content because _you_ don't need it anymore is poor etiquette.


Quote:
but I'm popping an error..

Did you read the error message?

Quote:
in function 'save_exits_to_database'

Quote:
bad argument #1 to 'gmatch' (string expected, got table)


What more information do you need than that? It looks straightforward to me.

https://github.com/fiendish/aardwolfclientpackage
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.


45,174 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.