Some help

Post Reply
freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Some help

Post by freon »

Hi everyone,

Freon here and I want to start by saying that I need help. I've really tried to do this myself but I am overwhelmed by the learning curve needed to get some features up and running for Mudlet. I don't know how to write LUA. I do know how some code works as I've dabbled in some html, css, and very little php, but this is very different.

Anyway, there are two things I'm trying to do that I just can't seem to figure out.

First is to create a recognition trigger that appends the character's name to the text.

For example, the mud gives us:
A bright-eyed, smelly goblin is here.

I know the goblin's name is Daisy.

Currently, I'm using this script in the trigger: echo ("(Daisy)")

and it gives me:

A bright-eyed, smelly goblin is here. (Daisy)

How can I get it to give me this:

(Daisy) A bright-eyed, smelly goblin is here.

It also has to work with mud output like this:
While sitting on a desk, a bright-eyed, smelly goblin writes gibberish on a piece of parchment.

Giving me:
While sitting on a desk, (Daisy) a bright-eyed, smelly goblin writes gibberish on a piece of parchment.

The second thing is to configure the mapper. Of which I have no idea where to begin.

If there are any kind souls willing to help a programming dummy out, I would appreciate it very much.

Thanks!

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Some help

Post by Jor'Mox »

So.. the first bit is pretty simple. You need to see where in the line the string you are searching for is, move the cursor to that place, insert the text you want, and then move the cursor back to the end of the line. Here is some example code that shows how to do that, step by step.
Code: [show] | [select all] lua
local pos = selectString(matches[1])
-- matches[1] is the entire matched text from a trigger pattern, and selectString returns the position of the first character of the matched text
moveCursor(pos, getLineNumber())
-- this will move the cursor to the position found with selectString, on the current line (returned by getLineNumber).
insertText("(Daisy) ")
-- this will put "(Daisy) " at the current location of the cursor
moveCursorEnd()
-- this puts the cursor back at the end of the line where it belongs.
Your second request is not nearly so simple. The mapper in Mudlet is not something that simply needs to be configured, but generally must have every single aspect coded in. Even the simplest of map scripts would be fairly substantial, and need a decent level of skill with Lua code and Mudlet code in particular. That said, I have actually created what I call a "generic" mapping script (which is over 1000 lines of code), for which you generally just need to make some basic triggers to capture relevant info from the game, and pass that along to the script. You can find it here: mudlet-mapper-f13/generic-mapping-script-t6105.html
If, like most people, you need some assistance getting the mapper to work for your game, I recommend asking questions on that thread to keep things consolidated in one place.

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Some help

Post by freon »

Thank you! I'll go try these out and see what happens. As for the mapper, I did make an attempt to get it started but got hopelessly lost. I'll probably need an idiot's guide or something.

Anyway, I'll direct my questions there. Meanwhile, thank you for this trigger help as it will take a farily large mental load off of the game I play.

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Some help

Post by freon »

Hi Jor'Mox,

Sorry to be pest but maybe I typed it wrong? The trigger doesn't seem to be working.

This is what I typed in the console:

Code: Select all

local pos = selectString(matches[1])
moveCursor(pos, getLineNumber())
insertText("(Daisy) ")
moveCursorEnd()
Did I goof with any syntax?

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Some help

Post by Vadi »

You can also just copy/paste what was written there. Could you show a screenshot of how you've got it setup?

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Some help

Post by freon »

can't seem to post photos but you can get to it at:

https://photos.app.goo.gl/xaelxpQ0bE5Hg6sl2

Moderator addition: here's the image concerned- new members many not be able to post such things in IIRC:
Screen Shot 2017-10-02 at 3.03.07 PM.png

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Some help

Post by Jor'Mox »

Doh. I had a typo in there, and didn’t notice.

You need selectString(matches[1],1)
The selectString function has to be told which instance of a string to select, and I left it out by accident.

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Some help

Post by freon »

I see. I'll give those a try.

Cheers!

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Some help

Post by Vadi »

Hmm. We could have it assume 1 if left out. Seems alright to do.

Post Reply