Inserting a delay in TinyMUX?

  • OK, so. I half-heartedly remember a function called suspend? Which does not seem to exist. Clearly I was hallucinating that. The only thing I can find is @wait -- but I really would rather make a neat and tidy function without it (or with it at this point, since it doesn't seem to work inside a function the way I'd like it to).

    Target goal: Take a list of messages (or commands, or whatever) and basically run an iter() with them... with a delay tucked in between.

    It'd be possible to do each of these individually on a number of objects with each custom, but I'd really like to try to get it to recognize 'do thing 1, wait X seconds, do thing 2, wait X seconds' for the duration of the list.

    I am code stupid, so I've not had any luck with this save for each of these being a custom attribute with @wait 5=[thing(1)];@wait 10=[thing(2)];@wait 15=[thing(3)] -- and so on. While it can definitely be done this way, something tells me there has to be something that works better than that, and I'm just running into my usual ignorance barrier. I'm having no luck finding it, though.

    Any thoughts? (Other than 'why in the blue hells are you doing that, woman?!') Or is that the only way to really go about it?

  • @surreality Last I checked, you can't wait in functions in Penn. I assume MUX is the same. The only way I know to do this is to use @dolist with @wait.

     @dolist A B C={@wait [mul(5,#@)]=thing(##)}

    That example waits 5 seconds between each item; you can adjust that as desired.

  • Sorry, there's no way to delay function execution. While a function is being evaluated everything else in the MU[SH|X] is halted waiting for it to complete. Despite appearances, MU{SH|X] is actually single-threaded and only one thing is ever done at a time.

    @wait is how you do this: and it works by 'queueing' a command to run at a later point approximately X seconds in the future.

    For this sort of thing you really don't want to do functions: @dolist and @wait are really the tools for the job.

  • That's what it looked like -- many thanks! I was hoping there would be an easier way, but this works.

  • I feel that functions shouldn't be used this way, really. Side-effect functions are the devil. (Watch me be opinionated!) :)

    That said, if you can turn it into something sane (like, say, a command), you might also want to look into semaphores. (The @wait/@notify pairing.) This will let you queue up a bunch of commands for a given object, and then @notify an object to execute the next command in its queue.

  • @Sparks The stuff I want to do can all be done pretty easily with some formatted pemits, so it's totally doable that way, yeah.

    There are probably a LOT of things I do ten kinds of 'not best practice' (since I am clueless) but I'm weirdly fussy about some things. The end result for this one is really just some ambience pemits for areas (which can be turned on or off with a preference since I know that kind of thing is a big love/hate no-middle-ground territory). One of the things I'm doing with them, though, is definitely fussbait of the first order: they're color coded in a way to make clear they're messages from the game itself; it's sort of a comfort-factor thing, so no one thinks there's someone DARK in the room or otherwise sending specific messages. People can pick their own ansi highlight colors, though -- so it needs to check for that to use their proper 'this is what isn't going to make me go blind' color for IC game notifications. (Theno deserves the 100% of the credit for getting that to actually work; I'm just abusing the hell out of it.)

    Since some of the things I want to do with it are the kind of old-school easter egg flavor-bits (like short sequences of a few scheduled messages for a room) it seemed more sane to do one message with a @wait or similar than enter a dozen things on the CRON for one fairly minor effect in random nooks of the grid. (It's a really, really haunted grid. There's a reason the last room down the hall's so cheap, after all... etc.)

  • Run everything on an old server. Not only will all your function calls be delayed, but everything else will too! It'll be just like the 90s, only with better hair and no shoulder pads.

Log in to reply