Mushclient Questions

by Esano

Back to Mechanic's Corner.

Razenth2010-07-01 19:05:44
###### can be easily used to imbed malicious code. These forums must REALLY REALLY hate it.
Unknown2010-07-01 20:51:40
You can use different languages, mixed-and-matched, in plugins, but you can only use one language in your main world. If you use Treant, that'll be Lua.

Honestly, if you can learn to use Java, you can learn to use Lua. Out of the dozen or so languages I've learned, Lua is by far the easiest I've encountered so far.
Xenthos2010-07-01 21:43:39
QUOTE (Razenth @ Jul 1 2010, 03:05 PM) <{POST_SNAPBACK}>
###### can be easily used to imbed malicious code. These forums must REALLY REALLY hate it.

There was a time when we were getting many posts with java-script in them every day, and I spent much time reporting them 15 minutes after the post (as we are told not to report them immediately). dry.gif
Xavius2010-07-01 22:12:24
QUOTE (TheSponge @ Jul 1 2010, 01:38 PM) <{POST_SNAPBACK}>
Aw crap, I've just got done learning how to do some basic java and Mushclient doesn't have that code selection.

Would I actually have to ditch my entire Treant defense system and find a new browser if I want to use Java coding? (not ######)


Edit: Why the heck do they cutoff J-a-v-a-s-c-r-i-p-t like it's a bad word?!

Java is not a scripting language. You should really stop expecting it to work for you. tongue.gif
Razenth2010-07-01 22:15:06
I doubt any client contains a full Java compiler, though that would be interesting to see.
Ardmore2010-07-02 02:48:19
This isn't a Mush quesiton as much as it is overall Lua.

I'm trying to learn how to manipulate tables, so I'm taking the basics of Treant and fiddling with it in my own world script.

When I get on balance, I call: bals:gain("bal")

Which is:
if not bals then
bals = {
lost = {}
}
end

function bals:gain(name)
if not bals.lost then
return
end

bals.lost = false
end

Every time I call it, I get this error: attempt to index field 'lost' (a function value)

Now I know what the error means, but I don't see a difference between what Treant does and what I do (seeing as it's copy & paste)

If anyone can let me know that'd be sweet.

The full error is actually... LUA: ERROR running script Balance (Trigger5) ERROR::17: attempt to index field 'lost'
(a function value)

I think something's weird, because it used to be
Faymar2010-07-02 08:29:11
You have probably defined a function bals:lost within the bals module. That's what the error says. Treant has bals:lose for when you lose a balance, you might want to use that name.
Ardmore2010-07-02 13:04:23
Misread your post, but that shouldn't be the problem. Even if I do define bals:lost(name), using bals.lost(name) is completely different.

I will give that a try though.
Unknown2010-07-02 13:13:40
Faymar is absolutely right. You can't have a "data" key/value that is later redefined as a function. Essentially the functions defined in a module are just keys in a table, as is the data. You need unique names.
Ardmore2010-07-02 13:27:52
Hm, very strange. Okay, good learning experience I guess. Now I know how Lua sets up functions/tables.

Thanks you two.
Unknown2010-07-02 14:19:50
QUOTE (Ardmore @ Jul 2 2010, 09:27 AM) <{POST_SNAPBACK}>
Hm, very strange. Okay, good learning experience I guess. Now I know how Lua sets up functions/tables.

Thanks you two.


As an interesting aside, absolutely everything in Lua is an entry in a table. Every variable you assign, function you declare, etc. is an entry in the Lua global table, _G .

It actually helped to demystify tables for me a bit when I realized it was all already in a table, so I was already manipulating tables.
Ardmore2010-07-02 15:03:42
I just assumed it would be like C++, which I'm used to, where it would be named the same thing but it could differentiate (sp?) between the two because of the : and . between bals and lost

I would have NEVER figured that out, thanks again guys!
Felicia2010-07-12 19:07:41
Is there a way to turn off (or simply remove) MUSHclient's welcome message?

CODE
Welcome to MUSHclient version 4.51!
Written by Nick Gammon.

Compiled: Mar 13 2010.
Using: Lua 5.1.1, PCRE 8.01, PNG 1.4.0, SQLite3 3.6.22, Zlib 1.2.3

For information and assistance about MUSHclient visit our forum at:
   http://www.gammon.com.au/forum/


I have a dummy world window that I use to display all communication other than SAY, YELL, SHOUT, and EMOTE, and the message is sort of an eyesore until it scrolls up, which can take a while.

Yes, this is OCD in progress.
Unknown2010-07-12 19:17:01
QUOTE (Felicia @ Jul 12 2010, 08:07 PM) <{POST_SNAPBACK}>
Is there a way to turn off (or simply remove) MUSHclient's welcome message?

CODE
Welcome to MUSHclient version 4.51!
Written by Nick Gammon.

Compiled: Mar 13 2010.
Using: Lua 5.1.1, PCRE 8.01, PNG 1.4.0, SQLite3 3.6.22, Zlib 1.2.3

For information and assistance about MUSHclient visit our forum at:
    http://www.gammon.com.au/forum/


I have a dummy world window that I use to display all communication other than SAY, YELL, SHOUT, and EMOTE, and the message is sort of an eyesore until it scrolls up, which can take a while.

Yes, this is OCD in progress.

Use DeleteOutput() once after the window is created.
Unknown2010-07-12 19:25:50
I think the function is DeleteLines(...). You could also use the Miniwindow approach to capturing chat. I adapted one that was posted on the MUSHclient forums so that it preserves the colors and still allows dragging the window and scrolling/resizing it.
Unknown2010-07-12 19:33:00
QUOTE (Zarquan @ Jul 12 2010, 08:25 PM) <{POST_SNAPBACK}>
I think the function is DeleteLines(...). You could also use the Miniwindow approach to capturing chat. I adapted one that was posted on the MUSHclient forums so that it preserves the colors and still allows dragging the window and scrolling/resizing it.

You can use DeleteLines(#) if you want, too. I just figured since she only wanted the initial output gone she could just DeleteOutput() at window creation. Either way works, you just don't specify a number of lines with DeleteOutput(). It's the equivalent of clrscr.
Unknown2010-07-12 19:46:55
Ah, good to know. One of the many functions I didn't know existed because I've never had a need to use it. biggrin.gif
Felicia2010-07-12 20:55:57
Thanks for the help, guys!

Regarding a miniwindow for capturing chat, I might use (or adapt) one eventually when I improve my understanding of how miniwindows work. The dummy world window does everything I need it to for the time being, though: Color preservation, dragging and resizing, indentation of large messages, line spacing to separate individual messages, sound notification upon new activity, font configuration, etc. Still, I realize miniwindows can do all of that and more, so I'll definitely look into it at some point.

(I've been making good headway learning Lua and MUSH, but I've been away from MUDs for about a month, so I've backslid. I'm a bit rusty now... rats.)
Tarken2010-07-13 13:49:04
I've recently started playing Lusternia (have played other ire muds in the past) and am just trying to sort a couple of things out. One thing I'm having a little trouble doing is capturing momentum on the prompt. I'm using a standard regex match that I use just for catching health/mana/etc:
(\\d+)h, (\\d+)m, (\\d+)e, (\\d+)p, (\\d+)en, (\\d+)w(.+)
I Know (.+) is bad practice, but my regex isn't great and I was just throwing something together for quickness purposes. However, obviously momentum isn't constantly on the prompt (as in when its at 0). I was wondering if anyone could give me a few pointers on how to search the character string for momentum? (Would need to do that later anyway for the flags, so I guess this will help with that as well).
Thanks!
Unknown2010-07-13 14:46:25
I have a prompt trigger in Treant (treant_kata.xml) for tracking just momentum. It can be modified to track the other stats, of course, but Treant has a separate trigger that's doing that already. Anyway, here it is for reference:
CODE

     enabled="y"
   group="Treant_Kata"
   keep_evaluating="y"
   match="^\\d+h\\, \\d+\\m\\, \\d+e\\, \\d+p\\, \\d+en\\, \\d+w(?:\\, (\\d+)mo)? .*?\\-(?:\\((?:\\d+ \\- \\w+|Done\\.)\\)\\s*)?$"
   name="prompt_momentum__"
   regexp="y"
   send_to="12"
   sequence="7900"
  >
  if #"%1" > 0 then
  prompt.momentum = tonumber("%1")
else
  prompt.momentum = 0
end

  


(The last part, after the dash, is to make it work with MudBot's mapper module, too.)