Mudlet Scripts

by Janalon

Back to Mechanic's Corner.

Janalon2009-08-03 12:39:13
MacBook user-- tried Wine/MushClient and wasn't happy with the results. Recently switched from Nexus to Mudlet... so now I am working without any system outside of my own triggers/aliases. Have no coding experience, so a curing system is a long way off.

Wondering if anyone has already tackled writing or converting scripts for Mudlet.
Rybosh2009-08-24 09:03:52
Put your map in a console window:

functions:

function init()
resolutionX, resolutionY = getMainWindowSize()
createMiniConsole("mapcap", resolutionX-440, 50, 400, 350)
setBackgroundColor("mapcap", 0, 0, 0, 0 )
setMiniConsoleFontSize("mapcap", 8);
end

function mapCapture()
selectString(line, 1)
copy()
appendBuffer("mapcap")
deleteLine();
end

Triggers:

Name: Map start
Regex: v\\d+ +$
Code:
enableTrigger("Map capture")

Name: Map end
Regex: -?\\d+:-?\\d+:-?\\d+
Code:
disableTrigger("Map capture")
mapCapture()

Name: Map capture
Regex: ^.*$
Code:
mapCapture()

Set the last trigger to be disabled. The triggers will enable it for you.

Looks like this:
Rybosh2009-08-24 23:15:57
Building a defence tracking system:

First, build a reset list with the names of all the defences you use:

function def_reset()
def = {}
def.weathering = 0
def.vitality = 0
def = 0
def.thirdeye = 0
def.nightsight = 0
def.deathsense = 0
def.insomnia = 0
def.selfishness = 0
def = 0
def = 0
def = 0
def = 0
def = 0
def = 0
def.resistance = 0
def = 0
def.constitution = 0
def.adrenaline = 0
def.flex = 0
def = 0
def = 0
end

Clearly mine is a work in progress, I don't have the elixers, herbs etc up there yet.

Next build the infrastructure:

function def_on(d)
if def == nil then
fg("red")
echo("Error: Incorrect defence variable assigned to above trigger.")
else def = 1 end
end

function def_off(d)
if def == nil then
fg("red")
echo("Error: Incorrect defence variable assigned to above trigger.")
else def = 0 end
end

function def_def(d)
def_on(d)
end

function list_defs()
local i
i = 0
fg("red")
bg("black")
echo("\\nCurrent Defs: ")
fg("white")
for k, v in pairs(def) do
if v == 1 then
if i == 0 then echo(k) else echo(", " .. k) end
i = 1
end
end
if i == 1 then echo(".") end
i = 0
fg("blue")
bg("black")
echo("\\nMissing Defs: ")
fg("white")
for k, v in pairs(def) do
if v == 0 then
if i == 0 then echo(k) else echo(", " .. k) end
i = 1
end
end
if i == 1 then echo(".") end
end

Using the above, you can set triggers to do -
def_on("defname") to tell your client that you have the def "defname" set to on
def_off("defname") to tell your client that you have the def "defname" set to off
def_def("defname") to tell your client that you have the def "defname" set to on, and that the information was recovered from the DEF command. This is a little bit of indirection in case you want to expand the system later.

Now you need to do is setup the triggers to each of the ON and DEF phrases for each def. I.e. for weathering

Begin of line substring: A brief shiver runs through your body.
Code: def_on("weathering")

Begin of line substring: Your body is weathering the storm of life a little better.
Code: def_def("weathering")

Lastly, setup this alias:

Alias name: defs
Pattern: ^defs$
Code: list_defs()

This will make you a list of what defs you have on, and are missing.

Janalon2009-08-25 18:14:48
QUOTE (Rybosh @ Aug 24 2009, 05:03 AM) <{POST_SNAPBACK}>
Put your map in a console window:

functions:

function init()
resolutionX, resolutionY = getMainWindowSize()
createMiniConsole("mapcap", resolutionX-440, 50, 400, 350)
setBackgroundColor("mapcap", 0, 0, 0, 0 )
setMiniConsoleFontSize("mapcap", 8);
end

function mapCapture()
selectString(line, 1)
copy()
appendBuffer("mapcap")
deleteLine();
end

Triggers:

Regex: v\\d+ +$
Code:
enableTrigger("Map capture")

Regex: -?\\d+:-?\\d+:-?\\d+
Code:
disableTrigger("Map capture")
mapCapture()

Regex: ^.*$
Code:
mapCapture()

Set the last trigger to be disabled. The triggers will enable it for you.


Hrm. Doesn't seem to work for me, even given not enabling that last trigger. Just to check, should the function be put into a script?

EDIT: On a sidenote, it seemed to affect READLOG in not being able to display... at all!
Rybosh2009-08-25 22:00:22
Functions go into scripts, yep. You can chuck the whole functions section into one script object.

No wonder, I forgot the names on the triggers!

The first trigger is named Map start
The second trigger is named Map end
The third is named Map capture <--- this bit is important

I'll update it in the original post.
Unknown2009-08-29 03:47:59
Script:
CODE
nexusPower={}
nexusPower.amt=0
nexusPower.targetamt=0
nexusPower.nexus="ravenwood"

function powerChannel(arg)

if arg ~= nil then

nexusPower.targetamt = arg
nexusPower.amt = 0
fg("lawn_green")
echo("\\nLinking with nexus: " .. nexusPower.nexus .. " with a target of " .. nexusPower.targetamt .. " surges.\\n")
enableTrigger("Auto Unlink Nexus")
sendr("link " .. nexusPower.nexus)

else

nexusPower.amt = nexusPower.amt + 1
fg("lawn_green")
echo("\\nHave channelled " .. nexusPower.amt .. " of " .. nexusPower.targetamt .. " from the nexus.")

if nexusPower.amt >= nexusPower.targetamt then
disableTrigger("Auto Unlink Nexus")
fg("lawn_green")
echo("\\nTarget of " .. nexusPower.targetamt .. " reached. Unlinking from nexus: " .. nexusPower.nexus .. "\\n")
sendr("unlink " .. nexusPower.nexus)

end

end
resetFormat()

end

CODE
Trigger Name: Auto Unlink Nexus
Exact Match Pattern: You channel energy from your link with the Master Ravenwood Tree.
Script:
powerChannel()
-- Change the pattern to match your city/commune

Alias Name: Nexus link
Pattern: ^nlink (\\d+)$
Script:
powerChannel(tonumber(matches))

Usage:
nlink 20
It will link until 20% has been added to your reserves. Not a difficult script, but handy. Easy enough to adapt it to harvesting/crafting etc as well.


Note:
My scripts require the following function, though the alternative is to replace all instances of "sendr" with "send".

CODE
-- Send alternative with command echo option --
commandEcho=0
function sendr(line)
    send(line)
    if commandEcho==1 then echo( "{" .. line .. "}\\n" ) end
end

There is also an alias that changes the values of commandEcho between 0 and 1
I originally added this function when Mudlet didn't echo commands send with send(). I use it for debugging scripts etc. Even though there is an option in preferences to show commands sent, I still prefer to use sendr() because I can toggle it on/off from the command line. Easier/quicker. Plus, I prefer the way this function displays the echo.
Mezz2011-02-17 21:07:01
anyone know how to make a window where I can keep "info here" updated?
Calixa2011-02-17 23:27:26
Duuuudeee, necro much! Ask here. As for IH, you will want to create a miniconsole, capture the IH output and direct it to there. My two cents are that you should bind who here / ih to numpad 5 so you can spam it while walking about.