Nyyrazzilyss / NyyLIB

Mudlet client script for Torilmud
http://www.torilmud.com/phpBB3/viewtopic.php?f=4&t=27194
GNU General Public License v2.0
7 stars 4 forks source link

coloured map #302

Open Nyyrazzilyss opened 2 years ago

Nyyrazzilyss commented 2 years ago

In @map:

`if matches[2] == "score" then local list = getAreaTable() local fullmap = getRooms()

local totalmap=0
local totalfound=0

local totalcoloured=0

local totalarea=0
local areasfound=0

local maprooms = {}

for roomid, roomname in pairs(fullmap) do
    local internalid = getRoomArea(roomid)

    local zone=getRoomUserData(roomid, "zoneid")
    local zoneid=tonumber(zone)

local env=getRoomEnv(roomid)

    if zoneid ~= nil then
        -- first appearance of room in area
        if maprooms[NyyLIB.areaTable[zoneid]] == nil then
            maprooms[NyyLIB.areaTable[zoneid]] = {0,0,0}
        end

        if internalid == -1 then
            -- undiscovered room
            maprooms[NyyLIB.areaTable[zoneid]][2] = maprooms[NyyLIB.areaTable[zoneid]][2] + 1
        else
            -- discovered room
            maprooms[NyyLIB.areaTable[zoneid]][1] = maprooms[NyyLIB.areaTable[zoneid]][1] + 1

    -- room is coloured
    if env ~= 271 then
      maprooms[NyyLIB.areaTable[zoneid]][3] = maprooms[NyyLIB.areaTable[zoneid]][3] + 1
    end
  end
    else
        -- echo("nil room " .. roomid .. "\n")
    end
end

for k,v in pairs(maprooms) do
    if v[1] ~= 0 then

  echo ( string.format("%45s %4d/%4d  rooms, ( %5.2f%% )  Coloured: ( %5.2f%% )\n", k, v[1], v[1]+v[2], v[1]*100/(v[1]+v[2]), v[3]*100/(v[1]) ) )

        totalfound=totalfound+v[1]
        areasfound=areasfound+1

  totalcoloured=totalcoloured+v[3]
    end
    totalmap=totalmap+v[1]+v[2]
end

echo( string.format("\n             found %3d/%-3d included areas      %d/%d rooms  ( %5.2f%% ) Coloured: ( %5.2f%% )\n\n", 
    areasfound, table.size(maprooms), totalfound, totalmap, totalfound*100/totalmap, totalcoloured*100/totalfound) )

end `

Nyyrazzilyss commented 2 years ago
@freqtable
pattern: ^@freqtable( [0-9]+)?$

local ftable={}
local targetzone=0

if matches[2] then
  targetzone=tonumber(matches[2])
end

for k,v in pairs(getRooms()) do
  local rzone=tonumber(getRoomUserData(k, "zoneid"))

  if targetzone==0 or targetzone==rzone then
    roomwords= string.split( string.lower(v), " ")

    for k2, v2 in pairs(roomwords) do
      if not table.contains({ "the", "a", "of", "in", "an", "at", "on" }, v2) then -- words to exclude
        ftable[v2]=ftable[v2] or 0
        ftable[v2]=ftable[v2]+1
      end
    end
  end
end

local arr = {}

for key, value in pairs(ftable) do
  arr[#arr + 1] = {key, value}
end

table.sort(arr, function(a,b) return a[2] > b[2] end )

display(#arr)

for nx=0,38,1 do  -- math.floor(#arr/7)
  for dx=1,7,1 do
    local entry=nx*7+dx

    if arr[entry] then
      echo( string.format("%d) %s (%d) ", entry, arr[entry][1], arr[entry][2]) )
    end
  end

  echo("\n")
end