Best way to run lots of commands

Sivan
Posts: 49
Joined: Tue Jun 23, 2009 3:54 am

Best way to run lots of commands

Post by Sivan »

I have an alias I used to use in zmud, that I would now like to use in Mudlet. It's about 60 commands to load mobs and then teleport them for a quest. What's the best way to do this without spamming myself off?

I tried using an alias but I got disconnected from the mud.

Loading and teleporting one mob looks like this:
send ("qmob load mobname")
tempTimer (.5, [[("send ("c tele mobname")]])

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

Re: Best way to run lots of commands

Post by Vadi »

Lol. You sent too many commands at once and MUDs anti-spam triggered. Impressive, because usually they're high (at least on Achaea its like 100 commands in under a second).

I guess you can create a table with all the mobs you wanna throw, then loop through them all and add tempTimers with an artificial small delay so its not all at once?

Sivan
Posts: 49
Joined: Tue Jun 23, 2009 3:54 am

Re: Best way to run lots of commands

Post by Sivan »

Vadi wrote:Lol. You sent too many commands at once and MUDs anti-spam triggered. Impressive, because usually they're high (at least on Achaea its like 100 commands in under a second).

I guess you can create a table with all the mobs you wanna throw, then loop through them all and add tempTimers with an artificial small delay so its not all at once?
How would I create a table?

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

Re: Best way to run lots of commands

Post by Bounces »

A table is just a special type of variable that holds an unlimited number of other variables and/or values.

You create a table in the same way you create any other variable, by assigning a value to it.

If your list of mobs is static then you can just hard code that...you would define the table as

mobTable = {mob1, mob2, mob3, mob4, ... mobN}

If your list of mobs is variable and you want to define them yourself then you need to build an alias to add mobs to your table using the insertTable function. It would look like this

^addMob (*.)$

table.insert(mobTable, matches[2])
echo(matches[2] .. " added to mobTable!")

Once you build your table you will want to use the ipairs function to iterate through it and extract the values. It would look something like this...

for i,v in ipairs(mobTable) do
tempTimer(1,[[send ("qmob load ".. v)]])
tempTimer (.5, [[(send ("c tele ".. v)]])
end

It will iterate through your table returning each mob incrementally with a wait time of 1 second after you teleport the last one before it sends the command to load the next

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

Re: Best way to run lots of commands

Post by Bounces »

Additional note:

If you go with the variable table route you will probably want to remove values from your mobTable at some point. To do this you need an alias that uses the table.remove() function.

The syntax of that function is table.remove(tableName, keytoremove).

In other words if you current table is

1 goblin
2 hypogriff
3 hag
4 mummy

and you decide that you don't want the hag on there any more then you would call table.remove(mobTable, 3). After it finishes your table becomes

1 goblin
2 hypogriff
3 mummy

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

Re: Best way to run lots of commands

Post by Vadi »

Theres a small error with bounces script, this one is proper:

Code: Select all

for i,v in ipairs(mobTable) do 
tempTimer(i,[[send ("qmob load ".. v)]])
tempTimer (i + .5, [[(send ("c tele ".. v)]])
end

Sivan
Posts: 49
Joined: Tue Jun 23, 2009 3:54 am

Re: Best way to run lots of commands

Post by Sivan »

Vadi suggested I post what I am doing in Zmud, and then that can be translated to how Mudloet would do it. Below is part of the alias I run to load and then teleport the mobs. I run this manually when I can see there are not many mobs of this type out there anymore. There are six more mobs, but this should give you an idea of what I am doing. With an example I should be able to modify this to add the other mobs. I would want this to loop 10 times and then stop.

Thanks, the help is appreciated.

Code: Select all

qmob load natis_snowsquall
#wait 500
c tele snowsquall
qmob load natis_gentlesnowfall
#wait 500
c tele gentle
qmob load natis_ragingsnowstorm
#wait 500
c tele raging
qmob load natis_noreaster
#wait 500
c tele noreaster
qmob load natis_flurry
#wait 500
c tele flurry
qmob load natis_isolatedsnowfall
#wait 500
c tele isolated

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

Re: Best way to run lots of commands

Post by Vadi »

ok, in mudlet we dont use #wait but as explained here, a tempTimer. so a direct translation would be

Code: Select all

send "qmob load natis_snowsquall"
tempTimer(0.5, [[sendAll("c tele snowsquall", "qmob load natis_gentlesnowfall")]])
tempTimer(1.5, [[sendAll("c tele gentle", "qmob load natis_ragingsnowstorm")]])
tempTimer(2.5, [[sendAll("c tele raging", "qmob load natis_noreaster")]])
tempTimer(3.5, [[sendAll("c tele noreaster", "qmob load natis_flurry")]])
[...]
and you get the idea. increase the time by 1s each time, because all code it done *at once*, without the delays. later in the future times will fire and do the stuff they've been told.

Sivan
Posts: 49
Joined: Tue Jun 23, 2009 3:54 am

Re: Best way to run lots of commands

Post by Sivan »

Does that go into an alias? Also, if the code is all sent at once, won't that spam me off again? And how do I loop it to prevent it from spamming me off?

User avatar
Alexander Divine
Posts: 65
Joined: Mon Dec 21, 2009 7:01 pm

Re: Best way to run lots of commands

Post by Alexander Divine »

I guess what I would do is something like

Code: Select all

for i = 1 .. 10000 do
  send("pick nose;eat sausage;deposit 1000 gold spinesreach")
end

Post Reply