FSDeveloper Community

Go Back   FSDeveloper Community > FSDeveloper Wiki

XML: Loop Using a Goto

From FSDeveloper Wiki

[edit] XML: Loop Using a Goto

A Loop can be easy simulated using a g (goto) command which uses :number_label for its target:

<Update>
  100 sp0 (* initialize, reg.0 = loop counter, 100 cycles *)
  :12345 (* loop label *)

	(* do something *)
	
  l0 -- s0 0 > if{ g12345 } (* next *)
</Update>

An alternative to using the stack pointer operators (and makes the script more clear!) is this form:

<Update>
   100 (>L:LoopCounter,enum) (* initialize the counter's stack, 100 cycles *)
   :12345 (* loop label *)

	(* do something *)

   (L:LoopCounter,enum) 1 - (>L:LoopCounter,enum)	(* decrement -1 *)
   (L:LoopCounter,enum) 0 > if{ g12345 } (* next *)
</Update>

Notes:

1. loop label can be any unique number
2. This "loop" will execute completely on every gauge cycle (18Hz), so you may wish to "slow it down" by using a master timer.

--N4gix 13:35, 2 September 2011 (EDT)


All times are GMT -4. The time now is 02:25.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Powered by vbWiki Pro 1.3 RC4. Copyright ©2006-2007, NuHit, LLC