Thread Rating:
		
			
				- 0 Votes - 0 Average
- 1
- 2
- 3
- 4
- 5
 
 
	
	
		
	
		| Vaikin  Apprentice
 
  
 Posts: 4
 Likes Given: 0
 Likes Received: 0 in 0 posts
 Joined: May 2016
 Reputation: 0
 
 
 
 ![]() 
 | 
			| RE: DOSWITCH 
 
				Theres an example in the wiki, should be pretty clear. 
Code:
 ON=@TargOn_Ground
 POINT_INFO <ARGO.P>
 SRC.SYSMESSAGE The point you targetted was: <VAR.TI_P>
 DOSWITCH <VAR.TI_LOS>
 
 SRC.SYSMESSAGE The point is not in your line of sight.
 SRC.SYSMESSAGE The point is in your line of sight.
 
 ENDDO
 SRC.SYSMESSAGE The distance between you and that point is <EVAL <VAR.TI_DISTANCE>> tiles.
 RETURN 1
 |  | 
	| 05-30-2016 08:58 AM |  | 
	
	| ![[+]](images/collapse_collapsed.gif)  
 | 
	
		| Coruja  Sphere Developer
 
      
 Posts: 987
 Likes Given: 5
 Likes Received: 226 in 187 posts
 Joined: Jul 2012
 Reputation: 7
 
 Dimension Shard
 
 ![]() 
 | 
			| RE: DOSWITCH 
 
				DOSWITCH is like an switch to select an specific pre-defined line on the code 
Code:
 DOSWITCH 3SYSMESSAGE Message 0
 SYSMESSAGE Message 1
 SYSMESSAGE Message 2
 SYSMESSAGE Message 3
 SYSMESSAGE Message 4
 ENDDO
 
this will make the code return "SYSMESSAGE Message 3"
 
of course it doesn't make sense use an fixed switch like this example, because if we always want the line 3, it makes more sense use directly "SYSMESSAGE Message 3" instead an useless DOSWITCH with many results but always returning the same fixed result 3
 
so DOSWITCH is usefull on situations where you already have some pre-defined lines and want trigger the correct line based on some other value, like this:
 
Code:
 DOSWITCH <DIR> //this return an 0-7 value based on the direction your char is facingSYSMESSAGE You are facing N
 SYSMESSAGE You are facing NE
 SYSMESSAGE You are facing E
 SYSMESSAGE You are facing SE
 SYSMESSAGE You are facing S
 SYSMESSAGE You are facing SW
 SYSMESSAGE You are facing W
 SYSMESSAGE You are facing NW
 ENDDO
 
in other words, DOSWITCH does the same thing as this code below but using an clean/optimized code
 
Code:
 IF (<DIR>==0)SYSMESSAGE You are facing N
 ELIF (<DIR>==1)
 SYSMESSAGE You are facing NE
 ELIF (<DIR>==2)
 SYSMESSAGE You are facing E
 ELIF (<DIR>==3)
 SYSMESSAGE You are facing SE
 ELIF (<DIR>==4)
 SYSMESSAGE You are facing S
 ELIF (<DIR>==5)
 SYSMESSAGE You are facing SW
 ELIF (<DIR>==6)
 SYSMESSAGE You are facing W
 ELIF (<DIR>==7)
 SYSMESSAGE You are facing NW
 ENDIF
				
(This post was last modified: 05-31-2016 07:53 AM by Coruja.)
 |  | 
	| 05-30-2016 04:19 PM |  | 
	
	| ![[+]](images/collapse_collapsed.gif) The following 1 user Likes Coruja's post:1 user Likes Coruja's post pointhz (05-31-2016)
 | 
	
		| pointhz  Journeyman
 
  
 Posts: 148
 Likes Given: 1
 Likes Received: 55 in 28 posts
 Joined: Oct 2013
 Reputation: 1
 
 
 
 ![]() 
 | 
			| RE: DOSWITCH 
 
				Thanks a lot Coruja    Pretty much clear now xD
 
Thanks for your answer too Vaikin. I'd seen that example already but couldnt figure out how the DOSWITCH function was picking the SYSMESSAGE xD 
 
If I look at the wiki example now I can figure it out. CanSeeLos returns either 0 or 1 and then it will pick either the first line or the second in the DOSWTICH. Makes sense, but it's not easy to find out unless you think about DOSWITCH picking a line by their order based on numbers.
			
				
(This post was last modified: 05-31-2016 05:31 AM by pointhz.)
 |  | 
	| 05-31-2016 05:29 AM |  | 
	
	| ![[+]](images/collapse_collapsed.gif)  
 | 
	 
	
	
		
	
	
		
 
 
	 
	
	
	
	
	
	
	
		
		
	
	
	
User(s) browsing this thread: 1 Guest(s)