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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  some questions about timer and trigger

some questions about timer and trigger

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


Posted by Darmier   (7 posts)  [Biography] bio
Date Mon 26 Sep 2016 12:32 PM (UTC)
Message
Hi, I am a newbie.
I want to know:
1.How many times a trigger scanning in 1 second?
Or maybe I should ask what`s the refresh frequency of a
trigger?
2.Can we make a timer in lua?

3.I want to do: print"hello",wait(sleep,delay) 1 second,print"ok",wait 1 second,print" " ,wait,...... just like this.
who can help me programing in lua?

thank you all.
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Mon 26 Sep 2016 02:50 PM (UTC)
Message
Quote:
1.How many times a trigger scanning in 1 second?
Or maybe I should ask what`s the refresh frequency of a
trigger?

The what?

Quote:
2.Can we make a timer in lua?

https://www.mushclient.com/scripts/function.php?name=DoAfterSpecial

Quote:
3.I want to do: print"hello",wait(sleep,delay) 1 second,print"ok",wait 1 second,print" " ,wait,...... just like this.

https://www.mushclient.com/forum/?id=4956&reply=2#reply2

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Darmier   (7 posts)  [Biography] bio
Date Reply #2 on Mon 26 Sep 2016 07:29 PM (UTC)
Message
Thank you.

1. I think there must be something always keep watch on a trigger, just like event. So I want to konw the refresh rate or refresh frequency or Hz or FPS.

2,3. I am a newbie, so I wish to do that in "pure" lua.

I hope that the maximum granularity of the timers is 0.01 seconds in the next version so I can make a small game in the window.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 26 Sep 2016 08:25 PM (UTC)
Message
See: http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks

In particular: OnPluginTick

This is designed to let you do something frequently (25 times a second). That would let you have a frame rate of 25.


Quote:

1.How many times a trigger scanning in 1 second?


Triggers are called when an incoming line arrives from the MUD. There is no particular "scan" time.

- Nick Gammon

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

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #4 on Mon 26 Sep 2016 09:25 PM (UTC)

Amended on Mon 26 Sep 2016 09:28 PM (UTC) by Fiendish

Message
Darmier said:
2,3. I am a newbie, so I wish to do that in "pure" lua.

As a newbie you should probably use the way suggested by someone who has many years of experience.

Nick Gammon said:
This is designed to let you do something frequently (25 times a second). That would let you have a frame rate of 25.
Optimistically. :)

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Tue 27 Sep 2016 02:51 AM (UTC)
Message
Yes, the advertised rate may not be met, as processing timers is a low priority.

- Nick Gammon

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

Posted by Darmier   (7 posts)  [Biography] bio
Date Reply #6 on Tue 27 Sep 2016 04:59 AM (UTC)
Message
Nick Gammon said:

In particular: OnPluginTick

This is designed to let you do something frequently (25 times a second). That would let you have a frame rate of 25.


Thank you.That is so important and useful to me.

I try to use this function, I can start it, but I don't know how to stop and control it. So I need more help.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Tue 27 Sep 2016 08:48 PM (UTC)
Message
You need to post some code if you want help with why it doesn't work.

- Nick Gammon

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

Posted by Darmier   (7 posts)  [Biography] bio
Date Reply #8 on Wed 28 Sep 2016 03:51 AM (UTC)

Amended on Wed 28 Sep 2016 04:27 AM (UTC) by Nick Gammon

Message

<script>
<![CDATA[
win="win"
WindowCreate(win,0,0,40,40,11,4,0xffffff)
WindowCircleOp (win, miniwin.circle_ellipse, 
                0, 0, 40, 40,                
                ColourNameToRGB("blue"), miniwin.pen_solid, 2, 
                ColourNameToRGB("cyan"), miniwin.brush_solid)
WindowShow(win,true)
x=0
y=GetInfo(280)-40
t=0
g=5
vx=5
vy=55
ty=0
z=3

function OnPluginTick( ... )
  WindowPosition(win,x,y,12,6)
  Redraw()    
  t=t+1
  ty=ty+1
  x=vx*t
  y=GetInfo(280)-40-vy*ty+0.5*g*ty*ty-z
  if y>=GetInfo(280)-40 then ty=0;vy=vy-z end
end
]]>
</script>


I use the code for simulating a ball jumping and jumping, but I don't konw how to stop the function OnPluginTick().

We can use "break" to stop "for" loop or "while" loop, and I want to konw if there is a command or method to stop the function.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Wed 28 Sep 2016 04:30 AM (UTC)
Message
You are looking at this the wrong way around. If a function is designed to be called 25 times a second, you don't stop it doing that.

Look at it this way: If you want to walk the dog every day except Sunday, you don't somehow stop Sunday from coming around. You build in a test:


if today == "Sunday" then
  -- do nothing
else
  WalkTheDog ()
end -- if


So in your case if you don't want the ball to move then don't move it. Build a test into the function.

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


22,437 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]