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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  MUSHclient version 4?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: MUSHclient version 4?
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  3  4  5  

Posted by Larkin   (278 posts)  [Biography] bio
Date Sat 09 Jul 2005 02:45 AM (UTC)  quote  ]
Message
Thank you, Flannel! That's exactly what I'll do then. I can easily convert my gettimeofday function into a DLL to extend Lua and have some fun with it.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Fri 08 Jul 2005 07:14 PM (UTC)  quote  ]
Message
Javascript and Perl can currently get milliseconds, you can currently extend Lua to do the same, via C.

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4915

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Fri 08 Jul 2005 01:30 PM (UTC)  quote  ]
Message
I'm not talking about timers. I want to grab the system time, including the current milliseconds, so I can time certain events between prompts. As all of the date/time functions are currently coded, I can only go down to the resolution of seconds.
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Fri 08 Jul 2005 10:24 AM (UTC)  quote  ]
Message
Hmm, why would you want to do that? And wouldn't MC have to check all the timers each millisecond to see if they should fire or not, thus making it quite slow?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Fri 08 Jul 2005 01:30 AM (UTC)  quote  ]
Message
I was looking for a way to get the system time down to the millisecond (similar to gettimeofday on Linux, perhaps), but I have not yet found a way to do this either in Lua or in MUSHclient. I have C code for a gettimeofday function, and I might be able to wedge it into Lua, if I can figure out the interface. If you'd like to include the capability to get time down the millisecond resolution in version 4, I'd be more than happy to share my function for grabbing the seconds/milliseconds time.
[Go to top] top

Posted by Gore   (207 posts)  [Biography] bio
Date Mon 27 Dec 2004 10:05 PM (UTC)  quote  ]
Message
Thanks a lot Nick :)
[Go to top] top

Posted by Nick Gammon   Australia  (19,190 posts)  [Biography] bio   Forum Administrator
Date Wed 22 Dec 2004 04:43 AM (UTC)  quote  ]
Message
Quote:

Doh, is there anychance of deci/centi/millisecond interval timers being implemented in version 4?


Regardless of your problem above, and whether or not the timers will solve it, I have indeed been working on sub-second timers in version 3.61. A bit more testing and I can release it for you to play with.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (19,190 posts)  [Biography] bio   Forum Administrator
Date Wed 22 Dec 2004 04:41 AM (UTC)  quote  ]
Message

2705h, 3290m ex-
You may eat another plant.
2705h, 3290m ex-
You have recovered balance on all limbs.
2705h, 3290m ex-


Why don't you turn on the "I have eaten" flag when you send "eat herb"? After all, you know you have just done it.

So you could do something like this:


if not just_eaten then
  Send "eat herb"
  just_eaten = true
end -- if


I suppose the problem here is that if you get two triggers in quick succession you might clear the flag twice. Well, you can find when a trigger matched (with GetTriggerInfo).

Now it doesn't matter how quickly the messages arrive, you instantly set a flag the moment you eat. So, if the second trigger fires it doesn't eat again.

You could also store the time you just ate (when sending "eat herb"). Then you don't clear the "just eaten" flag until a trigger arrives at least a second or two afterwards.

- Nick Gammon

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

Posted by Gore   (207 posts)  [Biography] bio
Date Mon 20 Dec 2004 11:26 PM (UTC)  quote  ]

Amended on Wed 22 Dec 2004 04:32 AM (UTC) by Nick Gammon

Message
Doh, sorry about my previous post on this thread.

Basically I don't say


dim herbbalance

Sub Eat_herb (a,b,c)
  World.Send "eat herb"
  herbbalance = 0
End Sub

I do:

dim herbbalance           ' Variable

Sub herbbalance_on (a,b,c) ' Sub to turn herbbalance on
  herbbalance = 1
End Sub

Sub herbbalance_off (a,b,c) ' Sub to turn herbbalance off
  herbbalance = 0           ' Called on the trigger:
End Sub                     ' ^You have eaten an herb\.$

Sub Eat_herb (a,b,c)        ' Sub to eat an herb
  If herbbalance = 1 then
    World.Send "eat herb"
  End If
End Sub


That's how it do it currently, and er, to simplify (not exactly how I do it, but for simplicity's sake) things I call eat_herb on balance/eq/etc.

So, if I get balance and eq simultaneously, I do eat_herb twice, and I overeat.

Now, if there were millisecond interval timers, I could do..


<timers>
  <timer name="anti_double_eat" script="imaginary_herbbalance_on" second=".3" >
  </timer>
</timers>

dim herbbalance           ' Variable
dim fake_herbbalance

Sub herbbalance_on (a,b,c) ' Sub to turn herbbalance on
  herbbalance = 1
End Sub

Sub herbbalance_off (a,b,c) ' Sub to turn herbbalance off
  herbbalance = 0           ' Called on the trigger:
End Sub                     ' ^You have eaten an herb\.$

Sub imaginary_herbbalance_on (a,b,c)
  fake_herbbalance = 1
End Sub

Sub Eat_herb (a,b,c)        ' Sub to eat an herb
  If fake_herbbalance = 1 AND herbbalance = 1 then
    World.Send "eat herb"
    fake_herbbalance = 0
    World.EnableTimer "anti_double_eat", 1
  End If
End Sub



If I did it that way, then the fake balance variable would be turned to false, then be turned on 300 milliseconds later, enough so that I don't double eat on the chance that I call this sub twice.
[Go to top] top

Posted by Nick Gammon   Australia  (19,190 posts)  [Biography] bio   Forum Administrator
Date Sun 19 Dec 2004 10:36 PM (UTC)  quote  ]
Message
Anyway, before I get bogged down with sub-second timers, I have released version 3.60, which has gone from a few minor updates to 22 enhancements.

So, not quite ready to rebadge as version 4 yet.

Interestingly, one of the fixes was a fix to a previous improvement. Just shows how it is hard to get these things perfect.

In 3.57 I added a change to the notepad windows, on request, so that the title of the window would be offered when you saved it. Seemed a simple idea. However in the wisdom of the Windows programmers, certain characters in a document title stop it from saving. It is not as if you get the dialog box, and have to change a few things, you don't even get that.

It is this sort of thing that makes me grind my teeth when using Windows. I have an Access database that does that. One of the forms, a while ago I changed it, and now when I use it, it says "you have changed it, do you want to save the changes?". I say "yes". Then I close it. It says "you have changed it, do you want to save the changes?". I say "yes". And so on. Eventually I close it without saving the changes. Kind of annoying.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (19,190 posts)  [Biography] bio   Forum Administrator
Date Sun 19 Dec 2004 10:20 PM (UTC)  quote  ]
Message
I don't quite understand that bit. Where do timers come into this example?

To save double eating can't you just store the fact that you have eaten something in a variable, and clear it when an appropriate message arrives?

- Nick Gammon

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

Posted by Gore   (207 posts)  [Biography] bio
Date Sun 19 Dec 2004 10:00 PM (UTC)  quote  ]
Message
well, there's built in variables that has the number of seconds (or milliseconds rather) from midnight, so you could time things in milliseconds using that

But - you can't do XXX.. wait 300 milliseconds then do XXX..

Like, say, you have a trigger that does

Sub Eat_Herb (a,b,c)
  if herbbalance = 1 then
    World.Send "eat herb"
  end if
End Sub

and this sub fires on "You have recovered balance" & "You may eat another plant"

So, you don't want to double eat and you get the following output:

2705h, 3290m ex-
You may eat another plant.
2705h, 3290m ex-
You have recovered balance on all limbs.
2705h, 3290m ex-

then you'd double eat.. with a millisecond timer I wouldn't have to worry about that sort of thing.
[Go to top] top

Posted by Nick Gammon   Australia  (19,190 posts)  [Biography] bio   Forum Administrator
Date Sun 19 Dec 2004 07:44 PM (UTC)  quote  ]
Message
I was toying with the idea of timer of less than a second. I suppose everyone's keen? Trouble is the various interfaces that assume a second granularity, but it can probably be worked around.

- Nick Gammon

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

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Sun 19 Dec 2004 06:52 PM (UTC)  quote  ]
Message
You can probably do smaller timers in Lua.

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4956&page=999999

Actually... I dont know. The Lua manual only talks about seconds. But if you could get the OS to return time in windows (which is the number of milliseconds since 1970 or whatever) then you should be able to do it.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Gore   (207 posts)  [Biography] bio
Date Sun 19 Dec 2004 05:15 PM (UTC)  quote  ]
Message
Doh, is there anychance of deci/centi/millisecond interval timers being implemented in version 4?

And the tabbed windows look wicked good, thanks Nick :D
[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.


18,840 views.

This is page 1, subject is 5 pages long: 1 2  3  4  5  [Next page]

[New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]