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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Timers Reset In Plugin

Timers Reset In Plugin

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


Posted by Sediket   (10 posts)  [Biography] bio
Date Mon 09 May 2022 05:56 PM (UTC)

Amended on Mon 09 May 2022 06:11 PM (UTC) by Sediket

Message
I came across something weird, when using addxml in a plugin it resets all the timers. I don't know if that's suppose to happen or if I'm doing something wrong, here is a plugin that demonstrates this:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, May 09, 2022, 12:36 PM -->
<!-- MuClient version 5.06 -->

<!-- Plugin "test" generated by Plugin Wizard -->

<muclient>
<plugin
   name="test"
   id="ae563a798b323a32a21db226"
   language="Lua"
   date_written="2022-05-09 12:36:21"
   requires="5.06"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

  <script>
    <![CDATA[
require "wait"
require "addxml"	

addxml.timer {  

			name="tank",
			enabled="y",
			minute="20",
			temporary="y",
			send = "var_stop = 1",
			send_to = 12,
		}

addxml.timer {  

			name="dps",
			enabled="y",
			minute="10",
			temporary="y",
			send = "var_stop = 1",
			send_to = 12,
		}


wait.make (function() 
  Note("Time left on timer tank: " .. GetTimerInfo("tank",13))
  Note("Time left on timer dps: " .. GetTimerInfo("dps",13))
  wait.time(4)
  Note("Time left on timer tank: " .. GetTimerInfo("tank",13))
  Note("Time left on timer dps: " .. GetTimerInfo("dps",13))
  wait.time(4)

  addxml.trigger{
    enabled="y",
    name="stop_action_trig",
    match=[[^\/stop$]],
    sequence="90",
    regexp="y",
    one_shot="y",
    send_to='12',
    send="var_action_stop = 1",
  }
  Note("Time left on timer tank: " .. GetTimerInfo("tank",13))
  Note("Time left on timer dps: " .. GetTimerInfo("dps",13))
end)

]]>
  </script>

</muclient>



output:
Time left on timer tank: 1199.9999850523
Time left on timer dps: 599.99952481594
Reinstalled plugin test (ae563a798b323a32a21db226)
Time left on timer tank before addxml: 1195.9744291613
Time left on timer dps before addxml: 595.97398464102
Time left on timer tank after addxml: 1199.9999793945
Time left on timer dps after addxml: 599.99843474943

The last two notes show how the timers were reset after use addxml

edit: This seems to only happen in plugins, for example in the specified external script file under scripts in Configuration this doesn't happen .
[Go to top] top

Posted by Nick Gammon   Australia  (23,006 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 18 May 2022 05:52 AM (UTC)

Amended on Tue 24 May 2022 06:12 AM (UTC) by Nick Gammon

Message
Is there any reason you don't just make the timers once, and then start and stop them? That might work around this issue.

It appears that what you describe is by design (sort of).

The addxml stuff calls a function that is used to load a plugin, except that it loads part of a plugin (ie. a timer in this case).

Then plugin loader then does a "reset all timers" as part of loading so that the timers start in a known way.

A way of working around this would be to use AddTimer and then if necessary follow that by SetTimerOption to set any options that are not directly supported by AddTimer. This does not use the XML loading interface and should not reset other timers.

Template:function=AddTimer AddTimer

The documentation for the AddTimer script function is available online. It is also in the MUSHclient help file.



Template:function=SetTimerOption SetTimerOption

The documentation for the SetTimerOption script function is available online. It is also in the MUSHclient help file.


- 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.


5,221 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]