function isClass(className)
if string.lower(gmcp.Char.Status.class):match(string.lower(className)) == string.lower(className) then
return true
else
return false
end
end
Usage:
if isClass("runewarden") then
--stuff!
else
--things!
end
if isClass("dragon") then
--stuff!
else
--things!
end
- Easy, non long way to tell what class you are.

Comments
A few tips to shorten that one, you can call lower() like you did match(), use find() instead of match(), use type() to check if it returned a number (it returns nil if it doesn't find it) instead of using if statements, then you end up with:
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.
gethealth = function (arg) local level = arg.level local olevel = 0 if level > 100 then olevel = level - 100 level = 100 end local con = arg.con local bracelets = arg.bracelets or 0 if level < 1 or level >= 200 then return "Invalid character level. Please choose a character level between 1 and 199." elseif bracelets < 0 or bracelets > 3 then return "Invalid bracelet level. Please choose a bracelet level between 0 and 3." else return math.floor ((300+level*(3*con+4)+olevel*(3*con-16))*(1+bracelets*0.05)) end -- if end, -- funcYou call it (note the curly braces) like: gethealth {level=101,con=23,bracelets=2}
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.
function GetRoomExits()
roomexits = nil
for i,v in pairs(gmcp.Room.Info.exits) do
if not roomexits then
roomexits = string.upper(i)
else
roomexits = roomexits..","..string.upper(i)
end
end
roomexits = roomexits or "TRAPPED!"
roomlabel : setFgColor("white")
roomlabel:echo("<b>Exits<br>" ..roomexits, nil, "c")
end
roomlabel = Geyser.Label:new({name="Room Exits",x="0.5%", y="94%",width="25.5%", height=35,fontSize = 10,})
roomlabel : setFgColor("white")
roomlabel:setStyleSheet[[
border-image: url(C:/MudletGFX/chat.png);
]]
registerAnonymousEventHandler("gmcp.Room.Info", "GetRoomExits")
sortedpairs = function (tbl) local i = 0 local tmp = {} for n in pairs (tbl) do table.insert (tmp, n) end table.sort (tmp) return function () i = i + 1 if tmp[i] ~= nil then return tmp[i], tbl[tmp[i]] end end -- func end -- funcAs an example...
Given table: t = {b=true,a=true,c=true}
You use it like so: for k, v in sortedpairs (t) do print (k, v) end
And the result is:
I use this a lot when displaying output, like my rift.
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.
Here is a target herb/mineral highlight that I use:
-- cecho(herb)
if (herb == "aurum flake") or (herb == "piece of kelp") then
cecho("\n<white:green>[ KELP ][ KELP ]\n")
targeat:cecho("<white:green>[ KELP ]\n")
elseif (herb == "lobelia seed") or (herb == "argentum flake") then
cecho("\n<white:orange>[ LOBELIA ][ LOBELIA ]\n")
targeat:cecho("<white:orange>[ LOBELIA ]\n")
elseif (herb == "kola nut") or (herb == "quartz grain") then
cecho("\n<white:dark_orchid>[ KOLA ][ KOLA ]\n")
targeat:cecho("<white:dark_orchid>[ KOLA ]\n")
elseif (herb == "cuprum flake") or (herb == "bellwort flower") then
cecho("\n<white:gold>[ Bellwort ][ Bellwort ]\n")
targeat:cecho("<white:gold>[ Bellwort ]\n")
elseif (herb == "hawthorn berry") or (herb == "calamine crystal") then
cecho("\n<white:brown>[ Hawthorn ][ Hawthorn ]\n")
targeat:cecho("<white:brown>[ Hawthorn ]\n")
elseif (herb == "stannum flake") or (herb == "prickly ash bark") then
cecho("\n<white:purple>[ ASH ][ ASH ]\n")
targeat:cecho("<white:purple>[ ASH ]\n")
elseif (herb == "ginseng root") or (herb == "ferrum flake") then
cecho("\n<white:blue>[ GINSENG ][ GINSENG ]\n")
targeat:cecho("<white:blue>[ GINSENG ]\n")
elseif (herb == "bloodroot leaf") or (herb == "magnesium chip") then
cecho("\n<white:red>[ BROOT ][ BROOT ]\n")
targeat:cecho("<white:red>[ BROOT ]\n")
elseif (herb == "goldenseal root") or (herb == "plumbum flake") then
cecho("\n<white:yellow>[ GSEAL ][ GSEAL ]\n")
targeat:cecho("<white:yellow>[ GSEAL ]\n")
end -- if
end -- colourHerbs
Called by a simple trigger for the eat line:
if matches[2] == target then
colourHerbs(matches[4])
end
Results of disembowel testing | Knight limb counter | GMCP AB files
BM:
^(ice|void|fire|light)$
if matches[2] == "ice" then
infuse = "infuse ice"
elseif matches[2] == "void" then
infuse = "infuse void"
elseif matches[2] == "fire" then
infuse = "infuse fire"
elseif matches[2] == "light" then
infuse = "infuse lightning"
end
--Alias--
^(par|ast|sli)$
if matches[2] == "par" then
strike = "strike " ..target.. " neck"
elseif matches[2] == "ast" then
strike = "strike " ..target.. " throat"
elseif matches[2] == "sli" then
strike = "strike " ..target.. " underarm"
end
--Alias--
^lsl$
send("setalias lsl " ..infuse.. "/legslash " ..target.. " left/" ..strike..";queue add eqbal lsl")
Serpent:
^d([a-z])([a-z]?)$
if gmcp.Char.Status.class == "Serpent" then
local venom = {
a = "aconite",
b = "digitalis",
c = "curare",
d = "delphinium",
e = "eurypteria",
g = "gecko",
h = "selarnia",
i = "epseth",
k = "kalmia",
l = "larkspur",
m = "monkshood",
n = "selarnia",
o = "voyria",
p = "prefarar",
r = "darkshade",
s = "slike",
u = "euphorbia",
v = "vernalius",
x = "xentio",
z = "vardrax",
}
ven1 = venom[matches[2]]
ven2 = venom[matches[3]]
send("dstab " ..target.. " " ..ven1.. " " ..ven2)
--Alias--
^hyp(\d+)$
if gmcp.Char.Status.class == "Serpent" then
hypnoStep = 1
if matches[2] == "1" then
hyp = "hyp1"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 1<red>]")
send("hypnotise " ..target)
elseif matches[2] == "2" then
hyp = "hyp2"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 2<red>]")
send("hypnotise " ..target)
elseif matches[2] == "3" then
hyp = "hyp3"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 3<red>]")
send("hypnotise " ..target)
elseif matches[2] == "4" then
hyp = "hyp4"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 4<red>]")
send("hypnotise " ..target)
elseif matches[2] == "5" then
hyp = "hyp5"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 5<red>]")
send("hypnotise " ..target)
elseif matches[2] == "6" then
hyp = "hyp6"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 6<red>]")
send("hypnotise " ..target)
elseif matches[2] == "7" then
hyp = "hyp7"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 7<red>]")
send("hypnotise " ..target)
elseif matches[2] == "8" then
hyp = "hyp8"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 8<red>]")
send("hypnotise " ..target)
elseif matches[2] == "9" then
hyp = "hyp9"
cecho("\n<red>[<blue>Hypnotising " ..target.. " 9<red>]")
send("hypnotise " ..target)
end
end
if hyp == "hyp1" then
hypnoAffs = {
"clearalias hyp;setalias hyp suggest " ..target.. " stuff;queue add eqbal hyp",
}
elseif hyp == "hyp2" then
hypnoAffs = {
"same stuff",
}
elseif hyp == "hyp3" then
hypnoAffs = {
"same stuff",
}
elseif hyp == "hyp4" then
hypnoAffs = {
"same stuff",
}
elseif hyp == "hyp5" then
hypnoAffs = {
"same stuff",
}
elseif hyp == "hyp6" then
hypnoAffs = {
"same stuff",
}
elseif hyp == "hyp7" then
hypnoAffs = {
"same stuff",
}
elseif hyp == "hyp8" then
hypnoAffs = {
"same stuff",
}
elseif hyp == "hyp9" then
hypnoAffs = {
"same stuff",
}
end
--Alias--
^hyp$
hypnoStack()
--Script--
function hypnoStack()
send(hypnoAffs[hypnoStep])
end
--Trigger--
^You issue the suggestion, concealing it deep within (\w+)'s mind\.$
hypnoStep = hypnoStep+1
deleteFull()
cecho("\n<red>[<blue>Suggest Succeeded<red>]")
Penwize has cowardly forfeited the challenge to mortal combat issued by Atalkez.
-- Script hypnoAffs = { { "aff1", "aff2", "aff3", "aff4", "aff5" }, -- 1 { "aff2", "aff6", "aff7" }, -- 2, -- etc. } function hypnoStack() local list = hypnoAffs[hyp] if list and list[hypnoStep] then sendAll("setalias hyp suggest " .. target .. " " .. list[hypnoStep], "queue add eqbal hyp", false) else -- message indicating end of stack or invalid list end end -- Alias ^hyp(\d+)$ -- if we're not a Serpent, do nothing if gmcp.Char.Status.class ~= "Serpent" then return end hypnoStep = 1 hyp = tonumber(matches[2]) local affs = hypnoAffs[hyp] if affs then cecho("\n[Hypnotising " ..target.. " with " .. string.concat(affs, ", ") .. ".]") send("hypnotise " ..target) else -- some kind of error message indicating you've tried to use a list that doesn't exist end -- Alias ^hyp$ hypnoStack() -- Trigger ^You issue the suggestion, concealing it deep within (\w+)'s mind\.$ hypnoStep = hypnoStep+1 deleteFull() cecho("\n[Suggest Succeeded]")Adding a stack is as simple as adding a new entry into the hypnoAffs table, and it's just a list of affs itself, not the full commands, so it saves on typing (bonus: you can display exactly what it's going to suggest when picking the stack). Added some comments where you'd inform the user that they've tried to do something that won't work, like use a hypno stack they haven't defined or tried to suggest when there's no more suggestions.Results of disembowel testing | Knight limb counter | GMCP AB files
function comma (num) local subs while true do num, subs = tostring(num):gsub("^(-?%d+)(%d%d%d)", "%1,%2") if subs == 0 then break end end return num end