[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Want an alias to repeat a number of commands at a certain time

Want an alias to repeat a number of commands at a certain time

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Xandler   (47 posts)  [Biography] bio
Date Mon 05 Jul 2021 04:59 PM (UTC)
Message
Trying to build something out so my character will do X amount of things at a certain time (ie eat 30 pieces of bread at midnight).

I have adapted the alias found here:

https://www.gammon.com.au/forum/?id=8473

to something similar (just changed the initial repeat symbol)


<aliases>
  <alias
   name="itemrepeat"
   match="^@\s*(\d+) (.*?)$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>-- check at least 1 repeat
if %1 &lt; 1 then
  ColourNote ("white", "red", "Too few repeats specified (%1)")
  return
end -- if

-- check not more than 1000 repeats
if %1 &gt; 1000 then
  ColourNote ("white", "red", "Too many repeats specified (%1)")
  return
end -- if

-- execute (send to command processor) the command
for i = 1, %1 do
  Execute "%2"
end -- for loop</send>
  </alias>
</aliases>


Is there a way to adapt this into doing a set amount of things at a certain time like I stated initially? I figure it would be some sort of timer that's set to At this time instead of every interval, but that's as far as I've gotten. I have no idea how to produce the result I want. Any help would be fantastic!
[Go to top] top

Posted by Nick Gammon   Australia  (22,928 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 05 Jul 2021 10:39 PM (UTC)
Message
Timers can fire at a certain time, so this example shows how a script executes every day at 9:30 AM. You could change that to 23:59, if you wanted it to fire close to midnight.


<timers>
  <timer enabled="y" 
         hour="9" 
         minute="30" 
         second="0.00"
         send_to="12"
         at_time="y" 
   >
  <send>
  
  print ("Timer fired at 9:30 AM")

  </send>
  </timer>
</timers>



Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


My example sends to "Script" but you could send to "Execute" if you want to do thing like aliases which are set up elsewhere.




If you want to make an alias to do this (rather than just making the timer) you can use the addxml module documented here: http://www.gammon.com.au/forum/?id=7123

So now your alias can add a timer (like below) and the thing to send, and the time to send it could be passed into the code below rather than being hard-coded.


require "addxml"
addxml.timer {  name = "mytimer",
                hour = 9,
                minute = 35,

                -- the thing to send
                send = [[

                print ("hi there!")

                ]],
                enabled = true,
                at_time = true,
                send_to = sendto.script,
              }

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xandler   (47 posts)  [Biography] bio
Date Reply #2 on Tue 06 Jul 2021 12:29 AM (UTC)
Message
I understand what you're saying (I don't think it's quite what I'm looking for), long story short, I want the alias to do say @30 eat bread at a certain time (which would process eat bread 30 times), is there a way to adapt that alias into a timed interval so it fires at a certain time of day?
[Go to top] top

Posted by Nick Gammon   Australia  (22,928 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 06 Jul 2021 03:53 AM (UTC)
Message
Well, you do what I said in reply #1, and make it send to "execute" and in that do your other alias to do something 30 times.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


8,349 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]