Difference between revisions of "Template:OBSE Format Specifiers"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Haama
(→‎EX Formatting Functions: Updated to v0014a)
imported>QQuix
(Updated and reordered)
 
(24 intermediate revisions by 8 users not shown)
Line 1: Line 1:
=== EX Formatting Functions ===
====OBSE Format Specifiers====
These formatting specifiers will work with [[:Category:Oblivion Script Extender|OBSE]] output functions, along with the usual functions.


In addition to the format specifiers supported by Oblivion's [[Message]] and [[MessageBox]] functions, [[:Category:Oblivion Script Extender|OBSE]] functions understand additional specifiers (in alphabetic order).


'''%r'''


Prints a return, ending the current line and starting at the next.
'''%a''' - Prints the character corresponding to the specified ASCII code.
:*Passing codes for unprintable characters (such as 0) may have unpredictable (though occasionally useful) results.
:*Passing the code for a percent sign will most likely crash the game as literal percent signs must come in pairs.




'''%n'''
'''%B''' - toggles blue text on for console output.


Prints the name of the specified reference or object.
'''%b''' - toggles blue text off for console output.
:*Example: "%BBlue%b suede shoes": when printed to the console, the word "Blue" will be printed in blue text.




'''%i'''
'''%c''' - Prints the specified component of the specified reference or object.
:Takes two arguments - a reference variable set to the spell or faction, and an index. Behaves differently depending on the passed reference:
::* Faction: Prints the ''n''th male rank title
::* Magic Item: Prints the ''n''th Magic Effect
:::*Prior to OBSE v0015, magic effects using actor values (such as Restore Agility) would not display the specific actor value.
:::*Actor values may not display correctly for non-English versions of Oblivion.


Prints the formID of the specified reference or object.


'''%e''' – replaced by nothing.
:*Provides a workaround for the script compiler's refusal to accept an empty string as a command argument.
:* Example:
SetNameEx "" object    ; attempts to remove an object's name, but won't compile
SetNameEx "%e" object  ; sets the name to an empty string
:*Can be used outside of format strings. When included in ''any'' string literal, %e will be replaced by an empty string.


'''%k'''


Prints the name of the key for the specified DirectInput scancode, such as those used for [[IsKeyPressed2]].
'''%i''' - Prints the FormID of the specified reference or object.
:*GOTCHA : as of v18, if a refVar is passed which points to a ref not loaded in memory %i will print 00000000 ''even if the refVar is not empty''.




'''%c'''
'''%k''' - Prints the name of the key for the specified DirectInput scancode, such as those used for [[IsKeyPressed2]].


Prints the specified component of the specified reference or object. Takes two arguments - the reference, and an index. Behaves differently depending on the passed reference:
:* Magic Item: Prints the ''n''th Magic Effect
:* Faction: Prints the ''n''th male rank title


===Added as of v0014a===
'''%n''' - Prints the name of the specified reference or object.
:* In OBSE versions prior to v0014a, %n can crash if the object's name contains a percent sign.


'''%p'''


Displays a pronoun based on the gender of the object parameter:
'''%p''' - Displays a pronoun based on the gender of the object parameter:
:*%po - objective  (he, she, it)
:* %po - objective  (him, her, it)
:*%pp - possessive (his, her, its)
:* %pp - possessive (his, her, its)
:*%ps - subjective (him, her, it)
:* %ps - subjective (he, she, it)




'''%q'''
'''%q''' - Prints a double quote character.
:*Can be used outside of format strings. When included in ''any'' string literal, %q will be replaced by a double quote


Prints a double quote character.
'''%r''' - Prints a carriage return, ending the current line and starting at the next.
:*Can be used outside of format strings. When included in ''any'' string literal, %r will be replaced by a carriage return.




'''%(...%)
'''%v''' - Prints the actor value (i.e. an attribute or skill) associated with the passed actor value code.


Conditionally omits a portion of the format string based on a boolean value. The left bracket accepts a variable; if the value of the variable is zero, all text up to the right bracket will be ignored, and any parameters supplied to format specifiers within the omitted substring will be skipped.
 
'''%x''' - Prints an integer in hexadecimal format.
:An optional digit from 0-9 immediately following this specifier indicates the minimum width of the displayed value.
::*For example, MessageEx "%x4" 255 will display "00FF".
 
 
'''%z''' – Prints the contents of a string variable.
:*Example:  sv_construct “The string is: %z” MyStringVar
 
 
'''%{...%}''' - Conditionally displays or omits the bracketed portion of the format string based on a boolean value. Accepts a variable - if the value of the variable is zero, all text and parameters up to the matching right bracket will be ignored. Otherwise the bracketed text will be displayed.
* Example (should be single-line, line-breaks added for Wiki)
MBoxEX "Doom comes%{ for you%}. What will you do?
|Dig a hole, hide
%{|Find someone, offer as sacrifice|Find someone, use as shield%}
|Enjoy your final 15 minutes" bDisplay bDisplay
If bDisplay is 0 this will print out
    Doom comes. What will you do?
    [Dig a hole, hide]
    [Enjoy your final 15 minutes]
If bDisplay is 1 this will print out
    Doom comes for you. What will you do?
    [Dig a hole, hide]
    [Find someone, offer as sacrifice]
    [Find someone, use as shield]
    [Enjoy your final 15 minutes]
* Note: When using [[GetButtonPressed]] with messageboxes that can have a variable number of buttons displayed using '''%{...%}''', the return value will be relative to the actual number of buttons displayed and will not include buttons hidden by '''%{...%}'''.
 
 
<noinclude>
[[Category: Templates|OBSE Format Specifiers]]
[[Category: Function Info Templates|OBSE Format Specifiers]]
</noinclude>

Latest revision as of 12:07, 26 May 2013

OBSE Format Specifiers[edit source]

In addition to the format specifiers supported by Oblivion's Message and MessageBox functions, OBSE functions understand additional specifiers (in alphabetic order).


%a - Prints the character corresponding to the specified ASCII code.

  • Passing codes for unprintable characters (such as 0) may have unpredictable (though occasionally useful) results.
  • Passing the code for a percent sign will most likely crash the game as literal percent signs must come in pairs.


%B - toggles blue text on for console output.

%b - toggles blue text off for console output.

  • Example: "%BBlue%b suede shoes": when printed to the console, the word "Blue" will be printed in blue text.


%c - Prints the specified component of the specified reference or object.

Takes two arguments - a reference variable set to the spell or faction, and an index. Behaves differently depending on the passed reference:
  • Faction: Prints the nth male rank title
  • Magic Item: Prints the nth Magic Effect
  • Prior to OBSE v0015, magic effects using actor values (such as Restore Agility) would not display the specific actor value.
  • Actor values may not display correctly for non-English versions of Oblivion.


%e – replaced by nothing.

  • Provides a workaround for the script compiler's refusal to accept an empty string as a command argument.
  • Example:
SetNameEx "" object    ; attempts to remove an object's name, but won't compile
SetNameEx "%e" object  ; sets the name to an empty string
  • Can be used outside of format strings. When included in any string literal, %e will be replaced by an empty string.


%i - Prints the FormID of the specified reference or object.

  • GOTCHA : as of v18, if a refVar is passed which points to a ref not loaded in memory %i will print 00000000 even if the refVar is not empty.


%k - Prints the name of the key for the specified DirectInput scancode, such as those used for IsKeyPressed2.


%n - Prints the name of the specified reference or object.

  • In OBSE versions prior to v0014a, %n can crash if the object's name contains a percent sign.


%p - Displays a pronoun based on the gender of the object parameter:

  • %po - objective (him, her, it)
  • %pp - possessive (his, her, its)
  • %ps - subjective (he, she, it)


%q - Prints a double quote character.

  • Can be used outside of format strings. When included in any string literal, %q will be replaced by a double quote

%r - Prints a carriage return, ending the current line and starting at the next.

  • Can be used outside of format strings. When included in any string literal, %r will be replaced by a carriage return.


%v - Prints the actor value (i.e. an attribute or skill) associated with the passed actor value code.


%x - Prints an integer in hexadecimal format.

An optional digit from 0-9 immediately following this specifier indicates the minimum width of the displayed value.
  • For example, MessageEx "%x4" 255 will display "00FF".


%z – Prints the contents of a string variable.

  • Example: sv_construct “The string is: %z” MyStringVar


%{...%} - Conditionally displays or omits the bracketed portion of the format string based on a boolean value. Accepts a variable - if the value of the variable is zero, all text and parameters up to the matching right bracket will be ignored. Otherwise the bracketed text will be displayed.

  • Example (should be single-line, line-breaks added for Wiki)
MBoxEX "Doom comes%{ for you%}. What will you do?
|Dig a hole, hide
%{|Find someone, offer as sacrifice|Find someone, use as shield%}
|Enjoy your final 15 minutes" bDisplay bDisplay

If bDisplay is 0 this will print out

   Doom comes. What will you do?
   [Dig a hole, hide]
   [Enjoy your final 15 minutes]

If bDisplay is 1 this will print out

   Doom comes for you. What will you do?
   [Dig a hole, hide]
   [Find someone, offer as sacrifice]
   [Find someone, use as shield]
   [Enjoy your final 15 minutes]
  • Note: When using GetButtonPressed with messageboxes that can have a variable number of buttons displayed using %{...%}, the return value will be relative to the actual number of buttons displayed and will not include buttons hidden by %{...%}.