MUSHClient script function compatibility
Porting a few of the most widely used MUSHClient script functions, as well as ensuring compatibilty with MUSHClient.
Blueprint information
- Status:
- Started
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- None
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- Discussion
- Series goal:
- None
- Implementation:
- Good progress
- Milestone target:
- None
- Started by
- PenquinCoder
- Completed by
Related branches
Related bugs
Sprints
Whiteboard
---
Is this still being worked on? Also, is there interest to be supporting this long-term?
---
API for MUSHclient - http://
Most used function of MUSHClient, and the Mudlet equivalent
##Naftali note - some functions in the second group would be greatly improved with a function to delete GUI triggers, etc.
mushenv = {
GetVariable = function (var) return _G[var] end,
GetVariableList = function () return _G end,
SetVariable = function (var,what) _G[var] = what end,
Simulate = feedTriggers,
Execute = expandAlias,
DeleteVariable = function (var) _G[var] = nil end,
DeleteTrigger = disableTrigger,
DeleteTriggerGroup = disableTrigger,
EnableTrigger = function (triggername,tf) if tf then enableTrigger(
DeleteTimer = disableTimer,
DeleteTimerGroup = disableTimer,
EnableTimer = function (timername,tf) if tf then enableTimer(
IsConnected = function () return true end,
prepmatches = function () table.remove(
Send = function (...)
local str,args = "", assert({ ... })
for i,v in ipairs(args) do str = str .. v end
send(str)
end,
colors = {
darkcyan = {0,139,139},
cyan = {0,255,255},
silver = {192,192,192},
lime = {0,255,0},
darkred = {139,0,0},
dimgray = {105,105,105},
lightgreen = {144,238,144},
darkgreen = {0,100,0},
normal = {192, 192, 192},
darkmagenta = {139,0,139},
olive = {128,128,0},
darkblue = {0,0,139},
},
ColourTell = function (...)
local args,fg,bg = assert({ ... })
for i = 1,table.maxn(args) do args[i] = args[i] or "black" end
if math.floor( #args / 3 ) ~= ( #args / 3 ) then debug("Args must be in groups of three") return end
for i = 1, #args, 3 do
fg = (mushenv.
bg = (mushenv.
setFgColor(
setBgColor(
echo(args[ i+2 ])
end
resetFormat()
end,
Tell = function (...)
local str,args = "", assert({ ... })
for i,v in ipairs(args) do str = str .. v end
echo(str)
end,
ColourNote = function (...)
local str,args,fg,bg = "", assert({ ... })
for i = 1,table.maxn(args) do args[i] = args[i] or "black" end
if math.floor( #args / 3 ) ~= ( #args / 3 ) then debug("Args must be in groups of three") return end
for i = 1, #args,3 do
fg = (mushenv.
bg = (mushenv.
str = str .. "<" .. fg[1] .. "," .. fg[2] .. "," .. fg[3] .. ":" .. bg[1] .. "," .. bg[2] .. "," .. bg[3] .. ">" .. args[ i+3 ]
end
decho(str)
end,
Note = function (...)
local str,args = "", assert({ ... })
for i,v in ipairs(args) do str = str .. v end
str = str .. "\n"
echo(str)
end,
IsTimer = function (id)
if not tostring(id) then return "eInvalidObject
id = mushtimers[id]
if not id or ( not isActive(
return 0,"eOK"
end,
AddTimer = function (timername,
local eEnabled,
local flagtypes = { "eEnabled"
local script,result,time = ""
for i,flag in ipairs(flagtypes) do
if flags < 2^(i-1) or math.fmod(
assert(
if assert(
end
if eReplace then killTimer(
if eAtTime then
hour = math.max(hour - tonumber(
minute = math.max(minute - tonumber(
second = math.max(second - ( tonumber(
end
time = (hour * 3600) + (minute * 60) + second
if response_text then script = script .. "send(" .. response_text .. ") " end
if scriptname then script = script .. scriptname end
if eOneShot then script = script .. " killTimer(" .. timername .. ")"
elseif eAtTime then script = script .. " killTimer(" .. timername .. ") permTimer(" .. timername .. ",nil,86400," .. script .. ")"
end
permTimer(
if not eEnabled then disableTimer(
end,
DoAfter = function (time,command) tempTimer(
DoAfterNote = function (time,message) tempTimer(
sendto = {
world = 0,
command = 1,
output = 2,
status = 3,
notepad = 4,
notepadappend = 5,
logfile = 6,
notepadreplace = 7,
commandqueue = 8,
variable = 9,
execute = 10,
speedwalk = 11,
script = 12,
immediate = 13,
scriptafteromit = 14
},
DoAfterSpecial = function (time,thing,where)
local functable = {
["0"] = send,
["2"] = function (stuff) echo(stuff .. "\n") end,
["10"] = expandAlias,
["12"] = function (stuff) assert(
["14"] = functable["12"]
}
tempTimer(
end,
EnableAlias = function (aliasname,tf) if tf then enableAlias(
OpenBrowser = openUrl,
Hyperlink = function (action, text, hint, fgcolor, bgcolor,url)
--Note - no support for text formating as of right now
if url then action = [[openUrl(]] .. action .. [[)]]
else action = [[expandAlias(]] .. action .. [[)]]
end
echoLink(
end,
string = string,
table = table,
pairs = pairs,
ipairs = ipairs
}
setfenv(1,mushenv)