Door names?

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

Door names?

Post by Nyyrazzilyss » Sun Sep 27, 2015 10:52 pm

Looking at the below command (setDoor) it appears to allow me to create a door in any direction in any room. What if the keyword for the door *isn't* door? For example, gate/boulder/etc.

Before I use RoomUserData to store/access the information, is there a command to do so already?

For example, if I want to create a doorways on the west and north walls of a room with keywords 'gate' - open gate north, open gate west would open them.

setDoor would appear to allow me to create a door in a specific direction, but doesn't allow me to change the name of it.



setDoor
setDoor(roomID, exitCommand, doorStatus)
Creates or deletes a door in a room. Doors are purely visual - they don't affect pathfinding. You can use the information to change to adjust your speedwalking path based on the door information in a room, though.

exitCommand:
The cardinal direction for the door is in - it can be one of the following: e,s,w,n,ne,se,sw,ne. {Plans are afoot to add support for doors on the other normal exits: up,down,in,out and also on special exits though more work will be needed for them to be shown in the mapper.}
doorStatus:
The door status as a number - 0 means remove door, 1 means open door (will draw a green square on exit), 2 means closed door (yellow square) and 3 means locked door (red square).

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

Re: Door names?

Post by SlySven » Tue Sep 29, 2015 11:53 pm

It's a purely visual marking to go on the 2D map - to indicate that there is something special about the exit in that direction - with three alternatives besides the default "normal/none" state. For examples see here:
Current code (release_30 branch commit-b19e2b3c on GitHub) situation:
Mudlet map screen shot (old)_round.png
There are some issues with this - see the corresponding output from code that I am trying to get ready to put in a future release:

The choice of "open", "closed", and "locked" state was to reflect a typical usage to indicate "doors" but that need not be how the user actually uses it other than that the colours are hard-coded to be green, orange and red respectively.

For your gate situation you may want to forgo the "normal" exits and switch to "special" exits (and draw in some custom exit lines to show them on the 2D map) so that the north exit is "open gate north" and the east is "open gate east" - I think that will cause the Mudlet main application to actually produce that output if the route finding code chooses that exit as part of a route.

I'm not so sure how the lua subsystem uses the data - the default package comes with two different systems for some different MUDs - if you want to investigate further check out the 3k-mapper.xml file that is automagically loaded for the "3Scapes" and "3Kingdoms" MUDs and the mudlet-mapper.xml one that is loaded for the (IRE) Achaea, Aetolia, Imperian, Lusternia and Midkemia MUds. It is also possible that you will want something different, especially if you are coding your own system for other things.

A sneak preview I have cobbled together so far:
Mudlet map screen shot (new).png
Using round rooms:
Mudlet map screen shot (new)_round.png

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

Re: Door names?

Post by Nyyrazzilyss » Wed Sep 30, 2015 12:33 am

I'm unsure about the route finder with custom exits, but I do know it ignores setDoor.

When I first went about adding doors into the map, I had used custom exits. It didn't really work with the map though, it was showing either no connection, or connections with one way arrows on them. I wasn't aware of the option to replace that with custom exit lines. I just had a quick look at the documentation, though, and it appears to only be doable through the gui/editor, not by lua command. Is that correct? My primary map source is a cmud map file, and i'm using a modified version of the import script posted elsewhere here to move the map into mudlet.

The route finder gives me a list of directions/room numbers. I think i'll proceed with just using setDoor, and adding a table to userdata for any room with a door to give the respective name of it. Unless i'm missing something completely, i'm assuming I need to insert commands to open doors myself anyways.

My biggest concern before I did that though was that I was missing/wasn't using something already present with the existing mudlet code.

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

Re: Door names?

Post by SlySven » Wed Sep 30, 2015 2:33 am

Check out the lua command addCustomLine( from id, id_to, direction, style, line colour, arrow )

Note that id_to is one of:
  • a room Id number - of a room on same area who's x and y coordinates are used as the other end of a SINGLE segment custom line, it does NOT imply that is what the exit it represent goes to, just the location of the end of the line).
  • a table of sets of THREE (x,y and z) coordinate in that order, x & y are decimals and z is an integer AND MUST BE PRESENT AND MUST BE THE SAME FOR ALL POINTS though it is irrelevant to what is produced as the line is drawn on the same z-coordinate as the room that the line is attached to!
Direction is a string to associate the line with the exit direction which to work properly must be an UPPERCASE string for the Normal exits, one of: "N", "NE", "E", "SE", "S", "SW", "W", "NW", "UP", "DOWN", "IN" or "OUT" or the Mixed Case as NEEDED string for a Special exit - though if there is a clash the effects are not good {e.g. don't have a special exit called "OUT"}! Also note that this set of normal exit "keys" are not the same as those used for exit weights, doors or locks...! :twisted:

Style is a string, one of: "solid line", "dot line", "dash line", "dash dot line" or "dash dot dot line" exactly.

Colour is a table of three 0-255 numbers being the red, green and blue components of the wanted colour in that order.

Finally arrow is a boolean which puts the arrow on the end of the last segment if true.

The mess over identifying normal exit directions is something that really mucks things about internally to the C++ code base - and as I type I am take the code "class" that holds the individual room details {TRoom}, apart to try and finally straighten things out, which badly needs to be done so we can handle more than just English. I intend to have a fresh set of the lua commands associated with an exit direction in 2 flavours: ...NormalExitDirCode... and ...SpecialExit... the first will only use a number between 1 and 12 as some commands already do and will map explicitly to the set:
  1. north
  2. north-east
  3. north-west
  4. east
  5. west
  6. south
  7. south-east
  8. south-west
  9. up
  10. down
  11. in
  12. out
whereas the second is never interpreted as a normal exit direction. This will work much better in practice for those constructing scripts as they can be language independent and not have to worry about problems with contracting direction words into single, or pairs, of letter {e.g. the Welsh for south and east both begin with the letter 'd'!} and of course ALL the new commands will work with the same (normal) exit identifiers... 8-)

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

Re: Door names?

Post by Nyyrazzilyss » Wed Sep 30, 2015 12:53 pm

You'll want to add that post re: addCustomLIne to the mapper documentation - I just rechecked, and the command/instructions to use it aren't present in the documentation website or google search.

Thanks

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

Re: Door names?

Post by SlySven » Wed Sep 30, 2015 10:47 pm

Use the source, you must, impetuous young Luke...
Ah, yes, right, I have just added the details to the wiki {and also for the getCustomLines(roomId) command} :oops:

Strangely, these went in for the Mudlet 2.1 version, but, as of yet, there is not a removeCustomLine() command - though you can overwrite an existing custom line with new values for the same exit, and remove/edit it from the 2D Map GUI...

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

Re: Door names?

Post by Nyyrazzilyss » Mon Oct 05, 2015 10:41 pm

Just a followup on this in case anyone else starts running into the same problem - get/setRoomUserData worked acceptably in combination with get/setDoors to have the mapper display properly, and information available for different door names. It's very fast. It also worked in combination with the speedwalk code I use.

The below are fragments only, they're not 100% self contained functions.

// set
local exitNames = getRoomUserData(FromID, "exitNames")
if exitNames == "" then
exitNames = {}
else
exitNames = yajl.to_value(exitNames)
end
exitNames[NyyLIB.Mapper.exitmap[dirtype]] = name
setRoomUserData(FromID, "exitNames", yajl.to_string(exitNames))

// get

function findDoorName(xdir)
local exitNames
exitNames = getDoors(NyyLIB.Mapper.queueroomID)

if exitNames[xdir] then
exitNames = getRoomUserData(NyyLIB.Mapper.queueroomID, "exitNames")
if exitNames ~= "" then
exitNames = yajl.to_value(exitNames)
end
if exitNames[xdir] then
return(exitNames[xdir])
end
return("door")
end
return(nil)
end

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests