Add area - As defined area id?

All and any discussion and development of the Mudlet Mapper.
Post Reply
Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Add area - As defined area id?

Post by Nyyrazzilyss »

The command to add a new area to the map generates the area id.

areaID = addAreaName(areaName)

Is there any way I could supply a pre-defined area id? There's 350 zones on the mud i'm writing the mapper script for, and ideally i'd be able to sync that number with the areaid in the mapper. I can still work with it if not possible (I internally store a list of names/mud area id, could use that to translate), would just be easier.

Something like: addAreaName("Jotunheim", 263)

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

Re: Add area - As defined area id?

Post by SlySven »

Off the top of my head (I don't have the Qt Creator IDE open at this precise moment) checkout the details of the setAreaName( (number)areaID, (string)areaName) command - IIRC it will create a new area with the given (positive) ID number if that area does not already exist (and rename it if does).

As it happens I do have a commit in place that (when released in the next 3.0.0 preview "epsilon"(?) or in an actual release version if we think the code is good to be released) will allow the above command to also take an existing area-name as an alternative to the area ID so you can rename an area without having to know the ID but that is in the pipeline and not in any binary releases at this point in time.

One other factor that you might like to note is that from the above code commit areas must have a unique, non-empty name - which can use characters that are not ASCII. This will be enforced and any existing maps that are subsequently loaded in will be automagically fixed. An area that then gets created without a name will become something like "Unnamed Area" and if a duplicate name is found the duplicates will gain a "_001", "_002", etc. type suffix. This is so that the Area Selection widget on the mapper and lua command that take an area name as an argument never have any ambiguity as to the area under consideration...

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Add area - As defined area id?

Post by Nyyrazzilyss »

Thanks! That worked.

You might want to update that on the manual, it indicates that setAreaName requires a pre-existing area. :)

I will give the user an alias for creating areas, but i'm not going to give them any choice on the names/id - I've pulled all that information from the mud.

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

Re: Add area - As defined area id?

Post by SlySven »

Dangnabit! The aforesaid changes breaks that and enforces "setAreaName" requiring a pre-existing name - thereby preventing using it to create a new area with specified ID. For some (historic I suspect) reason the Area's name is not actually stored inside the structure that holds the area's data and instead is held separately in a centralised table - and I've just broken things by checking for the existence of an area with a given ID in the data structure that holds (most) of the areas' data rather than the data structure that only holds the areas' names which is what gets modified by that command - even though it then means you have area names stored against an area ID number WITHOUT a corresponding data structure for an area with that ID number... grrrr

EDIT: Right, I think I'll found the fix for this and lined it up to go in. :geek:

ANOTHER EDIT: Bother, as you say below, it needs more work...

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Add area - As defined area id?

Post by Nyyrazzilyss »

Turns out in combination with setRoomArea, it doesn't work :( Can create the area, it shows in the list, but can't use it. While it would have been nice, i'll have to stick with keeping an extra table and using that to translate for now.

Post Reply