1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Choose your ride to damnation in the 5th Special Effect Contest Poll.
    Dismiss Notice
  5. The winners of the 13th Techtree Contest have been announced!
    Dismiss Notice
  6. Vote for the best entries in the 13th Music Contest Poll.
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] The "%" character

Discussion in 'Triggers & Scripts' started by mecatronic, Apr 8, 2009.

  1. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I'm trying to use this function:
    Code (vJASS):
    call DisplayTimedTextToForce( p_force, 20.00, "|cffffcc00You picked a Random Hero. You will receive 2 healing potions now and 50% bonus gold each wave." )


    but when I run the function, it displays "You picked a Random Hero. You will receive 2 healing potions now and 50 bonus gold each wave."

    it should be "50% bonus"

    what am I doing wrong?
     
  2. Shadow Daemon

    Shadow Daemon

    Joined:
    Nov 23, 2008
    Messages:
    184
    Resources:
    3
    Tools:
    3
    Resources:
    3
    Write two % symbols instead of one:

    Code (vJASS):
    call DisplayTimedTextToForce(p_force, 20., "|cffffcc00You picked a Random Hero. You will receive 2 healing potions now and 50%% bonus gold each wave.")
     
  3. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    oh, thanks for that
     
  4. Teelo

    Teelo

    Joined:
    Mar 31, 2009
    Messages:
    709
    Resources:
    1
    Maps:
    1
    Resources:
    1
    In some languages, % is a reserved character for wildcard or control, I guess based on what Shadow Daemon said, in JASS it is control (eg %n for newline?).

    I'm still learning JASS myself, but take php for example, and backspace. In php, strings enclosed in double quotes are checked for any special characters, and processed.
    If you write:
    Code (Text):
    echo 'blah \n blah';
    The output will be:
    blah \n blah

    If you write:
    Code (Text):
    echo "blah \n blah";
    The output will be:
    blah
    blah
     
  5. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    457
    Resources:
    0
    Resources:
    0
    In jass % is no reserved char. (ok there is one(?) function that uses %s. and in the game interface)
    But there is a bug that single % will removed in the header.
    So in the header you have to write two %. In your trigger on %.
    (I dont know what you have to do in libraries but i think one % should enough there)
     
  6. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    but i thought libraries were part of the header? they're at the top of it? on top of it?
     
  7. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    There is no structure in the code (beyond functions and the globals block at the top) once it's compiled. It's all dumped into one big .j file.
     
  8. Bobo_The_Kodo

    Bobo_The_Kodo

    Joined:
    Jan 15, 2007
    Messages:
    192
    Resources:
    0
    Resources:
    0
    %_ is a command used in wc strings -- don't know why

    like %r crashes game or something :)

    try experimenting