Difference between revisions of "0002"

From GTAMods Wiki
Jump to navigation Jump to search
(simple example)
(highlight)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Icon|trilogy}} '''GOTO'''
+
{{OpCode
<hr />
+
| games      = {{Icon|t}}
'''Description'''
+
| command    = GOTO
: Jumps to a label in the thread.
+
| description = Jumps to a label in the [[script]]
'''Syntax'''
+
| syntax1    = 0002: jump [''label'']
: 0002: jump [''label'']
+
| syntax2    = jump [''label'']
: jump [''label'']
+
| p1t        = [''label'']
'''Parameters'''
+
| p1d        = The position in the script it will go to, usually identified by a [[label]]
: [''label'']
+
}}
:: The position in the script it will go to, usually identified by a [[label]]
 
  
This is used in unconditional jumps. In both the Mission Builder and [[Sanny Builder]], you can use the '''jump''' keyword instead. The destination point is identified by a label, which is then used as a parameter.
+
This opcode is used in unconditional jumps, which allow the game to continue processing the script starting at the location of the label. In both the Mission Builder and [[Sanny Builder]], you can use the '''jump''' keyword instead.
  
 
== Example ==
 
== Example ==
The following example, using Sanny Builder, shows a simple usage of a "jump" out of a while loop to a specified label after the CAMERA key is pressed. The message will change from 0 to 1 after a successful jump.
+
The following example, using Sanny Builder, shows a simple usage of a "jump" out of a while loop to the specified label after pressing [[00E1|button 13]] (CAMERA key). The message will change from 0 to 1 after a successful jump.
<syntaxhighlight lang="scm">
+
{{Pre|class=sb-code|1=
while true
+
<span class="k">while</span> <span class="k">true</span>
     wait 10 ms
+
     <span class="k">wait</span> <span class="m">10</span> ms
     01E5: text_1number_highpriority 'NUMBER' 0 10 ms 1
+
     01E5: text_1number_highpriority <span class="s1">'NUMBER'</span> <span class="m">0</span> <span class="m">10</span> ms <span class="m">1</span>
     if  
+
     <span class="k">if</span>
         00E1:  key_pressed 0 13  // camera key
+
         [[00E1]]:  key_pressed <span class="m">0</span> <span class="m">13</span> <span class="c1">// camera key</span>
     then
+
     <span class="k">then</span>
         jump @label_goto
+
         <span class="k">jump</span> <span class="nl">@label_goto</span>
     end
+
     <span class="k">end</span>
end
+
<span class="k">end</span>
  
:label_misc
+
<span class="nl">:label_misc</span>
// miscellaneous content
+
<span class="c1">// miscellaneous content</span>
  
:label_goto
+
<span class="nl">:label_goto</span>
01E5: text_1number_highpriority 'NUMBER' 1 5000 ms 1
+
01E5: text_1number_highpriority <span class="s1">'NUMBER'</span> <span class="m">1</span> <span class="m">5000</span> ms <span class="m">1</span>
</syntaxhighlight>
+
}}
  
 
== Keywords ==
 
== Keywords ==
 
jump, goto, label
 
jump, goto, label
  
[[Category:OpCodes]]
+
== See also ==
 +
* {{Icon|t}} [[004D]], goto if false

Latest revision as of 08:01, 2 December 2016

GTA III Vice City San Andreas GOTO


Description
Jumps to a label in the script
Syntax
0002: jump [label]
jump [label]
Parameter
[label]
The position in the script it will go to, usually identified by a label

This opcode is used in unconditional jumps, which allow the game to continue processing the script starting at the location of the label. In both the Mission Builder and Sanny Builder, you can use the jump keyword instead.

Example

The following example, using Sanny Builder, shows a simple usage of a "jump" out of a while loop to the specified label after pressing button 13 (CAMERA key). The message will change from 0 to 1 after a successful jump.

while true
    wait 10 ms
    01E5: text_1number_highpriority 'NUMBER' 0 10 ms 1
    if 
        00E1:   key_pressed 0 13  // camera key
    then
        jump @label_goto
    end
end

:label_misc
// miscellaneous content

:label_goto
01E5: text_1number_highpriority 'NUMBER' 1 5000 ms 1

Keywords

jump, goto, label

See also

  • GTA III Vice City San Andreas 004D, goto if false