Cost of path

Post Reply
Swal
Posts: 14
Joined: Mon Mar 17, 2014 12:16 am

Cost of path

Post by Swal »

Hi!

I'm trying to implement a feature which would tell me the cost of the path between room A and B. Reason for this is I want to be able to tell which room is closest (or most efficient to get to) among a list of rooms.

Room weight looked like the perfect candidate (I'm not using exit weight), however when I'm trying to call getRoomWeight(roomid), it always returns 1. I know for fact it is incorrect, because when I open the weight through graphical UI it shows me a higher number. setRoomWeight also works, else I would have noticed this a year ago. Built in path finder seem to be using the weight properly.

I'm wondering if there is any way to mine out the correct data from the map? Or maybe there is already a function I'd like to create but missed somehow?

Thanks in advance!

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

Re: Cost of path

Post by SlySven »

Well I've just quickly tested on current-ish development code and have not experienced the issue you are describing, are you sure "roomid" is a valid value and IS the room you want to check (you don't have a global roomid and a roomId at the same time do you?) Note that 1 is the default weight for a room if you have not set a different value so I'm wondering whether you are actually referring to a different, unchanging variable with a similar name?

FWIIW Setting an exit weight overrides the weight of the destination room if that exit is used to go TO that room IRRC - I may have made a mistake in the tool-tips for the exits GUI dialog. :oops:

Swal
Posts: 14
Joined: Mon Mar 17, 2014 12:16 am

Re: Cost of path

Post by Swal »

I have selected the room through the Map, it shows me id 32771. When I check weight of the room through UI, it shows me 300 (last thing I want to enter, but still do). Next thing I do is getRoomWeight(32771). it returns me 1.

My version is Mudlet 2.1 (not sure what is the exact version, getMudletVersion is nil), I'm using W7 64 bit

It could be that it is time I upgrade my client, last downloaded about half a year ago, one of the stable builds.
Will report back once I did that.

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

Re: Cost of path

Post by SlySven »

The only thing that you might want to watch out for is where you say "I have selected" - do you mean you have clicked on the room and it has lit up in orange? By default the room that things like the 2D mapper context menu GUI "weight" command act on is the "current" room - which you can set with "lua centerview(roomId)" - unless one or more different rooms are actually "lit up" to indicate selection (only if more than one room is "selected" does the widget that lists all of them, and which allows you to select only some of them appear). The result of all of this is that you can sometimes do something on the "current" room by mistake when you thought you were doing things on the "selected" room and visa-versa - and this is something that might explain what you are describing IMHO.

getMudletVersion() was only introduced in a recent 3.0-ish version - it isn't in 2.1 which is why you were getting a nil result. ;)

Swal
Posts: 14
Joined: Mon Mar 17, 2014 12:16 am

Re: Cost of path

Post by Swal »

Thank for your reply, SlySven.

Yeah, I made sure I'm selecting properly. Just for test's sake, I even made a loop that went trough every single room, and did a getRoomWeight on them. None of them differed to 1.

Today I'll upgrade to 3.0, check out all the new goodies and hope all my script still work.

Swal
Posts: 14
Joined: Mon Mar 17, 2014 12:16 am

Re: Cost of path

Post by Swal »

I can confirm 3.0 works as expected.

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

Re: Cost of path

Post by SlySven »

That is strange though, a scan of the code at Source Forge which is what 2.1 was built from does not seem to show an obvious explanation for what you have described. Though I'm glad that the current development code does not show it - so it is nice to have the opposite to a "regression"... :wink:

Post Reply