Difference between revisions of "0AD9"
Jump to navigation
Jump to search
(highlight) |
m |
||
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= | {{Pre|class=sb-code|1= | ||
<span class="k">const</span> | <span class="k">const</span> | ||
Line 23: | Line 23: | ||
<span class="k">end</span> | <span class="k">end</span> | ||
− | 0A9A: FILE_HANDLE = openfile <span class="s2">"output"</span> mode <span class="m">0x77</span> <span class="c1">// w</span> | + | [[0A9A]]: FILE_HANDLE = openfile <span class="s2">"output"</span> mode <span class="m">0x77</span> <span class="c1">// w</span> |
<span class="k">while</span> <span class="k">true</span> | <span class="k">while</span> <span class="k">true</span> | ||
<span class="k">wait</span> <span class="m">10</span> | <span class="k">wait</span> <span class="m">10</span> | ||
<span class="k">if</span> | <span class="k">if</span> | ||
− | 00E1: player <span class="m">0</span> pressed_button <span class="m">17</span> <span class="c1">// attack key</span> | + | [[00E1]]: player <span class="m">0</span> pressed_button <span class="m">17</span> <span class="c1">// attack key</span> |
<span class="k">then</span> | <span class="k">then</span> | ||
− | <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> | + | <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> |
<span class="k">wait</span> <span class="m">0</span> | <span class="k">wait</span> <span class="m">0</span> | ||
<span class="k">end</span> | <span class="k">end</span> | ||
− | 0054: store_player <span class="nv">$PLAYER_CHAR</span> 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 <span class="s2">"%f %f %f%c"</span> in_file FILE_HANDLE data X_POS Y_POS Z_POS <span class="m">0xA</span> | 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> | ||
<span class="k">end</span> | <span class="k">end</span> | ||
<span class="k">end</span> | <span class="k">end</span> | ||
}} | }} | ||
+ | |||
+ | == Keywords == | ||
+ | write, file, format, formatted, text | ||
[[Category:CLEO Opcodes]] | [[Category:CLEO Opcodes]] |
Revision as of 04:37, 18 January 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]
- Values to write (any data type)
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