| Author | 
            Message | 
        
        
			| 
				
				 Duh102 
				happy carebear mom 
				
					 Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
				 
				 
			 | 
			
				
				  Toggleable hover code [solved]  
					
						Ok, so I think I have most of this figured out but the actual toggling is the problem. I have a gun which spawns a particle with the following script attached Attachment: 
			
				  
				Floater.txt [886 Bytes]
			
			Downloaded 227 times
		
		
	 And an actor with the following script attached. Attachment: 
			
				  
				Fly.txt [2.11 KiB]
			
			Downloaded 238 times
		
		
	 In theory, when the actor activates the gun the hover code should kick in, yes? For some reason this is not the case. Any ideas on what I did wrong? Further information: The actor's Goldvalue is set to 1337 (with the debug print) so perhaps I got the position of the timer reset wrong? EDIT: With a bit of a print I found it does indeed reset every 50ms, so that's not it.  
					
  
			 | 
		
		
			| Mon Apr 05, 2010 8:10 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 PhantomAGN 
				
				
					 Joined: Mon Jun 29, 2009 2:40 am Posts: 610 Location: Deep below The Map of Mars
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						I read your Lua, and I do not see where you would determine what actor fired the particle. Pretty sure you need to do that in order to manipulate said actor.
  Also, it's GoldValue, not GoldCost. Also, checking that is only going to determine if the particle's value is 1337. If my senior project had not literally caught fire (bad capacitor, no regulator, oops) I would have been working on a similar script.
  -- Disregard that, I ignored the first DL. 
					
							
  
							
    							Last edited by PhantomAGN on Mon Apr 05, 2010 11:31 pm, edited 1 time in total. 
    						 
						
  
			 | 
		
		
			| Mon Apr 05, 2010 10:48 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Duh102 
				happy carebear mom 
				
					 Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						I did #1, look at the section in floater beginning with "for actor in MovableMan.Actors do" I have GoldValue in floater but not fly... If that's it I'm gonna be angry. EDIT: And now it tells me that GoldValue is read only. Well then I suppose I have to use something else. iirc you can change InstanceName? Worth a shot. Did not work and scale does not seem to work either, strangely enough. Maybe I'm just doing it wrong. Updated version. Attachment: 
			
				  
				Floater.txt [868 Bytes]
			
			Downloaded 209 times
		
		
	 Attachment: 
			
				  
				Fly.txt [2.1 KiB]
			
			Downloaded 207 times
		
		
	  
					
  
			 | 
		
		
			| Mon Apr 05, 2010 11:03 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Grif 
				REAL AMERICAN HERO 
				
					 Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						PhantomAGN wrote: Also, it's GoldValue, not GoldCost. Nope. The lua property is Goldcost, specifically, not GoldValue, despite what the .ini property is labeled. Duh, try "Goldcost" (without capitalizing cost!) in both scripts.  
					
  
			 | 
		
		
			| Mon Apr 05, 2010 11:26 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Duh102 
				happy carebear mom 
				
					 Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						I've found there's something wrong in getting the actor, I put the printing of the Goldcost before changing it and it cannot find it. Hm. I don't see how it could be failing though... For quick reference, here is the pertinent sections of floater.lua. Code: self.parent = nil;        --Find out who shot the weapon by finding the closest actor within 50 pixels.    local curdist = 500;    for actor in MovableMan.Actors do       local avgx = actor.Pos.X - self.Pos.X;       local avgy = actor.Pos.Y - self.Pos.Y;       local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);       if dist < curdist then          curdist = dist;          self.parent = actor;       end    end        if MovableMan:IsActor(self.parent) then       print("" .. self.parent.Goldcost);       if not (self.parent.Goldcost == 1337) then  
					
  
			 | 
		
		
			| Mon Apr 05, 2010 11:46 pm | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Grif 
				REAL AMERICAN HERO 
				
					 Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						Okay, I might be wrong, try GoldCost with a capital C. 
					
  
			 | 
		
		
			| Tue Apr 06, 2010 12:11 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Duh102 
				happy carebear mom 
				
					 Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						That's readonly, tried that. 
					
  
			 | 
		
		
			| Tue Apr 06, 2010 1:08 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CrazyMLC 
				
				
					 Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						Fly.lua: Code:       if self.Scale == 1.01 then          print "Flying!"; ------problem          local ownController = self:GetController();          if not(self:IsDead()) then ------problem             if self.AngularVel > 0 or self.AngularVel < 0 then ------problem? Code:       if self.Scale == 1.01 then          print("Flying!");          local ownController = self:GetController();          if not(self:IsDead() == true) then             if self.AngularVel ~= 0 then  
					
							
  
							
    							Last edited by CrazyMLC on Tue Apr 06, 2010 3:17 am, edited 1 time in total. 
    						 
						
  
			 | 
		
		
			| Tue Apr 06, 2010 3:13 am | 
			
				
					 
					
					 
				    
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 TheLastBanana 
				DRL Developer 
				
					 Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						Actually, that second one is fine as far as I can tell.  If anything, you've made it worse - wouldn't this be easier? Code:       if self.Scale == 1.01 then          print("Flying!");          local ownController = self:GetController();          if (self:IsDead() == false) then             if self.AngularVel > 0 or self.AngularVel < 0 then  
					
  
			 | 
		
		
			| Tue Apr 06, 2010 3:17 am | 
			
				
					 
					
					 
				    
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Duh102 
				happy carebear mom 
				
					 Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						That might be a bit nicer, yes. I will correct and see if it fixes anything. EDIT: Hm, nope, no fixing. I'm still wondering if it's grabbing the actor correctly, perhaps I'll add in a print for the ClassName. EDIT2: Nope, it's getting an AHuman alright. EDIT3: Oh yeah, here's the current state of the script. Attachment: 
			
				  
				Floater.txt [911 Bytes]
			
			Downloaded 212 times
		
		
	 Attachment: 
			
				  
				Fly.txt [2.11 KiB]
			
			Downloaded 217 times
		
		
	  
					
  
			 | 
		
		
			| Tue Apr 06, 2010 3:18 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CrazyMLC 
				
				
					 Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						Does this work?
  ownController:IsState(Controller.HOLD_LEFT) -> UInputMan:KeyPressed(82) == true 
					
						
  
						Attachments: 
						
						
			
				  
				Fly.txt [1.94 KiB]
			
			Downloaded 268 times
		
		
	 
						
						 
					
			 | 
		
		
			| Tue Apr 06, 2010 3:38 am | 
			
				
					 
					
					 
				    
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Duh102 
				happy carebear mom 
				
					 Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						That shouldn't make a difference, it's not printing the "Flying!" thing. 
					
  
			 | 
		
		
			| Tue Apr 06, 2010 3:43 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 CrazyMLC 
				
				
					 Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						D'oh.
  if self.timer:IsPastSimMS(50) then ------> if self.timer:IsPastSimMS(50) == true then 
					
  
			 | 
		
		
			| Tue Apr 06, 2010 3:46 am | 
			
				
					 
					
					 
				    
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 TheLastBanana 
				DRL Developer 
				
					 Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						MLC, you don't have to waste your time doing that.  It's not actually necessary.  A lot of my scripts include it purely out of habit, but either way it's just going to return true. 
					
  
			 | 
		
		
			| Tue Apr 06, 2010 3:48 am | 
			
				
					 
					
					 
				    
			 | 
    	
		
	
	
		  | 
	
	
			| 
				
				 Duh102 
				happy carebear mom 
				
					 Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
				 
				 
			 | 
			
				
				  Re: Toggleable hover code  
					
						Same thing, it returns a boolean so it doesn't matter. Ninja'd. I just tried removing the check for the toggle variable and it works fine without, so that's the problem. The toggle variable is for some reason not being set, even though it's saying it's being set and the target is an AHuman. 
					
  
			 | 
		
		
			| Tue Apr 06, 2010 3:49 am | 
			
				
					 
					
					 
				  
			 | 
    	
		
	
	
		  | 
	
	
	
		 |