Function "addCustomLine" is nil

All and any discussion and development of the Mudlet Mapper.
Post Reply
CurryMUD
Posts: 19
Joined: Sat Mar 26, 2016 3:53 am

Function "addCustomLine" is nil

Post by CurryMUD » Mon Nov 21, 2016 9:53 pm

Hi,
In my mapper script I'm using the "addCustomLine" function, but it isn't working. The error message below indicates that the function is nil.
*** starting new session ***
[ERROR:] object:<WindowResizeEvent> function:<handleWindowResizeEvent>
<attempt to call a nil value>
[ERROR:] object:<WindowResizeEvent> function:<handleWindowResizeEvent>
<attempt to call a nil value>
[ERROR:] object:<event handler function> function:<curry_mapper>
<[string "mudlet = mudlet or {}; mudlet.mapper_script..."]:30: attempt to call global
'addCustomLine' (a nil value)>
I'm perplexed as everything was working for me previously. Unfortunately I don't know what I did to cause this issue.
I'm using Mudlet 2.1 on Mac. The issue is still occurring after reinstalling Mudlet. I also deleted and recreated my profile and scripts.

I tried using Mudlet 3.0 iota instead, and the issue went away. Unfortunately Mudlet kept crashing, though it stopped crashing when I disabled my vitals gauges script.

My scripts can be found here.

Does anyone have any ideas?
Thanks!

CurryMUD
Posts: 19
Joined: Sat Mar 26, 2016 3:53 am

Re: Function "addCustomLine" is nil

Post by CurryMUD » Tue Nov 22, 2016 1:48 am

Confirmed this is also happening on a fresh install of Mudlet 2.1 on Ubuntu 16.04 LTS.

CurryMUD
Posts: 19
Joined: Sat Mar 26, 2016 3:53 am

Re: Function "addCustomLine" is nil

Post by CurryMUD » Tue Nov 22, 2016 10:34 pm

I've been playing around some more with Mudlet 3.0 iota on Mac OS X El Capitan. As I mentioned, the nil "addCustomLine" issue isn't happening on Mudlet 3.0, so that's good. But Mudlet keeps crashing. I discovered that if I turn on the mapper before Mudlet receives my "Room.Info" GMCP, then it doesn't crash and everything works fine.
I can show the crash report if needed.

User avatar
SlySven
Posts: 903
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Function "addCustomLine" is nil

Post by SlySven » Wed Nov 23, 2016 3:04 am

What are you using to specify the exit direction that the custom line is for - looking at even the current code seems to need you to use one of the exact following UPPER-CASE command as the third argument:
"N", "NE", "E", "SE", "S", "SW", "W", "NW", "UP", "DOWN", "IN", "OUT". The code in the C++ core of Mudlet does have something that ought to take a number in the range 1 to 12 as one of those given directions but looking more deeply I see that the code that converts the number to a string key does not upper case it for normal exit directions so the line is stored but is not drawn because of the mis-match between cases when the custom line is stored and then attempted to be drawn later. The current map loading auditing code may note the presence of custom line data for a (special, as it does not match the expected normal) exit that does not exist - possibly before clearing it out of the map data... :(

That is the case with current code as I see it which largely dates back to a couple of days after 2.1 was released. In 2.1 itself I see that only strings can be used to specify the exit direction that the line is to be added to, and that the validation for an UPPER case DIRECTION has been commented out so that you may enter lower case strings and then they would not show for the same reasons that the newer stuff gets it wrong for a numeric code.

I suggest starting a separate topic (or raising a bug on our Launchpad Bug Tracker) about the crashing on GMCP it seems likely that something is trying to do a map related operation before the map data is present but why this is crashing the Mudlet application is not immediately clear to me.

<aside>BTW taking a quick look at your Scripts on github I spotted that your
Code: [show] | [select all] lua
function find_room_id(room_id)
  for id in pairs(getRooms()) do
    if id == room_id then return id end
  end
end
seems a non-optimum if you are attempting to validate room_id as a valid room. Instead of getting Mudlet to create and return the entire room table with getRooms() why not use getRoomName(...) and check for a non-nil response which an existent room will cause even if the room name is the empty string...!</aside>

User avatar
SlySven
Posts: 903
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Function "addCustomLine" is nil

Post by SlySven » Wed Nov 23, 2016 3:13 am

Oh, I was looking at the wrong branch! It seems that the Lua command "addCustomLine" was not present in the 2.1 release code, it was being worked on in a development branch at the time and was not merged in until June 2013 whereas release 2.1 came out in January that year. So the nil result you are getting is indeed correct from that version.

CurryMUD
Posts: 19
Joined: Sat Mar 26, 2016 3:53 am

Re: Function "addCustomLine" is nil

Post by CurryMUD » Wed Nov 23, 2016 5:05 am

Ah, well that explains it!
I'm glad we were able to get to the bottom of this, it was starting to drive me nuts. Strange though, I thought I had it working at one point... I must have been confused about that.
The docs are a bit misleading, as they say "Introduced in version 2.1 of Mudlet."

I'll see about filing a bug in the bug tracker regarding the 3.0 crash.

And thanks for pointing out my potentially slow code, I'm now using your suggested method and it seems to be working well for me. I had a feeling that what I was doing there wasn't ideal. I'm a complete newbie to Lua and it didn't occur to me that I could just use "getRoomName" and check for nil. Nice!

Many thanks for all your help! I'm really happy that my players will have the mapping functionality.
Recently I was able to move my gauges to the bottom of the screen using Gyser and I'm also quite happy with how that's turned out.

User avatar
SlySven
Posts: 903
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Function "addCustomLine" is nil

Post by SlySven » Wed Nov 23, 2016 6:51 pm

Tweaked the Wiki entry for this command...! 8-)

Post Reply

Who is online

Users browsing this forum: Darkfire and 1 guest