| Author | Message | 
        
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Lua scripts that interact with eachother? *SolvedI want to make a Lua script that interacts with another Lua script directly. Example:
 If self.blabla then
 self.partnerscript.randcounter = 123
 end
 
 How would I do this?
 
 
 
    							Last edited by CaveCricket48 on Sat Oct 17, 2009 11:28 pm, edited 1 time in total. 
 
 | 
		
			| Sat Oct 17, 2009 4:02 pm | 
					
					   | 
	
	
		|  | 
	
			| zalo 
					Joined: Sat Feb 03, 2007 7:11 pm
 Posts: 1496
   |   Re: Lua scripts that interact with eachother?Global Variables.  EVERYTHING can access those.
 But, there's probably a better/more specialized way.
 
 
 | 
		
			| Sat Oct 17, 2009 4:18 pm | 
					
					     | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: Lua scripts that interact with eachother?Can you edit Descriptions with Lua the same way you can edit Mass/Health/ect? Maybe I can do that. 
 
 | 
		
			| Sat Oct 17, 2009 4:40 pm | 
					
					   | 
	
	
		|  | 
	
			| Roon3 
					Joined: Sun May 11, 2008 12:50 pm
 Posts: 899
   |   Re: Lua scripts that interact with eachother?Code: Obj. A
 self.Johnny = 1
 
 Obj. B
 
 For x in movableman.stuff do
 if x.presetname == Obj. A then
 x = self.GuyI'mGonnaInteractWith
 end
 end
 
 if self.GuyI'mGonnaInteractWith.Johnny == 1 then
 stuffs
 end
That works IIRC, I'm most likely wrong, and if I am, CC's lua is ♥♥♥♥.
 
 | 
		
			| Sat Oct 17, 2009 5:04 pm | 
					
					     | 
	
	
		|  | 
	
			| findude 
					Joined: Tue Dec 12, 2006 3:10 pm
 Posts: 495
 Location: Uncertain quantum state
   |   Re: Lua scripts that interact with eachother?That might do the trick, but the partner will be pretty random.
 Try looking at the teleporter code for some partnering stuff.
 
 
 | 
		
			| Sat Oct 17, 2009 5:54 pm | 
					
					   | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: Lua scripts that interact with eachother?The teleporter script adds itself to a list and the partner does the same. Then it just interacts with the said list. That wouldn't work very well with what I'm doing, since I'm making a Device. Roon's method looks good, going to try it.
 EDIT: I was thinking of something. Is it possible to switch the magazine of a gun with a different one?
 
 
 | 
		
			| Sat Oct 17, 2009 6:00 pm | 
					
					   | 
	
	
		|  | 
	
			| Roon3 
					Joined: Sun May 11, 2008 12:50 pm
 Posts: 899
   |   Re: Lua scripts that interact with eachother?That's most likely hardcoded, I don't think you can even check it. If you want to have various magazines you can always lua the fireing. Also Findude, that was just an example, you can always make the search more specific. 
 
 | 
		
			| Sat Oct 17, 2009 6:23 pm | 
					
					     | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: Lua scripts that interact with eachother?How do you use Lua to drop the weapon you're currently holding? 
 
 | 
		
			| Sat Oct 17, 2009 6:40 pm | 
					
					   | 
	
	
		|  | 
	
			| TheLastBanana DRL Developer 
					Joined: Wed Dec 13, 2006 5:27 am
 Posts: 3138
 Location: A little south and a lot west of Moscow
   |   Re: Lua scripts that interact with eachother?Code: local cont = actor:GetController();cont:SetState(Controller.WEAPON_DROP);
 
 | 
		
			| Sat Oct 17, 2009 10:35 pm | 
					
					     | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: Lua scripts that interact with eachother?I changed WEAPON_DROP to BODY_JUMP for testing, and CC crashed with this: Attachment: 
			 Error.bmp [ 279.39 KiB | Viewed 4525 times ]
 
 | 
		
			| Sat Oct 17, 2009 10:52 pm | 
					
					   | 
	
	
		|  | 
	
			| TheLastBanana DRL Developer 
					Joined: Wed Dec 13, 2006 5:27 am
 Posts: 3138
 Location: A little south and a lot west of Moscow
   |   Re: Lua scripts that interact with eachother?Pastebin the code. 
 
 | 
		
			| Sat Oct 17, 2009 10:53 pm | 
					
					     | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: Lua scripts that interact with eachother?
 
 | 
		
			| Sat Oct 17, 2009 10:56 pm | 
					
					   | 
	
	
		|  | 
	
			| TheLastBanana DRL Developer 
					Joined: Wed Dec 13, 2006 5:27 am
 Posts: 3138
 Location: A little south and a lot west of Moscow
   |   Re: Lua scripts that interact with eachother?Looking at that, I'm not really sure. 
 
 | 
		
			| Sat Oct 17, 2009 11:01 pm | 
					
					     | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: Lua scripts that interact with eachother? *SolvedNVM, got it working using: self.parentactor:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true); 
 
 | 
		
			| Sat Oct 17, 2009 11:29 pm | 
					
					   | 
	
	
		|  | 
	
			| TheLastBanana DRL Developer 
					Joined: Wed Dec 13, 2006 5:27 am
 Posts: 3138
 Location: A little south and a lot west of Moscow
   |   Re: Lua scripts that interact with eachother? *SolvedAh, crap.  I forget the second argument.  That would be the problem. 
 
 | 
		
			| Sat Oct 17, 2009 11:31 pm | 
					
					     | 
	
	
		|  | 
	
	
		|  |