Author Topic: Simple timeout functionality  (Read 4672 times)

0 Members and 1 Guest are viewing this topic.

Offline BadManiacTopic starter

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Simple timeout functionality
« on: October 18, 2010, 01:31:49 PM »
0
Old EUO:
Code: [Select]
SET %timeout #SCNT2 + 2500
...
IF #SCNT2 > %timeout
  do stuff

How do we achieve the same functionality as simply as possible in OEUO? Least amount of code lines wins!

Code: [Select]
timeout = getticks() + 2500
...
if getticks() > timeout do
  stuff
... BRAINFART, sorry >.<
« Last Edit: October 18, 2010, 01:38:50 PM by BadManiac »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Simple timeout functionality
« Reply #1 on: October 18, 2010, 01:37:32 PM »
0
Checkout my helper subs.  I have second and milliseconds flavors.

http://www.scriptuo.com/index.php?topic=5960.0
« Last Edit: October 18, 2010, 01:43:09 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline BadManiacTopic starter

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Simple timeout functionality
« Reply #2 on: October 18, 2010, 01:45:41 PM »
0
I know TM, but for this purpose they are about as elegant as a donkey in tap dancing shoes.  :P

A function call with object creation and all that just to get that done? Too complex for this simple use. getticks() does what I needed. I'm EXTREMELY anal when it comes to short optimized code, and I suffer BAD from NIH syndrome :(

I'll be abusing your subs for damn sure, maybe even add to them when we get to creating the SUO community library. But for such a simple thing as I was trying to do here, they are way overkill :)

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Simple timeout functionality
« Reply #3 on: October 18, 2010, 02:34:52 PM »
0
I'll give up a bit of complexity for code clarity anyday; especially since we finally have a language we can really do some cool things with such as objects.  I'll probably go overboard with object encapsulation just because WE CAN!!  heh
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline BadManiacTopic starter

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Simple timeout functionality
« Reply #4 on: October 18, 2010, 02:57:07 PM »
0
OOP have no place here. Objects are great for larger things. They make no sense for this and make the code obfuscated and unnecessarily complex. But that's my opinion, I loathe OOP for anything but their intended purpose which is very LARGE projects, where they improve things immensely. They can stay out of my scripting world, thanks.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Simple timeout functionality
« Reply #5 on: October 18, 2010, 07:51:39 PM »
0
And yet I still had fun using it.  ;)

Each to their own.
« Last Edit: October 18, 2010, 07:57:52 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline BadManiacTopic starter

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Simple timeout functionality
« Reply #6 on: October 18, 2010, 09:03:34 PM »
0
I'm sure we'll both have fun. This is honestly a good thing. You'll go class and object encapsulation nuts, and I'll be an old school procedural programmer nazi. Both ways work, and it expands the community's overall knowledge :) Yay for diversity. (obviously  classes suck and you're wrong...)

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Simple timeout functionality
« Reply #7 on: October 18, 2010, 09:24:10 PM »
0
Honestly, I'm just jazzed there's way more programming widgets available to us these days.  Gotta love that!
Please read the ScriptUO site RULES
Come play RIFT with me!

Tags: