Difference between revisions of "0AD9"
Jump to navigation
Jump to search
(Created page with "{{OpCode | games = {{Icon|t}} (with CLEO) | description = Writes a formatted text to the file | syntax1 = 0AD9: write_formatted_text "[''string'']" in_file [''fi...") |
m |
||
(2 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
| p2d = The [[0A9A|handle of the file]] | | p2d = The [[0A9A|handle of the file]] | ||
| p3t = [''any''] | | p3t = [''any''] | ||
− | | p3d = | + | | p3d = Any values to write (optional) |
}} | }} | ||
Line 14: | Line 14: | ||
== Example == | == Example == | ||
− | The following example allows you to record your positions into a file every time you press [[00E1|button 17 ( | + | The following example allows you to record your positions into a file every time you press [[00E1|button 17]] (ATTACK key). |
− | < | + | {{Pre|class=sb-code|1= |
− | const | + | <span class="k">const</span> |
− | FILE_HANDLE = 0@ | + | FILE_HANDLE = <span class="nv">0@</span> |
− | X_POS = 1@ | + | X_POS = <span class="nv">1@</span> |
− | Y_POS = 2@ | + | Y_POS = <span class="nv">2@</span> |
− | Z_POS = 3@ | + | Z_POS = <span class="nv">3@</span> |
− | end | + | <span class="k">end</span> |
− | 0A9A: FILE_HANDLE = openfile "output" mode 0x77 // w | + | [[0A9A]]: FILE_HANDLE = openfile <span class="s2">"output"</span> mode <span class="m">0x77</span> <span class="c1">// w</span> |
− | while true | + | <span class="k">while</span> <span class="k">true</span> |
− | wait 10 | + | <span class="k">wait</span> <span class="m">10</span> |
− | if | + | <span class="k">if</span> |
− | 00E1: player 0 pressed_button 17 // attack key | + | [[00E1]]: player <span class="m">0</span> pressed_button <span class="m">17</span> <span class="c1">// attack key</span> |
− | then | + | <span class="k">then</span> |
− | while 00E1: player 0 pressed_button 17 // attack key | + | <span class="k">while</span> [[00E1]]: player <span class="m">0</span> pressed_button <span class="m">17</span> <span class="c1">// attack key</span> |
− | wait 0 | + | <span class="k">wait</span> <span class="m">0</span> |
− | end | + | <span class="k">end</span> |
− | 0054: store_player $PLAYER_CHAR position_to X_POS Y_POS Z_POS | + | [[0054]]: store_player <span class="nv">$PLAYER_CHAR</span> position_to X_POS Y_POS Z_POS |
− | 0AD9: write_formatted_text "%f %f %f%c" in_file FILE_HANDLE data X_POS Y_POS Z_POS 0xA | + | 0AD9: write_formatted_text <span class="s2">"%f %f %f%c"</span> in_file FILE_HANDLE data X_POS Y_POS Z_POS <span class="m">0xA</span> |
− | end | + | <span class="k">end</span> |
− | end | + | <span class="k">end</span> |
− | </ | + | }} |
+ | |||
+ | == Keywords == | ||
+ | write, file, format, formatted, text | ||
[[Category:CLEO Opcodes]] | [[Category:CLEO Opcodes]] |
Latest revision as of 05:59, 1 February 2017
(with CLEO)
- Description
- Writes a formatted text to the file
- Syntax
- 0AD9: write_formatted_text "[string]" in_file [file] ( [any] ... )
- Parameter
- [string]
- Text to write into the file (see
fprintf
for explanation) - [file]
- The handle of the file
- [any]
- Any values to write (optional)
This CLEO opcode writes a formatted text to the file. In Sanny Builder it is important that you disable case converting in order for the opcode to work as expected. In "Options..." under the "Formats" tab in the "Case converting" box, select "As is". For CLEO v2.0.0.4 and below for GTA III and Vice City, this opcode crashes the game.
Example
The following example allows you to record your positions into a file every time you press button 17 (ATTACK key).
const FILE_HANDLE = 0@ X_POS = 1@ Y_POS = 2@ Z_POS = 3@ end 0A9A: FILE_HANDLE = openfile "output" mode 0x77 // w while true wait 10 if 00E1: player 0 pressed_button 17 // attack key then while 00E1: player 0 pressed_button 17 // attack key wait 0 end 0054: store_player $PLAYER_CHAR position_to X_POS Y_POS Z_POS 0AD9: write_formatted_text "%f %f %f%c" in_file FILE_HANDLE data X_POS Y_POS Z_POS 0xA end end
Keywords
write, file, format, formatted, text