Extended color table: Adds two sets of colors, Aetolian color (specially-named colors that match Aetolia's standard output) and the "dead" series (super dark colors, great for backgrounds). Just pop this in a script you have and it'll add them automagically.
color_table = {
snow = {255, 250, 250},
ghost_white = {248, 248, 255},
GhostWhite = {248, 248, 255},
white_smoke = {245, 245, 245},
WhiteSmoke = {245, 245, 245},
gainsboro = {220, 220, 220},
floral_white = {255, 250, 240},
FloralWhite = {255, 250, 240},
old_lace = {253, 245, 230},
OldLace = {253, 245, 230},
linen = {250, 240, 230},
antique_white = {250, 235, 215},
AntiqueWhite = {250, 235, 215},
papaya_whip = {255, 239, 213},
PapayaWhip = {255, 239, 213},
blanched_almond = {255, 235, 205},
BlanchedAlmond = {255, 235, 205},
bisque = {255, 228, 196},
peach_puff = {255, 218, 185},
PeachPuff = {255, 218, 185},
navajo_white = {255, 222, 173},
NavajoWhite = {255, 222, 173},
moccasin = {255, 228, 181},
cornsilk = {255, 248, 220},
ivory = {255, 255, 240},
lemon_chiffon = {255, 250, 205},
LemonChiffon = {255, 250, 205},
seashell = {255, 245, 238},
honeydew = {240, 255, 240},
mint_cream = {245, 255, 250},
MintCream = {245, 255, 250},
azure = {240, 255, 255},
alice_blue = {240, 248, 255},
AliceBlue = {240, 248, 255},
lavender = {230, 230, 250},
lavender_blush = {255, 240, 245},
LavenderBlush = {255, 240, 245},
misty_rose = {255, 228, 225},
MistyRose = {255, 228, 225},
white = {255, 255, 255},
black = {0, 0, 0},
dark_slate_gray = {47, 79, 79},
DarkSlateGray = {47, 79, 79},
dark_slate_grey = {47, 79, 79},
DarkSlateGrey = {47, 79, 79},
dim_gray = {105, 105, 105},
DimGray = {105, 105, 105},
dim_grey = {105, 105, 105},
DimGrey = {105, 105, 105},
slate_gray = {112, 128, 144},
SlateGray = {112, 128, 144},
slate_grey = {112, 128, 144},
SlateGrey = {112, 128, 144},
light_slate_gray = {119, 136, 153},
LightSlateGray = {119, 136, 153},
light_slate_grey = {119, 136, 153},
LightSlateGrey = {119, 136, 153},
gray = {190, 190, 190},
grey = {190, 190, 190},
light_grey = {211, 211, 211},
LightGrey = {211, 211, 211},
light_gray = {211, 211, 211},
LightGray = {211, 211, 211},
midnight_blue = {25, 25, 112},
MidnightBlue = {25, 25, 112},
navy = {0, 0, 128},
navy_blue = {0, 0, 128},
NavyBlue = {0, 0, 128},
cornflower_blue = {100, 149, 237},
CornflowerBlue = {100, 149, 237},
dark_slate_blue = {72, 61, 139},
DarkSlateBlue = {72, 61, 139},
slate_blue = {106, 90, 205},
SlateBlue = {106, 90, 205},
medium_slate_blue = {123, 104, 238},
MediumSlateBlue = {123, 104, 238},
light_slate_blue = {132, 112, 255},
LightSlateBlue = {132, 112, 255},
medium_blue = {0, 0, 205},
MediumBlue = {0, 0, 205},
royal_blue = {65, 105, 225},
RoyalBlue = {65, 105, 225},
blue = {0, 0, 255},
dodger_blue = {30, 144, 255},
DodgerBlue = {30, 144, 255},
deep_sky_blue = {0, 191, 255},
DeepSkyBlue = {0, 191, 255},
sky_blue = {135, 206, 235},
SkyBlue = {135, 206, 235},
light_sky_blue = {135, 206, 250},
LightSkyBlue = {135, 206, 250},
steel_blue = {70, 130, 180},
SteelBlue = {70, 130, 180},
light_steel_blue = {176, 196, 222},
LightSteelBlue = {176, 196, 222},
light_blue = {173, 216, 230},
LightBlue = {173, 216, 230},
powder_blue = {176, 224, 230},
PowderBlue = {176, 224, 230},
pale_turquoise = {175, 238, 238},
PaleTurquoise = {175, 238, 238},
dark_turquoise = {0, 206, 209},
DarkTurquoise = {0, 206, 209},
medium_turquoise = {72, 209, 204},
MediumTurquoise = {72, 209, 204},
turquoise = {64, 224, 208},
cyan = {0, 255, 255},
light_cyan = {224, 255, 255},
LightCyan = {224, 255, 255},
cadet_blue = {95, 158, 160},
CadetBlue = {95, 158, 160},
medium_aquamarine = {102, 205, 170},
MediumAquamarine = {102, 205, 170},
aquamarine = {127, 255, 212},
dark_green = {0, 100, 0},
DarkGreen = {0, 100, 0},
dark_olive_green = {85, 107, 47},
DarkOliveGreen = {85, 107, 47},
dark_sea_green = {143, 188, 143},
DarkSeaGreen = {143, 188, 143},
sea_green = {46, 139, 87},
SeaGreen = {46, 139, 87},
medium_sea_green = {60, 179, 113},
MediumSeaGreen = {60, 179, 113},
light_sea_green = {32, 178, 170},
LightSeaGreen = {32, 178, 170},
pale_green = {152, 251, 152},
PaleGreen = {152, 251, 152},
spring_green = {0, 255, 127},
SpringGreen = {0, 255, 127},
lawn_green = {124, 252, 0},
LawnGreen = {124, 252, 0},
green = {0, 255, 0},
chartreuse = {127, 255, 0},
medium_spring_green = {0, 250, 154},
MediumSpringGreen = {0, 250, 154},
green_yellow = {173, 255, 47},
GreenYellow = {173, 255, 47},
lime_green = {50, 205, 50},
LimeGreen = {50, 205, 50},
yellow_green = {154, 205, 50},
YellowGreen = {154, 205, 50},
forest_green = {34, 139, 34},
ForestGreen = {34, 139, 34},
olive_drab = {107, 142, 35},
OliveDrab = {107, 142, 35},
dark_khaki = {189, 183, 107},
DarkKhaki = {189, 183, 107},
khaki = {240, 230, 140},
pale_goldenrod = {238, 232, 170},
PaleGoldenrod = {238, 232, 170},
light_goldenrod_yellow= {250, 250, 210},
LightGoldenrodYellow = {250, 250, 210},
light_yellow = {255, 255, 224},
LightYellow = {255, 255, 224},
yellow = {255, 255, 0},
gold = {255, 215, 0},
light_goldenrod = {238, 221, 130},
LightGoldenrod = {238, 221, 130},
goldenrod = {218, 165, 32},
dark_goldenrod = {184, 134, 11},
DarkGoldenrod = {184, 134, 11},
rosy_brown = {188, 143, 143},
RosyBrown = {188, 143, 143},
indian_red = {205, 92, 92},
IndianRed = {205, 92, 92},
saddle_brown = {139, 69, 19},
SaddleBrown = {139, 69, 19},
sienna = {160, 82, 45},
peru = {205, 133, 63},
burlywood = {222, 184, 135},
beige = {245, 245, 220},
wheat = {245, 222, 179},
sandy_brown = {244, 164, 96},
SandyBrown = {244, 164, 96},
tan = {210, 180, 140},
chocolate = {210, 105, 30},
firebrick = {178, 34, 34},
brown = {165, 42, 42},
dark_salmon = {233, 150, 122},
DarkSalmon = {233, 150, 122},
salmon = {250, 128, 114},
light_salmon = {255, 160, 122},
LightSalmon = {255, 160, 122},
orange = {255, 165, 0},
dark_orange = {255, 140, 0},
DarkOrange = {255, 140, 0},
coral = {255, 127, 80},
light_coral = {240, 128, 128},
LightCoral = {240, 128, 128},
tomato = {255, 99, 71},
orange_red = {255, 69, 0},
OrangeRed = {255, 69, 0},
red = {255, 0, 0},
hot_pink = {255, 105, 180},
HotPink = {255, 105, 180},
deep_pink = {255, 20, 147},
DeepPink = {255, 20, 147},
pink = {255, 192, 203},
light_pink = {255, 182, 193},
LightPink = {255, 182, 193},
pale_violet_red = {219, 112, 147},
PaleVioletRed = {219, 112, 147},
maroon = {176, 48, 96},
medium_violet_red = {199, 21, 133},
MediumVioletRed = {199, 21, 133},
violet_red = {208, 32, 144},
VioletRed = {208, 32, 144},
magenta = {255, 0, 255},
violet = {238, 130, 238},
plum = {221, 160, 221},
orchid = {218, 112, 214},
medium_orchid = {186, 85, 211},
MediumOrchid = {186, 85, 211},
dark_orchid = {153, 50, 204},
DarkOrchid = {153, 50, 204},
dark_violet = {148, 0, 211},
DarkViolet = {148, 0, 211},
blue_violet = {138, 43, 226},
BlueViolet = {138, 43, 226},
purple = {160, 32, 240},
medium_purple = {147, 112, 219},
MediumPurple = {147, 112, 219},
thistle = {216, 191, 216},
a_darkred = {128, 0, 0},
a_darkgreen = {0, 179, 0},
a_brown = {128, 128, 0},
a_darkblue = {0, 0, 128},
a_darkmagenta = {128, 0, 128},
a_darkcyan = {0, 128, 128},
a_grey = {192, 192, 192},
a_darkgrey = {128, 128, 128},
a_red = {255, 0, 0},
a_green = {0, 255, 0},
a_yellow = {255, 255, 0},
a_blue = {0, 85, 255},
a_magenta = {255, 0, 255},
a_cyan = {0, 255, 255},
a_white = {255, 255, 255},
dead_grey = {18, 27, 27},
dead_brown = {34, 23, 6},
dead_green = {0, 51, 0},
dead_red = {51, 0, 0},
dead_blue = {0, 0, 51},
dead_yellow = {34, 34, 0},
dead_magenta = {34, 6, 34},
dead_cyan = {6, 34, 34},
}
iecho(): Auto-colors special fields, and allows easy tokens to create informationally useful displays. Angle brackets, parentheses, and colons will be colored a dark grey. Putting a hash (#) before a name will automatically color it a fancy blue (the "name color"), whereas using an ampersand (&) will color it a fancy green (the "parameter color"). You can use !o, !x, !<, and !> in your echo to add special symbols.
Example: iecho("!< Test. I'm going to kill #Omei by &stabbing Her on 1/12/13. !>")
Outputs: « Test. I'm going to kill Omei by stabbing Her on 1/12/13. »
Note: This script uses my fancy colors above. You'll need to replace the "a_name" colors if you don't want to use them.
iecho = function (output)
-- iecho, or infoEcho.
-- This interesting little ditty will reformat
-- echoes to insert symbols, colors, and other things.
-- Default to Aetolian grey.
output = "<a_grey>" .. output
-- Differentiating slashes, colons, etc.
output = output:gsub("[\:\/\(\)]", "<a_darkgrey>%1<a_grey>")
-- Player/NPC names.
output = output:gsub("#(%w+)", "<a_cyan>%1<a_grey>")
-- Parameter names.
output = output:gsub("&(%w+)", "<a_green>%1<a_grey>")
-- Special characters.
output = output:gsub("!o", "<a_green>" .. string.char(7) .. "<a_grey>")
output = output:gsub("!x", "<a_red>" .. string.char(7) .. "<a_grey>")
output = output:gsub("!<", "<a_darkcyan>" .. string.char(171) .. "<a_grey>")
output = output:gsub("!>", "<a_darkcyan>" .. string.char(187) .. "<a_grey>")
cecho(output)
end
Comments
Anyone else got any neats scripts... or, know where to find a Add to Queue thingy?
[spoiler]
#echo %cr
#echo %ansi( 1)a 1
#echo %ansi( 2)a 2
#echo %ansi( 3)a 3
#echo %ansi( 4)a 4
#echo %ansi( 5)a 5
#echo %ansi( 6)a 6
#echo %ansi( 7)a 7
#echo %ansi( 8)a 8
#echo %ansi( 9)a 9
#echo %ansi( 10)a 10
#echo %ansi( 11)a 11
#echo %ansi( 12)a 12
#echo %ansi( 13)a 13
#echo %ansi( 14)a 14
#echo %ansi( 15)a 15
#echo %ansi( 16)a 16
#echo %ansi( 17)a 17
#echo %ansi( 18)a 18
#echo %ansi( 19)a 19
#echo %ansi( 20)a 20
#echo %ansi( 21)a 21
#echo %ansi( 22)a 22
#echo %ansi( 23)a 23
#echo %ansi( 24)a 24
#echo %ansi( 25)a 25
#echo %ansi( 26)a 26
#echo %ansi( 27)a 27
#echo %ansi( 28)a 28
#echo %ansi( 29)a 29
#echo %ansi( 30)a 30
#echo %ansi( 31)a 31
#echo %ansi( 32)a 32
#echo %ansi( 33)a 33
#echo %ansi( 34)a 34
#echo %ansi( 35)a 35
#echo %ansi( 36)a 36
#echo %ansi( 37)a 37
#echo %ansi( 38)a 38
#echo %ansi( 39)a 39
#echo %ansi( 40)a 40[/spoiler]
Edit: This is for CMUD.
local noTitleWords = { "a", "an", "the", "and", "of", "in" } string.title = function (str) if type(str) == "string" then str = str:gsub("([a-zA-Z']+)", function (word) if table.contains(noTitleWords, word) == false or word == str:match("^%w+") then word = string.upper(word:sub(1, 1)) .. string.lower(word:sub(2, -1)) return word end end) return str else return str end end string.space = function (x) x = x or 0 return string.rep(" ", x) end string.truncate = function (str, n) n = n or 80 if str:len() > n then return str:sub(1, n - 3) .. "..." else return str end endpNum(number/string): This function is for aesthetic displays. It will string numbers along with commas (I am American, after all) to enhance readability. It will cleanly accept both strings and actual numbers, spitting out a string as a result. Performance note: Despite my clumsy use of string concatenation, it processes -very- quickly. Even when using it in spammy displays like the tables shown in OFFERINGS LIST, there was no noticeable lag.
pNum = function (n) -- pNum, aka prettyNumber(). -- Inserts commas into number values. if type(n) ~= "string" and type(n) ~= "number" then error("Passed invalid type (" .. type(n) .. ") to pNum().") return end n = tostring(n) if n:match("^%d+$") == nil then return n elseif n:len() <= 3 then return n end local output = "" local count = 0 for i = n:len(), 1, -1 do count = count + 1 local x = n:sub(i, i) if i == n:len() then output = x elseif i == 1 then output = x .. output else if count == 3 then count = 0 output = "," .. x .. output else output = x .. output end end end return output endYou'll need these scripts, just put them in a new script window called Library or something:
library = library or {} library.list = library.list or {} library.scan = falseYou'll need these functions:
function additem(list, val) if table.contains(list, val) then return end table.insert(list, val) end
function library.bookSearch(criteria) for t,n in ipairs(library.list) do if string.findPattern(library.list[t].title, criteria) then cecho("\nCriteria matched. Book Number is ") echoLink(library.list[t].number, [[send("read " .. ]] .. library.list[t].number .. [[, false)]], "Read "..library.list[t].title.") end end end
These triggers:
Pattern - ^ \#(\d+) (.+)
Script
additem(library.list, {["title"] = matches[3], ["number"] = matches[2]})Exact match - An unseen presence whispers in your ear, "There is no more, friend."
Script
Pattern - ^Type MORE to continue reading\. \(\d+\% shown\)
script
if library.scan then send("more", false) send("more", false) endAnd finally, these Aliases:
Pattern - ^lcs$
Script
library.scan = true library.list = {} send("library catalog", false)Pattern - ^lss (\w+)$
Script
How this works is that when you enter the "lcs" alias, it will scan the entire library and store all the book titles with their corresponding numbers. You can then use the "lss" alias to do something like:
"lss Consanguine"
And it will return all book numbers with the word Consanguine in the title. It will also provide a link that you can click that will read the first page of the book (as well as show you the title of the book) for you lazy people.
Special thanks to @Lin for helping me with some of the code, and also for formatting the post for me. XD
#ALIAS ANSI {$a=1;$b="";#15 {#ADDI $b {%ansi(high, $a) $a};#ADD $a 1};#PRINT { ANSI:%replace($b,"|","")};#CR}
local escape_exits = {} for k,_ in pairs(gmcp.Room.Info.exits) do table.insert(escape_exits, k) end send("qeb " .. escape_exits[math.random(1,#escape_exits)])Are there 3 scripts called library = library or {}, library.list = library.list or {}, and library.scan = false ?
Which scripts do the fuctions go into?
The second function has an error on the echolink line.
Can anyone help this newbie at lau scripting?
A function is just a variable where the value is a set of instructions.
Copy the parts called scripts/functions to the script editor, all into one script 'object'. Or multiples - it makes no difference.
Paste.
The triggers are a separate object in mudlet, so create those there.
Go to command line and type:
lua display(library)
This will display the contents of the table you just created, called "library". It will be a mix of information, and functions.
library = {} --creates a blank table
library = library or {} --creates a blank table ONLY IF it doesn't already exist.
library.scan = false --creates a variable, nested in the table, called 'scan' with a value of false
function library.whatever()
-- creates a variable 'whatever' nested in the table, with a value that is a set of instructions
end
^All of that goes into a script object in the script editor.
The triggers are a separate thing
echoLink(library.list[t].number, [[send("read " .. ]] .. library.list[t].number .. [[, false)]], "Read "..library.list[t].title.")
In Mudlet, create a multiline trigger. The first trigger's pattern is:
You have the following on cooldown:
I call it "cooldown header." Set the "fire length" to 50-100 more lines. We're going to close this trigger when it hits prompt.
Then, nest a trigger in it called "cooldown capture" or whatever you like. Use the following lines as perl regex:
1: ^(:?(:?\w+)|(:?\w+) (:?\w+))\s+(\d+) minutes and (\d+) seconds$
2: ^(:?(\w+)|(:?\w+) (:?\w+))\s+(\d+)\s+(minutes)$
3: ^(:?(\w+)|(:?\w+) (:?\w+))\s+(\d+)\s+(seconds)$
Then, as an example body:
local cd = matches[2]:lower():gsub(" ", "_")
local cap = tonumber(matches[6])
local cap2 = matches[7]
if cap2 == "minutes" then
local time = tonumber(cap*60)
fs.offcd(cd)
fs.oncd(cd, time)
elseif cap2 == "seconds" then
local time = cap
fs.offcd(cd)
fs.oncd(cd, time)
else
cap = tonumber(cap*60)
cap2 = tonumber(cap2)
local time = tonumber(cap + cap2)
fs.offcd(cd)
fs.oncd(cd, time)
end
What the functions do is pretty obvious, so you should be able to adapt this to your own scripts.
the way she tells me I'm hers and she is mine
open hand or closed fist would be fine
blood as rare and sweet as cherry wine
table = {
"value1",
"value2",
"value3",
etc...
}
function ismember(list, value) if list==nil then echo("You didn't supply a list - ismember") return false elseif value==nil then echo("You didn't supply a value - ismember") return false end return table.contains(list, value) end function additem(list, value) if list==nil then echo("You didn't supply a list - additem") return false elseif value==nil then echo("You didn't supply a value - additem") return false end if not table.index_of(list, value) then table.insert(list, value) else return false end end function delitem(list, value) if list==nil then echo("You didn't supply a list - delitem") return false elseif value==nil then echo("You didn't supply a value - delitem") return false end if table.index_of(list, value)~=nil then table.remove(list, table.index_of(list, value)) end endif the value isn't a variable, like matches[2] or some sort, enclose it in "" for headaches.example:
additem(table, "value4")
function gmcp_enabled() local path = getMudletHomeDir() .."/current" local most_recent, mr_time, file mr_time = 0 for file in lfs.dir(path) do if file ~= "." and file ~= ".." then local f = path .. "/" .. file local attr = lfs.attributes(f) assert (type(attr) == "table") if attr.mode ~= "directory" then local time = attr.modification if time > mr_time then most_recent = f mr_time = time end end end end print(most_recent) local f = io.open(most_recent, "r") local t = f:read("*all") f:close() local b = string.find(t,[[mEnableGMCP="yes"]]) if not b then return false else return true end endFirst trigger pattern:
^\s?\[\*\]\s+\(say\)\s+(.+)
-- Regex
-- Fire length 10
First trigger script:
if not dlg_opt_num then dlg_opt_num = 1 else dlg_opt_num = dlg_opt_num + 1 end if not dlg_opts then dlg_opts = {} end dlg_opts[tostring(dlg_opt_num)] = matches[2] for k,v in pairs(dlg_opts) do if tonumber(k) > dlg_opt_num then dlg_opts[k] = nil end end selectString(matches[1],1) replace("") resetFormat() echoLink("\[" .. dlg_opt_num .. "\]" .. matches[2], [[send("]] .. "say " ..matches[2]..[[")]], "Dialogue Option")Second trigger pattern:
return isPrompt()--Lua function
Second trigger script:
dlg_opt_num = 0You can set up keys for the dialogue options using dlg_opts["1"], dlg_opts["2"] and so on.
I don't know how important it actually is to consider performance but 'gating' regex trigs like the above with a substring trig on 'say' will stop the regex from testing any line except ones with 'say' in it.
Two ways to do it, supposedly equal in efficiency.
1. Create a simple substrig trig with the pattern 'say' and no script/command. Drag the other trigger onto this new one.
2. Alternatively make the existing a multi pattern 'AND' trigger, with 'say' as the first pattern and the regex as the second.
Anyway, I hope someone finds that useful. I wasn't picking apart the above really nice script, just using it as an example to talk about efficiency.