No announcement yet.

More questions (I guess they won't stop)

  • Filter
  • Time
  • Show
Clear All
new posts

  • More questions (I guess they won't stop)

    So, one thing I could never figure out how to do is centerprint with text and a variable in the same line. For example, in the game I'm making, its important for the player to know the time when he touches the exit. It should say "Time is: 5.231," however I can't do this. I can either just put text or just put a variable, as every time you do a centerprint it replaces the other.

    I've seen people do it in their mods, and I'm pretty sure you do it with an SVC. How can I do that?

  • #2
    /n will create a line-break to a center-print
    are you curious about what all there is out there in terms of HD content for quake?
    > then make sure to check out my 'definitive' HD replacement content thread! <
    everything that is out there for quake and both mission-packs, compiled into one massive thread


    • #3
      Unlike sprint, the centerprint messages do not stack up on the screen. The latest one simply over-rides the previous one. So entering a string (i.e. "time is: " ) followed by a float (the game time stored as a string using the function ftos) cannot be done on the same line, because it would require 2 inputs to the centerprint function, instead of the one it allows.

      What you can do, however, is redefine centerprint. Look in defs.qc near the bottom. I believe centerprint is engine function #73 (or somewhere around there). Just below centerprint, add another function:

      multi_centerprint(entity e, string A, string B, string C, string D) = #73

      You can add as many string fields as needed I believe. Then simply call on this new function when needed. It would look like this:

      multi_centerprint(other, "Time is: ", t, "/n", "/n");

      where t is a local string of the gametime stored through ftos().

      EDIT: for a better example than just my memory, look at the source code in FrikBot, or AD. FrikBot uses it for it's waypoint editor menu, and AD uses it for key inventory.
      'Replacement Player Models' Project


      • #4
        You can redefine the arguments of a built in? Really?

        That sounds terrible.

        Why can't he just concat the string together and put that in centerprint?

        msg = "time is: " + ftos(time());


        • #5
          I don't think AD's key inventory update has been released yet. Sock has said he would put it in the forthcoming final 1.6 release.
          ♪ I'm skiiiiiiinnin' in the pain, just skiiiiiiinnin' in the pain ♪
          ♪ What a glorious feelin' I'm haaaaaaappy again ♪


          • #6
            @Gypsy I can do that? damn, never knew. I'll try it out.

            Edit: It doesn't work.
            Last edited by SpecialBomb; 07-23-2017, 04:33 PM.


            • #7
              @SB ~ Many, many languages support string concatenation via the plus sign. Honestly, I was unsure if QC did. It was a shot in the dark. Sorry it didn't work.


              • #8
                Here's another idea that probably isn't going to work. FTEQCC supports arrays....maybe it also supports some basic array functions.

                someArray = ["Time is:", ftos(time())]
                msg = someArray.join(" ");

                For the record, due to some research I did earlier, it seems Dutch's way is the actual way. I just threw out the above cause maybe it will work. I'm not very confident it will cause I don't ever recall seeing push(), pop(), shift(), unshift() or join() in any QC. Those are real array functions that are supported by numerous languages though.


                • #9

                  Yeah it seems pretty hacky to me. I honestly have no idea what the engine does internally to a redefined function. Maybe I'll poke around the engine code sometime this week. Really, the only familiarity I have is the HUD graphics.



                  as a side note, QC will eat you alive. Have you ever heard the saying "you can't make a silk purse out a sow's ear?" If you're trying to do anything beyond what quake originally did with QC, the saying applies. After close to 20 years, people have found interesting ways to "hack" their ideas into QC, but eventually you're going to be left wanting more.
                  Last edited by Dutch; 07-23-2017, 07:48 PM.
                  'Replacement Player Models' Project


                  • #10
                    @but eventually you're going to be left wanting more.

                    You would think after 20 years somebody would have added simple string concatenation in. There are numerous ways it could be done. Surely one of them is sufficient.

                    t = ftos(time());
                    m = "Time is: "

                    msg = "Time is: %t"; <---this is probably the best way

                    msg = m + t;

                    msg = "Time is: ";

                    msg = [m, t].join(" ");


                    • #11
                      Well, luckily for me, I got it working using the function redefine.

                      I've actually started to delve into engine modification, and in the game I'm making, I've changed a few things in the quakespasm engine. It's working extremely well so far, and I hope I can make a good game.

                      I can assure you none of those methods work. The only way for it to is to modify the string structure in the engine, recode the compiler to understand it, and make sure qc can interpret it.


                      • #12
                        Hah! I just thought of a way but it is whacked out. It will work though. Using the file system add-on, append your string to a text file and then read the entire file back to centerprint.
                        Ridiculous? Absolutely. But it will work without redefining built ins (which just seems like a huge hack to me). Honestly, you could probably come up with a lot of reasons to use the file system add-on (like an external database).


                        hey, actually frikfile has a string concat feature


                        Edit...hah. @CaseSensitiveUserName pastes their avatar in the post. This new forum has a lot of little bitty features.
                        You want to drive people nuts? I guarantee you all of these people will get notifications they were mentioned.


                        eh, as much as I want to mention half of the members here for no reason at all, I'll stop there.
                        Last edited by MadGypsy; 07-23-2017, 08:48 PM.