Difference between revisions of "Category:Code Snippets"
Jump to navigation
Jump to search
m |
|||
Line 2: | Line 2: | ||
''Note:'' Don't just post your code, also give an explanation what it does and in which context it has to be used. | ''Note:'' Don't just post your code, also give an explanation what it does and in which context it has to be used. | ||
+ | |||
+ | =Arrays in Vice City= | ||
+ | :label | ||
+ | 0006: 0@ = 10 //these are the values we want to return from the array | ||
+ | 0051: reutrn | ||
+ | 0006: 0@ = 78 //the space that the 0006 and the 0051 opcodes take up in total is 9 bytes because: | ||
+ | 0051: return //opcode(2 bytes) + ptype(1 byte) + var(2 bytes) + ptype(1 byte) + smallint(1 byte) + opcode(2 bytes) = 9 | ||
+ | 0006: 0@ = 36 | ||
+ | 0051: return | ||
+ | |||
+ | 008B: 1@ = $index //if we want the second value then $index = 1 (because for the first value $index = 0) | ||
+ | 0012: 1@ *= 9 //9 * 1 = 9 (9 because the 0006 + 0051 opcodes take up 9 bytes in this case) | ||
+ | 000A: 1@ += ££label //add the value of ££label to 1@ | ||
+ | 0050: gosub 1@ //gosub to ££label + 9, so 0@ returns 78 | ||
[[Category:Mission Script]] | [[Category:Mission Script]] |
Revision as of 17:23, 13 December 2005
A collection of code snippets often used in the mission script, or to accomplish certain tasks.
Note: Don't just post your code, also give an explanation what it does and in which context it has to be used.
Arrays in Vice City
:label 0006: 0@ = 10 //these are the values we want to return from the array 0051: reutrn 0006: 0@ = 78 //the space that the 0006 and the 0051 opcodes take up in total is 9 bytes because: 0051: return //opcode(2 bytes) + ptype(1 byte) + var(2 bytes) + ptype(1 byte) + smallint(1 byte) + opcode(2 bytes) = 9 0006: 0@ = 36 0051: return 008B: 1@ = $index //if we want the second value then $index = 1 (because for the first value $index = 0) 0012: 1@ *= 9 //9 * 1 = 9 (9 because the 0006 + 0051 opcodes take up 9 bytes in this case) 000A: 1@ += ££label //add the value of ££label to 1@ 0050: gosub 1@ //gosub to ££label + 9, so 0@ returns 78
Pages in category "Code Snippets"
The following 32 pages are in this category, out of 32 total.