MU Soapbox

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Muxify
    • Mustard

    Request: Halp!

    MU Code
    15
    29
    12478
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Eerie
      Eerie last edited by

      @Thenomain said:

      Who's a good girl? Who's a good girl? You are!

      I knew it! I knew I was the good girl!

      #squirrel?!

      1 Reply Last reply Reply Quote 1
      • Chime
        Chime @Cobalt last edited by

        @Cobaltasaurus said:

        He will pretty much chat code even when you don't want! Or are unsuspecting of the code!

        Can confirm! ...but it's actually rather nice. I can't always help, but often the sudden popup of zomg random code exuberance really helps make the day better.

        It is by will alone I set my mind in motion. It is by the juice of Coffea arabica that thoughts acquire speed, the table acquires stains, the stains become a warning. It is by will alone I set my mind in motion.

        Thenomain 1 Reply Last reply Reply Quote 1
        • Thenomain
          Thenomain @Chime last edited by Thenomain

          @Chime said:

          @Cobaltasaurus said:

          He will pretty much chat code even when you don't want! Or are unsuspecting of the code!

          Can confirm! ...but it's actually rather nice. I can't always help, but often the sudden popup of zomg random code exuberance really helps make the day better.

          Chime and I having code-sex (i.e., super-nerding about code) on The Reach was some of the best time I've had there.

          I send her things like this:

          Thenomain
          You are, btw, solving issues that Chime's vtable() has taken into account. If you want to look at that code. Just sayin'.

          Melpomene
          digs around on github

          Thenomain
          Beware going mad.

          It's a bit sad for me that Mel figured out the code much faster than I did.

          “If you wish to make an apple pie from scratch, you must first invent the universe.”
          ― Carl Sagan, Cosmos

          M 1 Reply Last reply Reply Quote 0
          • M
            Melpomene @Thenomain last edited by Melpomene

            @Thenomain I don't think it was me figuring it out (I wouldn't know how to make it faster, f'rex) as much as seeing a div() and going "Oh! Arbitrary number of columns!" and then extrapolating. 😉 I am still not what I would consider "up" on the MU*code. Witness the fact that I forgot all about strtrunc and was using mid throughout my code! :facepalm:

            One of these days I will consider myself decent at this stuff. What strikes me as awesome about MUcode is this: it may look like spaghetti, it may be under-documented and a little obtuse... but it's remarkably good at getting the job done. I know of no other language that works with strings as well as MUcode does. (Perl does not count except for its regex abilities, which are murder and ought to be against the Geneva convention.)

            Also, in case that post was confusing for anyone (it could happen, it happened to me!), I am not Chime. 😄

            Chime 1 Reply Last reply Reply Quote 0
            • Chime
              Chime @Melpomene last edited by

              @Melpomene But I liiiiike perl and regexes and things!

              But yes, perl can be horrendous too.

              The only other language I know that treats strings even vaguely like MUSH does would be M4-- the macroprocessor used for sendmail configs and GNU Autoconf and friends. It's a mess.

              vtable() is not a good example of anything, but did what I needed it to at the time. tl;dr it formats a list into some number of columns for the apparent width() of the screen. If the specified columncount is 0 or not present, it looks at the data and uses the most columns it can without truncating elements. The cell borders, padding, and contents are all specifiable and color-safe. iirc, args are ( list, columncount, input delimiter, output separator, padding ).

              Perhaps more interesting are the exposed helper functions; ncol and widthcol. ncol takes ( maxwidth of an element, number of elements); widthcol takes (count), where count is a number of columns. ncol gives you how many columns vtable would use, and widthcol tells you how large the columns will be (which with padding is larger than the input list, maybe).

              Things like the +who I made for the reach use this to dynamically construct internal columns in a vtable with individual width/alignment details that change dynamically depending on screen width.

              ...if I were doing this over, I'd just write a few hardcode functions to format html/css tables for a text screen. They are almost simpler, really.

              It is by will alone I set my mind in motion. It is by the juice of Coffea arabica that thoughts acquire speed, the table acquires stains, the stains become a warning. It is by will alone I set my mind in motion.

              Arkandel M 2 Replies Last reply Reply Quote 0
              • Arkandel
                Arkandel Admin @Chime last edited by

                @Chime said:

                @Melpomene But I liiiiike perl and regexes and things!

                Sometimes you have a problem. You figure you'll use a regex to fix it. Now you have two problems.

                (says someone who uses regexes every day. 🙂 )

                • He who takes offense when not intended is a fool. He who takes offense when intended is a greater fool.
                1 Reply Last reply Reply Quote 1
                • M
                  Melpomene @Chime last edited by

                  @Chime If you ever get around to doing that, gimme. 😄

                  Have you got that vtables function documented anywhere? I would've used it if I'd known you didn't have to specify column widths, but the code I found didn't include documentation and taking apart someone else's code is always a PITA. I just want to know what format it expects things in.

                  I found myself (mostly out of sheer "I CAN code so I WILL code!") making the equivalent of vtables in a different way: it expects a string formatted with two delimiters like so: a|b|c|d~e|f|g~h|i|j|k|l~m|n|o~p|q|r|s|t~u|v|w~x|y|z - and the two delimiters, and it outputs the whole set as a list of columns, fitting them to whatever width is available.

                  Gimme if you've got it, reinventing the wheel is fun but I'm not sure I'm doing the world any good. 😉

                  Chime 1 Reply Last reply Reply Quote 0
                  • Thisnameistaken
                    Thisnameistaken last edited by

                    See, you all are the best reason to learn code. Because it's like watching the Muppets as a child and then re-watching it as an adult. Functions never looked so dirty.

                    Thanks for all the help, everyone. @Thenomain and @GentlemanJack , I'll be hitting you up. And while we're at it, anyone have a good +roll/dice code they want to sacrifice up to the newbie to dissect?

                    1 Reply Last reply Reply Quote 0
                    • Chime
                      Chime @Melpomene last edited by

                      @Melpomene said:

                      @Chime If you ever get around to doing that, gimme. 😄

                      @Thenomain tells me I need to give him a hardcode @whence command first. (tells you where the command you specify is defined, which is rather unexpectedly useful for taking a quick look at whatever bug people are complaining about today...)

                      Have you got that vtables function documented anywhere? I would've used it if I'd known you didn't have to specify column widths, but the code I found didn't include documentation and taking apart someone else's code is always a PITA. I just want to know what format it expects things in.

                      I had it beautifully expanded and documented on WORA. sigh.

                      Really, what you see is what you get.

                      vtable( LIST ) is expected to work for simple cases; the 0-default column count will decide on its own what a sensible column count for the data and screen is.

                      I found myself (mostly out of sheer "I CAN code so I WILL code!") making the equivalent of vtables in a different way: it expects a string formatted with two delimiters like so: a|b|c|d~e|f|g~h|i|j|k|l~m|n|o~p|q|r|s|t~u|v|w~x|y|z - and the two delimiters, and it outputs the whole set as a list of columns, fitting them to whatever width is available.

                      One of the MUSH codebases had a hardcode format function (of some name) that looked much like that. Probably Penn or RHOST.

                      Gimme if you've got it, reinventing the wheel is fun but I'm not sure I'm doing the world any good. 😉

                      If you can use it from what I've explained already, you're welcome to it. If not, well, it's broken and you get to keep both pieces.

                      @Arkandel said:

                      Sometimes you have a problem. You figure you'll use a regex to fix it. Now you have two problems.

                      (says someone who uses regexes every day. 🙂 )

                      They are quick and effective, but for anything of significant complexity, I prefer language that allow easy expression of more complex parsing algorithms. Yes, C/C++ has flex/bison (or lex/yacc if you are truly desperate and your time machine is stuck in the 70s or something). Java has ANTLR, or whatever. Those are effective if you're trying to write a compiler, but tend to be a bit clunky and I've found there is a very large functionality gap between "I'm writing a compiler with multi-file contextual grammar." and "heyyy a few regexes will do fine."

                      The sweet-spot seems to be language that can readily express simpler recursive-descent or similar parsers without having to break into a whole new language (like bison does). Haskell's Parsec and AttoParsec modules do a fantastic job of fitting exactly into that niche-- especially when combined with the applicative functors module. Being able to add recursive grammar for handling string escapes and other important details make for a huge functionality improvement over more primitive systems like regexs.

                      It is by will alone I set my mind in motion. It is by the juice of Coffea arabica that thoughts acquire speed, the table acquires stains, the stains become a warning. It is by will alone I set my mind in motion.

                      1 Reply Last reply Reply Quote 1
                      • 1
                      • 2
                      • 2 / 2
                      • First post
                        Last post