lassiter-mapper.xml version 9c165b60 — first build [ezra]
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
# lassiter-mudlet — the package Lassiter Creek offers your Mudlet on connect
|
||||
|
||||
**Public on purpose.** The game (a MUD, Mudlet only) sends GMCP `Client.GUI` when you log in; Mudlet fetches
|
||||
`lassiter-mapper.xml` from here and installs it — a mapper that draws rooms from the game's `Room.Info` packets.
|
||||
Nothing else lives here: no game source, no tables, no rooms. The script's home is the private game repo
|
||||
(`lassiter-creek-world/clients/mudlet/`); this is the built copy. Current version: **9c165b60**.
|
||||
|
||||
Connect: `mill.tail813f8a.ts.net` port `8443`, TLS on.
|
||||
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE MudletPackage>
|
||||
<MudletPackage version="1.001">
|
||||
<ScriptPackage>
|
||||
<Script isActive="yes" isFolder="no">
|
||||
<name>lassiter-mapper</name>
|
||||
<packageName>lassiter-mapper</packageName>
|
||||
<script>-- Lassiter Creek — Mudlet mapper fed by GMCP Room.Info (W-8 / W-16). One script, no generic-mapper mode needed.
|
||||
-- The server sends Room.Info {num, name, area, exits={direction=num}} after every move and look (typeclasses/characters.py).
|
||||
-- Install: Mudlet → Scripts (the pencil icon) → Add Item → paste this whole file → Save. Then `look` in game.
|
||||
-- The map window: Mudlet's compass/map icon in the toolbar, or type `lua openMapWidget()`.
|
||||
|
||||
lassiter = lassiter or {}
|
||||
lassiter.last = lassiter.last or nil -- {num=, dir=} of the previous room and the direction we left by
|
||||
|
||||
local OFFSET = { -- where a new room is drawn relative to the one we came from
|
||||
north = {0, 1, 0}, south = {0, -1, 0}, east = {1, 0, 0}, west = {-1, 0, 0},
|
||||
northeast = {1, 1, 0}, northwest = {-1, 1, 0}, southeast = {1, -1, 0}, southwest = {-1, -1, 0},
|
||||
up = {0, 0, 1}, down = {0, 0, -1}, ["in"] = {1, 1, 0}, out = {-1, -1, 0},
|
||||
}
|
||||
local SHORT = { n="north", s="south", e="east", w="west", ne="northeast", nw="northwest",
|
||||
se="southeast", sw="southwest", u="up", d="down", ["in"]="in", out="out" }
|
||||
|
||||
-- remember the direction we tried to move in, so the new room can be placed beside the old one
|
||||
function lassiter.onSend(_, cmd)
|
||||
local c = (cmd or ""):lower():match("^%s*(%S+)")
|
||||
if c and (OFFSET[c] or SHORT[c]) then
|
||||
lassiter.pending_dir = SHORT[c] or c
|
||||
end
|
||||
end
|
||||
|
||||
local function areaId(name)
|
||||
local id = getAreaTable()[name]
|
||||
if not id then id = addAreaName(name) end
|
||||
return id
|
||||
end
|
||||
|
||||
function lassiter.onRoomInfo()
|
||||
local info = gmcp and gmcp.Room and gmcp.Room.Info
|
||||
if not info or not info.num then return end
|
||||
local num = tonumber(info.num)
|
||||
local isNew = not roomExists(num)
|
||||
if isNew then addRoom(num) end
|
||||
setRoomName(num, info.name or ("room " .. num))
|
||||
setRoomArea(num, areaId(info.area or "Lassiter Creek"))
|
||||
-- place a room we have never drawn: beside the room we came from, in the direction we moved
|
||||
if isNew then
|
||||
local prev = lassiter.last
|
||||
local dir = lassiter.pending_dir
|
||||
if prev and dir and OFFSET[dir] and roomExists(prev) then
|
||||
local x, y, z = getRoomCoordinates(prev)
|
||||
local o = OFFSET[dir]
|
||||
setRoomCoordinates(num, x + o[1], y + o[2], z + o[3])
|
||||
else
|
||||
setRoomCoordinates(num, 0, 0, 0)
|
||||
end
|
||||
end
|
||||
-- exits: every known destination gets a real link; an unknown one gets a stub so the map shows the opening
|
||||
for dir, dest in pairs(info.exits or {}) do
|
||||
local d = SHORT[dir] or dir
|
||||
dest = tonumber(dest)
|
||||
if dest and OFFSET[d] then
|
||||
if roomExists(dest) then setExit(num, dest, d) else setExitStub(num, d, true) end
|
||||
end
|
||||
end
|
||||
lassiter.last = num
|
||||
lassiter.pending_dir = nil
|
||||
centerview(num)
|
||||
end
|
||||
|
||||
if lassiter.h1 then killAnonymousEventHandler(lassiter.h1) end
|
||||
if lassiter.h2 then killAnonymousEventHandler(lassiter.h2) end
|
||||
lassiter.h1 = registerAnonymousEventHandler("gmcp.Room.Info", "lassiter.onRoomInfo")
|
||||
lassiter.h2 = registerAnonymousEventHandler("sysDataSendRequest", "lassiter.onSend")
|
||||
sendGMCP('Core.Supports.Set ["Room 1", "Char 1"]')
|
||||
cecho("<green>[lassiter] mapper armed — `look` to draw the room you are in.\n")
|
||||
-- version 9c165b60
|
||||
</script>
|
||||
<eventHandlerList/>
|
||||
</Script>
|
||||
</ScriptPackage>
|
||||
</MudletPackage>
|
||||
Reference in New Issue
Block a user