Feature request: Multi-Line Send

Brinson
Posts: 15
Joined: Wed Nov 25, 2009 5:19 am

Feature request: Multi-Line Send

Post by Brinson »

I come from Kildclient, a linux client. It has a feature that opens a box. You paste your paragraph in, can choose a prefix (say, tell X), and then choose # of lines and Seconds. If you choose 5 lines and 10 seconds, it sends 5 lines every 10 seconds until the message is complete.

This a neat feature for pre-planned RP like stories and songs.

Bounces
Posts: 18
Joined: Sat Dec 26, 2009 5:44 am

Re: Feature request: Multi-Line Send

Post by Bounces »

This problem is interesting to me and as I have not yet done any real scripting with Mudlet and Lua I think I might try it on...especially since no one else has stepped up to look into it in the month since it's been posted.

I will try to put a package together that satisfies this request. Since I have never done anything like it I make no promises on development time...but I will work on it.

Based on what you have said seems like I need
1) a miniconsole to accept the paragraph
2) a temptimer to tick off an user-defined amount of time until the next send
3) several for loops

Seems simple enough...maybe.

I hope I am not getting in over my head. :|

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

Re: Feature request: Multi-Line Send

Post by Vadi »

That'd be nice but miniConsoles don't accept input. Only the input line does :)

It could require some c++ coding into mudlet to add. Doesn't sound too bad, but not top priority atm.

Bounces
Posts: 18
Joined: Sat Dec 26, 2009 5:44 am

Re: Feature request: Multi-Line Send

Post by Bounces »

The backend part of it seems easy enough...I just need to create a table of commands that I want to send and then have those commands spit out on the timer...

It's the input that is giving me trouble...in my thought excercises...I have not put any script down yet...

Could I have the input saved to a text file that the script reads in? It accepts input that way as well right?

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

Re: Feature request: Multi-Line Send

Post by Vadi »

You can read a text file from Mudlet, yes. Rather easy with io.lines or such, see google

Bounces
Posts: 18
Joined: Sat Dec 26, 2009 5:44 am

Re: Feature request: Multi-Line Send

Post by Bounces »

So I think I am almost there, but I am getting an error from the Debugger, and I am not sure what it means...

Help maybe?

Here is the run down. I have built aliases that call each of the functions listed below...

Code: Select all

function mlAddCommands(text)
	table.insert(t,text)
end

function mlSendCommand()
	for i,v in ipairs(t) do send(v .. "\n") end
	t = {}
	printTable(t)
end

function mlEchoCommand()
	printTable(t)
	for i,v in ipairs(t) do echo(v .. "\n") end
	t = {}
	printTable(t)
end

function mlInsertCommand(keyvalue, text)
	printTable(t)
	table.insert(t, keyvalue, text)
	echo("Value added! \n")
	printTable(t)
end

function mlRemoveCommand(keyvalue)
	printTable(t)
	table.remove(t, keyvalue)
	echo("Value removed! \n")
	printTable(t)
end

function mlSendCommand(filePath)
	t = {}
	for line in io.lines(filePath) do
		mlAddCommands(line)
	end
	printTable(t)
	mlSendCommand()
end

function mlEchoCommand(filePath)
	t={}
	for line in io.lines(filePath) do
		mlAddCommands(line)
	end
	printTable(t)
	mlEchoCommand()
end
	
Now...assume t is a table already initiated, because I have done so already, and excuse the sloppy coding in some places, It has grown organically, so there may be some things that aren't needed, like all the printTable()s which are essentially just helping me debug.

So the idea is the package can be used two ways, build the table from the command line with mlAddCommand and mlRemoveCommand, or pass in a text file with the the text that I want for the table...like this one...

Code: Select all

Filename: c:\demo.txt

say this is line 1 of my multiline send
say this is line 2 of my multiline send
say this is line 3 of my multiline send
say this is line 4 of my multiline send
say this is line 5 of my multiline send
say this is line 6 of my multiline send
say this is line 7 of my multiline send
say this is line 8 of my multiline send
say this is line 9 of my multiline send
say this is line 10 of my multiline send
say I am done now

The command line method seems to work fine, but when I use mlEchoCommand(c:\demo.txt) or mlSendCommand(c:\demo.txt) I get this error for the debugger...

Code: Select all

me=mlEchowithFile(^mlEcho (.*)$) matched.
Alias: capture group #1 = <mlEcho c:\demo.txt>
Alias: capture group #2 = <c:\demo.txt>
LUA: ERROR running script mlEchowithFile (Alias8) ERROR:Lua error:[string "function 
mlAddCommands(text)..."]:43: bad argument #1 to 'lines' (FILE* expected, got nil)

Alias name=mlSendwithFile(^mlSend (.*)$) matched.
Alias: capture group #1 = <mlSend c:\demo.txt>
Alias: capture group #2 = <c:\demo.txt>
LUA: ERROR running script mlSendwithFile (Alias7) ERROR:Lua error:[string "function 
mlAddCommands(text)..."]:34: bad argument #1 to 'lines' (FILE* expected, got nil)
Thoughts?

Thanks for the help!

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

Re: Feature request: Multi-Line Send

Post by Vadi »

You're using io.lines a bit wrong. You open a file first, then you give it to io.lines to work on.

See http://lua-users.org/wiki/IoLibraryTutorial

Bounces
Posts: 18
Joined: Sat Dec 26, 2009 5:44 am

Re: Feature request: Multi-Line Send

Post by Bounces »

The wiki says io.lines opens the file by itself...
io.lines ([filename])

Opens the given file name in read mode and returns an iterator function that, each time it is called, returns a new line from the file. Therefore, the construction

for line in io.lines(filename) do ... end

will iterate over all lines of the file. When the iterator function detects the end of file, it closes the file and returns nil (to finish the loop).
I will try doing a seperate open command when I get home from church later today and return and report...maybe the wiki is wrong...

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

Re: Feature request: Multi-Line Send

Post by Vadi »

Oh. Well, it says the same in the reference manual and it did work for me. Guess it's something else :|

Scolius
Posts: 10
Joined: Mon Apr 30, 2018 7:24 am

Re: Feature request: Multi-Line Send

Post by Scolius »

Anyone know the end result of this? Did it get made? I was looking for something else and saw this and would love to use it if it was implemented.

Post Reply