Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ General
➜ 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 page
Posted by
| Darmier
(7 posts) 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. | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #1 on Mon 26 Sep 2016 02:50 PM (UTC) |
Message
| |
Posted by
| Darmier
(7 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,121 posts) 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 | Top |
|
Posted by
| Fiendish
USA (2,533 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,121 posts) 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 | Top |
|
Posted by
| Darmier
(7 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,121 posts) 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 | Top |
|
Posted by
| Darmier
(7 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,121 posts) 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 | 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.
25,665 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top