Skip to content

Mudlet Scripting

edited October 2012 in Scripting
Because I'm a nub who will constantly be asking for coding help while I'm figuring this crap out, I thought I'd go ahead and start this up and make a small contribution of my own. This is the trigger I've created to handle appending the roomnum and area to the room title via GMCP magic. I've used screwy colors for room_title via CONFIG COLOUR on purpose, since I just rehighlight over the room title anyways, to make it so that this doesn't trigger on everything else... like newsroom, quicksand, inventory, etc, like it will if you leave standard colors. There may be a simpler way to handle this, and I'd appreciate input if so, but this works without issue for me at present. Obviously, GMCP required. I use CONFIG COLOUR ROOM_TITLE 5 1 to make this work, though you can use any other unused color combination you would prefer.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.0">
    <TriggerPackage>
        <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="yes" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="yes" isColorTriggerFg="yes" isColorTriggerBg="yes">
            <name>RoomName Trigger</name>
            <script>cecho(&quot;&lt;blue&gt;(&lt;white&gt;&quot; .. gmcp.Room.Info.num .. &quot;&lt;blue&gt;) &lt;DarkGoldenrod&gt;in &quot; .. gmcp.Room.Info.area)</script>
            <triggerType>0</triggerType>
            <conditonLineDelta>0</conditonLineDelta>
            <mStayOpen>0</mStayOpen>
            <mCommand></mCommand>
            <packageName></packageName>
            <mFgColor>#aaaa00</mFgColor>
            <mBgColor>#000000</mBgColor>
            <mSoundFile></mSoundFile>
            <colorTriggerFgColor>#800080</colorTriggerFgColor>
            <colorTriggerBgColor>#800000</colorTriggerBgColor>
            <regexCodeList>
                <string>FG12BG4</string>
            </regexCodeList>
            <regexCodePropertyList>
                <integer>6</integer>
            </regexCodePropertyList>
        </Trigger>
    </TriggerPackage>
</MudletPackage>

Anyone else got something to add?
«13456718

Comments

  • Not sure if you used it or not, doesn't look like it, but there is a code button you can use for posting code. Its the big C up on the top menu bar. Helps with formatting.

  • When I used ZMUD I had a status bar that I could add or take away things like a crit counter, fish counter, kill counter, stuff like that.

    Whats the easiest way to do somethin like this on Mudlet?
  • edited October 2012
    Create consoles with the Vyzor package. You can find the package on the mudlet forums(forums.mudlet.org) you can info on how to do things at the mudlet wiki page.

  • Does anyone have a caravan runner for mudlet?
  • Iluv said:
    Does anyone have a caravan runner for mudlet?
    Lionas posted one on the old forums. I'll add that one in a moment, aliases and triggers will be in separate posts.
  • edited November 2012
    CARAVAN RUNNER ALIASES

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE MudletPackage>
    <MudletPackage version="1.0">
        <AliasPackage>
            <AliasGroup isActive="yes" isFolder="yes">
                <name>Caravans</name>
                <script></script>
                <command></command>
                <regex></regex>
                <Alias isActive="yes" isFolder="no">
                    <name>Caravan go</name>
                    <script>enableTrigger(&quot;caravanpath_impy&quot;)
    caravanpath = {}
    send(&quot;path find &quot;..matches[2])</script>
                    <command></command>
                    <regex>^caravanto (\d+)$</regex>
                </Alias>
                <Alias isActive="yes" isFolder="no">
                    <name>docaravan</name>
                    <script>send(&quot;lead caravan &quot;..caravanpath[1])</script>
                    <command></command>
                    <regex>^docaravan$</regex>
                </Alias>
            </AliasGroup>
        </AliasPackage>
    </MudletPackage>


    Again, I take no credit for this. Lionas coded this, if I remember properly.

  • edited November 2012
    Triggers for the caravan runner are too long in XML, so I'll just leave it like this:

    Trigger: named "caravan"
    Pattern 0 - " ^Path: (.*)$
    Pattern 1 - ^((n|ne|nw|s|se|sw|e|w|u|d|in|out)(,)?( )?)+$
    Script:

    --strip the Path: off it (if present) so the lines are identical

    local pathingstring = string.gsub(matches[1],"Path: ","")

    for token in string.gmatch(pathingstring, "[^,%s]+") do

    table.insert(caravanpath,token)

    end

    --debug print to show that the list is getting populated

    --for i,v in ipairs(caravanpath) do echo (i.." "..v.."\n") end

    if (not (string.byte(pathingstring,-1) == 44 or string.byte(pathingstring,-2) == 44)) then

    onbalance = "lead caravan "..caravanpath[1]

    --disableTrigger(caravanpath_impy)

    end

    Second trigger: named "stepping" -
    Pattern 0 - " ^You lead a caravan \w+\. "
    Script

    table.remove(caravanpath,1)

    if #caravanpath > 0 then

    send("lead caravan "..caravanpath[1])

    end

  • I never did test that thing, does it work?
    I am the righteous one... 
    the claims are stated - it's the world I've created 
  • Works beautifully.
  • edited November 2012
    Alrighty, I have a miniconsole in Mudlet which displays the results of WHO HERE. However, the trigger used to capture that data is also picking up my prompt, and my prompt is thus parsed through the function which displays the table results. I want to somehow remove my prompt data from the table prior to displaying the table, but can't figure out how to do it. Nothing I'm attempting seems to work. Present code is shown below:

    Pattern[exact match]: You see the following people here:

    char.peopleHere = {}

    char.peopleChecking = true

    enableTrigger("People Checking")

    deleteLine()



    Pattern[perl regex]: (.+)

    for name in string.gmatch(matches[2], "[^, ]+") do

    --insert some check to remove prompt data here

    table.insert(char.peopleHere, name)

    end

    deleteLine()


    Pattern[lua function]: isPrompt()


    if (char.peopleChecking) then

    disableTrigger("People Checking")

    char.peopleChecking = false

    for i = 1, 6 do

    table.remove(char.peopleHere, 1)

    end

    whoHereAdd()

    end

    --How do I rid the 'Who Here' console of my prompt? The code below replaces the prompt for me,

    --but does not rid the 'Who Here' console of the prompt data

    --

    --replaceLine("Here be the prompt")



    Script:


    --this function doesn't work, with or without the 'break'.

    --I added them to try, since my only other use of a

    --similar loop successfully used break

    function filterPeopleHere()

    for k, v in ipairs (char.peopleHere) do

    if v == "TIME:" then

    table.remove(char.peopleHere, k)

    break

    end

    if v == "EST" then

    table.remove(char.peopleHere, k)

    break

    end

    end

    end


    function whoHereAdd()

    filterPeopleHere()

    --display function used below is solely for testing to see if anything changes in the table

    display(char.peopleHere)

    whoHereConsole:Clear()

    whoHereConsole:CEcho("<red>PEOPLE HERE\n")

    for k, v in ipairs (char.peopleHere) do

    whoHereConsole:EchoLink( "(" .. v .. ") ", [[expandAlias("st ]]..v..[[") printTargetWindow()]], "Target " .. v, true, false )

    end

    end

  • edited November 2012
    Ok, actually... I've now updated the filterPeopleHere() function, and it works... mostly. My custom prompt line is shown below, for reference:

    H:[*h/*H] M:[*m/*M] E:[*e/*E] W:[*w/*W] <*b*I> XP: *x% TIME: *T EST

    Somehow, I need to filter out these lines from the peopleHere table (unless the trigger can be fixed to not pick the prompt up in the first place?), but I'm not familiar with how to filter out variable strings, like my health and mana and whatnot, so that they don't show up as 'people' in my People Here console.

    Updated filterPeopleHere() function:

    function filterPeopleHere()

    for k, v in ipairs (char.peopleHere) do

    if v == "TIME:" then

    table.remove(char.peopleHere, k)

    end

    if v == "EST" then

    table.remove(char.peopleHere, k)

    end

    if v == "<eb" then

    table.remove(char.peopleHere, k)

    end

    if v == "<eb>" then

    table.remove(char.peopleHere, k)

    end

    if v == "db>" then

    table.remove(char.peopleHere, k)

    end

    if v == "<-b" then

    table.remove(char.peopleHere, k)

    end

    if v == "<e-" then

    table.remove(char.peopleHere, k)

    end

    if v == "<--" then

    table.remove(char.peopleHere, k)

    end

    if v == "pdb>" then

    table.remove(char.peopleHere, k)

    end

    if v == "fdb>" then

    table.remove(char.peopleHere, k)

    end

    if v == "pb>" then

    table.remove(char.peopleHere, k)

    end

    if v == "pd>" then

    table.remove(char.peopleHere, k)

    end

    if v == "b>" then

    table.remove(char.peopleHere, k)

    end

    if v == "d>" then

    table.remove(char.peopleHere, k)

    end

    if v == "XP:" then

    table.remove(char.peopleHere, k)

    end

    end

    end


    "db>" still shows up in the peopleHere table, even though it's supposedly being filtered out by this function, and I'm not sure why.

  • edited November 2012
    I don't recall if there's an easy way to get the full line that's matched (is it in matches[1]?), but if you can do that, just do a test against the pattern you have for the line, and if it matches don't parse the line at all.

    EDIT: You'd probably do the test by testing the return value of string.find on the line. It's been a while since I've written lua, but that sounds right.
    I am the righteous one... 
    the claims are stated - it's the world I've created 
  • As for that caravan runner, you can probably replace the onbalance nonsense with queue eqbal, now that queues exist.
    I am the righteous one... 
    the claims are stated - it's the world I've created 
  • good job
  • yes, matches[1] is how you get the full line.

  • ok im matching multiple lines on a single trigger using the multimatch line delta for 5 lines at once, i've been using deleteLine() to delete certain other lines i have triggers for, but how would i delete all 5 lines at once?
  • There isn't any real easy way...but you can try

    selectString(multimatches[1][1],1) replace("") deselect() selectString(multimatches[2][1],1) replace("") deselect() On multiple line triggers, there is a function like showMultimatches() or something similar to show what is being matched. Multimatches[1][1] would be the whole line of the first matched line in your trigger, multimatches[2][1] would be the whole line of the second matched line in your trigger. Hope this helps.

  • Alright, how would I turn my prompt pattern into a lua pattern for matching?

    H:[*h/*H] M:[*m/*M] E:[*e/*E] W:[*w/*W] <*b*I> XP: *x% TIME: *T EST is the in-game custom prompt line, but I'm not sure how to turn that into a Lua pattern to test against.
  • I am the righteous one... 
    the claims are stated - it's the world I've created 
  • thank you delrayne

  • is it possible to delete lines above a certain line? like let's say i want to delete the 2 lines above \-\-\-\-\-\-\-\-\-\-\-\-\-\- (.+):(.+):(.+) \-\-\-\-\-\-\-\-\-\- the perl regex
  • That is one ugly trigger, but you'll have to look into the selectString() function. Might be called selectLine() I don't really remember. Also, the lack of ease of which you can select certain lines above a trigger to be deleted is the main reason Sani quit using mudlet. Like I said, there isn't any easy way to do it. Just look through the manual a bit and get creative. Also check the other IRE forums as well. That's where I got the last bit of code I gave you.

  • okay, yeah i'm seeing a large problem in my minimap then, because i still have 2 lines that it isn't deleting for some reason, thank you

  • I was wondering if I should just work on creating an offense script for my character or if I should make a curing one too. Not sure how good the ingame curing system is since I am new to the game.
  • The ingame curing is pretty freaking awesome.

    You CAN write a system that's better than it, but it'll be a lot of work.

    "On the battlefield I am a god. I love war. The steel, the smell, the corpses. I wish there were more. On the first day I drove the Northmen back alone at the ford. Alone! On the second I carried the bridge! Me! Yesterday I climbed the Heroes! I love war! I… I wish it wasn’t over."

  • yeah, the in game curing is generally more than enough for anyone.

  • does anyone have any scripts for Mudlet .. Im new to the game and the links I found have rather been set to private or the script/s have been deleted..

    Any help would be appreciated... Thanks in advance
  • What sort of scripts you looking for? the IRE site has some good stuff, as well as the mudlet forums...granted the forums are less game specific and more utility/background work type stuff.

  • yeah I loaded up my other mud game and ripped out some stuff from that, like the mini map widow, tabbed chat etc.. was more of curious as to if anyone had anything that was Imperian related..
  • Any specifics?
Sign In or Register to comment.