ScriptUO

Scripting Resources & Utilities => OEUO => OpenEUO Scripting Chat => Topic started by: BadManiac on October 18, 2010, 01:31:49 PM

Title: Simple timeout functionality
Post by: BadManiac on October 18, 2010, 01:31:49 PM
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 >.<
Title: Re: Simple timeout functionality
Post by: TrailMyx on October 18, 2010, 01:37:32 PM
Checkout my helper subs.  I have second and milliseconds flavors.

http://www.scriptuo.com/index.php?topic=5960.0
Title: Re: Simple timeout functionality
Post by: BadManiac on October 18, 2010, 01:45:41 PM
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 :)
Title: Re: Simple timeout functionality
Post by: TrailMyx on October 18, 2010, 02:34:52 PM
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
Title: Re: Simple timeout functionality
Post by: BadManiac on October 18, 2010, 02:57:07 PM
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.
Title: Re: Simple timeout functionality
Post by: TrailMyx on October 18, 2010, 07:51:39 PM
And yet I still had fun using it.  ;)

Each to their own.
Title: Re: Simple timeout functionality
Post by: BadManiac on October 18, 2010, 09:03:34 PM
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...)
Title: Re: Simple timeout functionality
Post by: TrailMyx on October 18, 2010, 09:24:10 PM
Honestly, I'm just jazzed there's way more programming widgets available to us these days.  Gotta love that!