Difference between revisions of "Thread"
From Unofficial QEdit Wiki Guide
Japanaman2 (Talk | contribs) |
Japanaman2 (Talk | contribs) m |
||
(3 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
==Use== | ==Use== | ||
Used to thread a constantly running function regardless of what floor you are on. | Used to thread a constantly running function regardless of what floor you are on. | ||
+ | |||
+ | (To thread functions that will end when the players change floors see [[thread_stg]]) | ||
Threads allow for the threaded function to run all while letting the main script continue on. | Threads allow for the threaded function to run all while letting the main script continue on. | ||
Line 11: | Line 13: | ||
Usually used for looping functions that jmp back on their selves (time), or when you need to preform a constant check of a register. | Usually used for looping functions that jmp back on their selves (time), or when you need to preform a constant check of a register. | ||
− | + | When using threaded functions make sure you start the threaded function with a sync. | |
==Example== | ==Example== | ||
<span style='font-size:12px;font-family:courier'> | <span style='font-size:12px;font-family:courier'> | ||
− | <span style='color:blue'>100: </span><span style='color:green'>thread </span>101 <span style='color:orange'>//Threads Function 101 so that the main | + | <span style='color:blue'>100: </span><span style='color:green'>thread </span>101 <span style='color:orange'>//Threads Function 101 so that the main script can continue while 101 is going on.</span> |
<span style='color:green'> ret </span> | <span style='color:green'> ret </span> | ||
<span style='color:blue'>101: </span><span style='color:green'>sync </span><span style='color:orange'>//Waits 1 frame.</span> | <span style='color:blue'>101: </span><span style='color:green'>sync </span><span style='color:orange'>//Waits 1 frame.</span> | ||
− | <span style='color:green'> addi </span>R1, 00000001 <span style='color:orange'>//Adds | + | <span style='color:green'> addi </span>R1, 00000001 <span style='color:orange'>//Adds 00000001 to register1.</span> |
<span style='color:green'> jmp </span>101 <span style='color:orange'>//Jumps back to function 101.</span> | <span style='color:green'> jmp </span>101 <span style='color:orange'>//Jumps back to function 101.</span> | ||
</span> | </span> |
Latest revision as of 00:31, 1 August 2013
Contents
Syntax
Syntax: thread Function
- Function = Function to thread.
Use
Used to thread a constantly running function regardless of what floor you are on.
(To thread functions that will end when the players change floors see thread_stg)
Threads allow for the threaded function to run all while letting the main script continue on.
Usually used for looping functions that jmp back on their selves (time), or when you need to preform a constant check of a register.
When using threaded functions make sure you start the threaded function with a sync.
Example
100: thread 101 //Threads Function 101 so that the main script can continue while 101 is going on.
ret
101: sync //Waits 1 frame.
addi R1, 00000001 //Adds 00000001 to register1.
jmp 101 //Jumps back to function 101.