Displaying randomly generated number somewhere in map (TF2)

Discussion in 'Mapping Questions & Discussion' started by Sappykun, Nov 4, 2019.

  1. Sappykun

    Sappykun L1: Registered

    Messages:
    2
    Positive Ratings:
    0
    I have a logic_case -> math_remap -> math_counter setup that effectively generates a random number between 0 and about 530,000 when the map starts. The number is then deposited in a logic_compare where it is used to determine a pattern for a code-breaking game I have created.

    However, without knowing what this value is, the game is unplayable.

    How would I go about displaying this value somewhere in the map? The values I am using are not pre-generated, so I cannot make specific textures for specific numbers. It needs to work for the general case. I do not want to hard-code any of the values into the map.

    Things I have looked into:
    • game_text: Would probably be the least elegant but easiest solution. Problem is, I don't know how to change the text by sending it an input. Can I change the message property using AddOutput? How would I pass in the parameter?
    • A ToggleTexture system similar to the way the buttons are set up to display the number somewhere.
    Thanks.

    If it helps, here is the game in action:

    https://files.catbox.moe/10nd1c.webm

     
    Last edited: Nov 13, 2019 at 2:33 PM
  2. Sappykun

    Sappykun L1: Registered

    Messages:
    2
    Positive Ratings:
    0
    I've changed the number generating logic to generate a random value between 0 and 499,999, allowing me to display each digit separately on a second ToggleTexture system. This eliminates some of the combos from the entire set of potential codes, but only 6%. I'm willing to live with that.

    My question still stands: How can I display an arbitrary integer somewhere on the map, such as a counter's value, without needing to generate and display each digit individually?
     
  3. Da Spud Lord

    aa Da Spud Lord L0: Crappy Member

    Messages:
    1,120
    Positive Ratings:
    763
    Unfortunately, the best method you have, I think, is just to generate each digit separately, and create the logic to display each digit individually, so you only need textures or game_text entities for the numbers 0-9. (If you use game_text, you may need as many as 10 game_text entities for each digit in your number, although using methods below you could reduce this to one entity per digit.)

    game_text does have a method of changing it's text at runtime, but this will not work for what you're trying to do. AddOutput can be used to change the keyvalue of basically any entity at runtime, including the message text of a game_text. However, because of the way AddOutput works, there's no way to plug a variable value into the entity. You need to include the key and value together in the parameter of AddOutput output to change a keyvalue, and Hammer has no tools for merging and outputting strings. As such, even AddOutputing to change the text of a game_text still requires you to explicitly declare what you want to display. Any other method of outputting display text, either into the world or onto a player's HUD, will, to my knowledge, suffer the same issue.

    EDIT: You could try displaying the number in a paused team_round_timer, but not sure how well that will work.
     
    Last edited: Nov 13, 2019 at 4:08 PM