Converting two aliases from tintin

Post Reply
daemoen
Posts: 7
Joined: Wed Jul 14, 2010 8:09 pm

Converting two aliases from tintin

Post by daemoen »

Hey guys,
Having a few issues with writing a nice little exp bot/script that I use on one of the muds I play.

I have it working just fine in tintin for now, figured I would see if anyone could help with these two conversions so I can use mudlet full time.



#ALIAS {expcycle}={medichi;#delay {20} {medichi; #delay {20} {picket; #delay {20} {plague; #delay {20} {plague; #delay {20} {plague; #delay {20} {plague; #delay {20}
{heal} } } } } } }} @ {5}

#ALIAS {heal}={recall;sleep;#delay {60} {wake;expcycle}} @ {5}

the format in tt is {aliasname} {commands} {priority}. Priority is useless in this case and can be ignored.

Would be of great help. I had tried to replace the delays with tempTimer, but seems they cannot be nested.

I had attempted the following:

Alias Name: Heal
Pattern: ^heal$
sendAll("recall", "sleep")
tempTimer( 30.0, [[ send("wake") ]] )

Alias Name: Expcycle
Pattern: ^expcycle$
echo("Testing the heal aliases recursion")

I had tested using the following tempTimer in heal:
tempTimer( 30.0, [[ send("wake"), expandAlias("expcycle" ]] )

But this failed to call expcycle as best as I can tell.
Any assistance/info would be appreciated.

Also worth mentioning is that medichi, picket, and plague are also aliases.

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: Converting two aliases from tintin

Post by Yetzederixx »

tempTimer( 30.0, [[ send("wake"), expandAlias("expcycle" ]] )
Code: [show] | [select all] lua
tempTimer(30, [[ send("wake"); expandAlias("expcycle") ]])
-- your syntax was wrong here

daemoen
Posts: 7
Joined: Wed Jul 14, 2010 8:09 pm

Re: Converting two aliases from tintin

Post by daemoen »

ok, good to know.

Any idea on how to embed the tempTimer inside a tempTimer as I need to do for the expcycle alias?

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: Converting two aliases from tintin

Post by Yetzederixx »

I'd imagine that you would just nest them. There was a post somewhere about nesting multi-line quotes though, basically you have to have matching equal signs within the brackets (ie: 0 [[ ]], 1 [=[ ]=], 2 [==[ ]==], etc)
Code: [show] | [select all] lua
-- this worked when I tested it in Mudlet
tempTimer(10, [[ send("inv"); tempTimer(10, [=[ send("score") ]=]) ]])

daemoen
Posts: 7
Joined: Wed Jul 14, 2010 8:09 pm

Re: Converting two aliases from tintin

Post by daemoen »

ok, perfect. Thanks

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: Converting two aliases from tintin

Post by Iocun »

I wouldn't personally nest them. It makes things look very messy very quickly and easily leads to errors that are hard to find.

Why don't you do something like this instead:
FIRST COMMAND
tempTimer(20, [[SECOND COMMAND]])
tempTimer(40, [[THIRD COMMAND]])
tempTimer(60, [[FOURTH COMMAND]])

This will also space your commands with 20 second intervals between them, but doesn't require any nesting.

Alternatively, as a slightly "advanced option", create some function that executes the next command in the chain, then calls itself recursively with a 20 second timer:
Code: [show] | [select all] lua
local commandlist = {"first command", "second command", "third command"}

nextcommand = function()
	send(commandlist[1])
	table.remove(commandlist, 1)
	if #commandlist>0 then
		tempTimer(20, [[nextcommand()]])
	end
end

nextcommand()
That solution may seem a bit contrived and unnecessary for just a small script, but would be useful if you had to chain a very large sequence of commands. The advantage of this is that you can at any time easily edit your commandlist (insert a new command somewhere inbetween, remove some commands, change some commands around) without having to worry about the timing issues etc.


Last but not least:
I strongly advise against the use of expandAlias(). Instead of calling the alias expcycle via expandAlias, create a function called expcycle that contains all the commands and then simply use expcycle() to call it. This practice may be more foreign to you if you come from certain other clients (I'm sadly unfamiliar with tintin) where it's normal to call aliases from within script, but it's a bad coding practice here, and you can avoid several problems by learning to use functions as early as possible.

Post Reply