Mudlet Questions

by Rika

Back to Mechanic's Corner.

Lilia2010-12-26 05:12:03
QUOTE
EDIT: Alright so...If I make an alias for this and want 'defup' to be the alias to execute the script, I put that in the pattern name?

Yes, but to be safe, use ^defup$ ,otherwise, it will expand if you just happen to use defup in a sentence, even if it's part of a word.
Abethor2010-12-26 05:24:49
Okay it worked...but it didn't. When I just had:
send("insomnia")
tempTrigger ( 1, ] )

it sends insomnia on an infinite loop.
Jules2010-12-26 05:35:12
QUOTE (Abethor @ Dec 26 2010, 12:24 AM) <{POST_SNAPBACK}>
Okay it worked...but it didn't. When I just had:
send("insomnia")
tempTrigger ( 1, ] )

it sends insomnia on an infinite loop.


Change tempTrigger to tempTimer?

And for the love of god, remove the extra spaces! You're violating PEP 8.
Abethor2010-12-26 05:37:33
QUOTE (Jules @ Dec 25 2010, 11:35 PM) <{POST_SNAPBACK}>
Change tempTrigger to tempTimer?

And for the love of god, remove the extra spaces! You're violating PEP 8.

That worked! Thanks!

And I like my spaces, coming from Java I'm used to some very spacey code lines.

EDIT: Probably another easy question...is there an echo command? Or something similar?
Neos2010-12-26 06:00:28
QUOTE (Lilia @ Dec 26 2010, 12:00 AM) <{POST_SNAPBACK}>
You would temp triggers for that:
send("defense 1")
tempTrigger( 5, ])
tempTrigger( 10, ])
tempTrigger( 15, ])
tempTrigger( 20, ])

This would send defense 1, wait five seconds, then send defense 2, then five seconds later, send defense 3, etc. The temp triggers are all created at once, so you have to make sure they're spaced out properly. If you put 5 in every one, they'll all fire five seconds after defense 1. This isn't the best solution, but's it worked alright for me until I found demonnic's chaser script. It's able to know what requires/takes balance/equlibrium and what doesn't. If you use it right, your system can do balance and equilibrium things at the same time. I don't know if he's made it available on it's own, but it's part of the influencer he wrote.

I have it as a stand alone, though a lot of names and variables are changed around, since it was pulled from Stygian. It's basically the same code, but changed names and no debugging stuff in it.

QUOTE (Abethor @ Dec 26 2010, 12:37 AM) <{POST_SNAPBACK}>
That worked! Thanks!

And I like my spaces, coming from Java I'm used to some very spacey code lines.

EDIT: Probably another easy question...is there an echo command? Or something similar?

Yes. echo(), cecho(), hecho(), and decho().
My own opinion. Don't quote me.
Echo is for just regular uncolored echos. You can add color, but it'd just be better to use cecho(), hecho(), or decho().
Best place to learn about them is from the manual, then looking at some examples on the mudlet forum, and in a few of the mudlet scripts posted on these forums.
Abethor2010-12-26 06:04:16
QUOTE (AquaNeos @ Dec 26 2010, 12:00 AM) <{POST_SNAPBACK}>
I have it as a stand alone, though a lot of names and variables are changed around, since it was pulled from Stygian. It's basically the same code, but changed names and no debugging stuff in it.


Yes. echo(), cecho(), hecho(), and decho().
My own opinion. Don't quote me.
Echo is for just regular uncolored echos. You can add color, but it'd just be better to use cecho(), hecho(), or decho().
Best place to learn about them is from the manual, then looking at some examples on the mudlet forum, and in a few of the mudlet scripts posted on these forums.

Thanks a bunch. I've meandered through the manual a bit, but I've spent so much time looking at Java code as of late that my eyes bug out on me fairly easily shocked.gif
Unknown2010-12-26 08:29:54
Better to use an array to store such things as whether you wish the defence to re-initialise on loss, whether the specific defence requires/takes bal/eq etc.

You can also use GMCP to track your balances, which makes things much more simple and streamlined.
Unknown2010-12-26 18:58:12
How can I get more variety of colours for my colour echoes, like the ones in m&m? E.g. a dark green as opposed to the bright green that shows. Is there a list somewhere?
Furien2010-12-26 19:13:35
Stick

showColors()

in an alias and execute it.
Unknown2010-12-27 00:02:20
QUOTE (Furien @ Dec 26 2010, 02:13 PM) <{POST_SNAPBACK}>
Stick

showColors()

in an alias and execute it.


I'm amazed by these colours ohmy.gif Way more than expected. Thanks!

Another question - how do I trigger something to fire based on my health/mana/ego? I have the code for how to determine when my health reaches a certain point, but don't know what to put in the trigger line or what the trigger is supposed to look like ...

CODE
if mm.stats.currenthealth <= 1500 then
  expandAlias("do fly")
end
Unknown2010-12-27 08:59:15
QUOTE (Shou @ Dec 27 2010, 12:02 AM) <{POST_SNAPBACK}>
I'm amazed by these colours ohmy.gif Way more than expected. Thanks!

Another question - how do I trigger something to fire based on my health/mana/ego? I have the code for how to determine when my health reaches a certain point, but don't know what to put in the trigger line or what the trigger is supposed to look like ...

CODE
if mm.stats.currenthealth <= 1500 then
  expandAlias("do fly")
end


You do not need to trigger much as the value can be called from the main system API, as per your usage of mm.stats. What I personally do ( assuming your PC is sufficiently fast enough, although this -is- Mudlet smile.gif ) is to simply create a single trigger, the type needs to be set as a Lua Function with the contents on line one being:

CODE
return isPrompt()


Once done, just stick your code in the large box provided.

NOTE: You will need to add in a failsafe if you use this method. A simple variable will suffice.

HTH.
Neos2010-12-27 09:08:57
QUOTE (Draylor @ Dec 27 2010, 03:59 AM) <{POST_SNAPBACK}>
You do not need to trigger much as the value can be called from the main system API, as per your usage of mm.stats. What I personally do ( assuming your PC is sufficiently fast enough, although this -is- Mudlet smile.gif ) is to simply create a single trigger, the type needs to be set as a Lua Function with the contents on line one being:

CODE
return isPrompt()


Once done, just stick your code in the large box provided.

NOTE: You will need to add in a failsafe if you use this method. A simple variable will suffice.

HTH.

Also could just make us of the event provided by m&m which works off the prompt, it's listed in the m&m documents. Put your code in a function, add the event, and make sure you have the necessary checks to make sure it's not firing constantly. Though if you don't understand events you can't make much use of it.
Vadi2010-12-27 10:04:08
It's best to use that event, since the event is guaranteed to come after the stats were updated by m&m - whereas if you do an update, m&m trigger will be below your own prompt trigger, and it'll be firing on old values still there.

Oh, and, new tutorial: events.
Unknown2010-12-27 15:59:41
Putting my own class folders before the m&m one never caused me any problems, though I do use GMCP for such things, so I should have mentioned that too, I guess.
Unknown2010-12-27 16:17:57
I don't really understand events, but I will take a look at that tutorial as it seems the best way to go. Thank you all!
Neos2010-12-27 16:50:01
Because everyone keeps asking for it:
CODE
if (targetHighlight == nil or exists(targetHighlight, "trigger") == 0) and target ~= nil then
  targetHighlight = tempTrigger(target, ] .. target .. ])
elseif exists(targetHighlight, "trigger") == 1 and matches ~= target then
  killTrigger(targetHighlight)
  targetHighlight = tempTrigger(target, ] .. target .. ])
end

Personally when I set my target, it's set differently, for pvp I make sure the persons name is capitalized with
CODE
target = string.title(string.lower(matches))

end just have the regular
CODE
target = matches

for hunting.
Unknown2010-12-27 17:01:36
QUOTE
target = string.title(string.lower(matches))


The string.lower is rather redundant there. Personally opinion, I guess, though I just use string.upper for both instances.
Neos2010-12-27 17:04:51
QUOTE (Draylor @ Dec 27 2010, 12:01 PM) <{POST_SNAPBACK}>
The string.lower is rather redundant there. Personally opinion, I guess, though I just use string.upper for both instances.

I tend to tab complete the name at times, and the first thing it catches is the name in all caps. As long as it achieves what I need it to, I'm good.
Sylphas2010-12-27 17:32:03
Does string.title() do what I think it does? I wonder why I went and made my own function for that...
Neos2010-12-27 17:42:47
QUOTE (Sylphas @ Dec 27 2010, 12:32 PM) <{POST_SNAPBACK}>
Does string.title() do what I think it does? I wonder why I went and made my own function for that...

Capitalizes the word. I believe that's the second time you've made a function of your own, while there was already something there.