| View previous topic :: View next topic   | 
	
    
	
	 | 
		| Author | 
		Message | 
	
	
		
        
          Wowbagger 
         
        Lieutenant JG 
         
   
         
        Age: 20 
        Zodiac:   
        Joined: 03 Apr 2005 
        Posts: 270 
        Location: Minne-soh-tah 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 I know, it's a long shot, given how messily the App file creates things.  Still, it's worth asking: has anyone figured out a way to create a class that inherits from a class in App? 
              | 
         
        
           _________________
  
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          Defiant 
         
        Free "as in Free Speech" Engineer Admiral 
         
   
         
        Age: 26 
        Zodiac:   
        Joined: 27 Jan 2003 
        Posts: 2337 
        Location: Hamburg, Germany 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 Have not tried, but shouldn't be a problem, why? 
              | 
         
        
           _________________ BC Modification Kobayashi Maru
 
 
--
 
 Whenever you find that you are on the side of the majority, it is time to reform.
 
-- Mark Twain
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          MLeo 
         
        Fleet Admiral 
         
  
         
        Age: 22 
        Zodiac:   
        Joined: 26 Nov 2002 
        Posts: 11439 
        Location: Netherlands 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
 | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          Wowbagger 
         
        Lieutenant JG 
         
   
         
        Age: 20 
        Zodiac:   
        Joined: 03 Apr 2005 
        Posts: 270 
        Location: Minne-soh-tah 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 
  	  | Defiant wrote: | 	 		  | Have not tried, but shouldn't be a problem, why? | 	  
 
 
Well, say you're trying to create a new class, called MyShipClass, which inherits from App.ShipClass.  The class itself is written easily enough, but then how do you actually create the ships in the game?
 
 
According to loadspacehelper, you call App.ShipClass_Create().  So, instead, you make a function called MyShipClass_Create().
 
 
Unfortunately, here is the App.ShipClass_Create() function:
 
 
 	  | Code: | 	 		  def ShipClass_Create(*args, **kwargs):
 
 
    val = apply(Appc.ShipClass_Create,args,kwargs)
 
 
    if val: val = ShipClassPtr(val)
 
 
    return val | 	  
 
 
Certainly, you can make a class called MyShipClassPtr, so that call can go through, but how can you create an Appc.MyShipClass_Create()?  As far as I can tell, you can't, and, as far as I can tell, the only way to create a game object is by going through Appc.  Hence my problem.
 
 
If I've overlooked something, I'd be very pleased.  Thanks, guys. 
             | 
         
        
           _________________
  
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          MLeo 
         
        Fleet Admiral 
         
  
         
        Age: 22 
        Zodiac:   
        Joined: 26 Nov 2002 
        Posts: 11439 
        Location: Netherlands 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
 | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          Wowbagger 
         
        Lieutenant JG 
         
   
         
        Age: 20 
        Zodiac:   
        Joined: 03 Apr 2005 
        Posts: 270 
        Location: Minne-soh-tah 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 Or I'm still a n00b programmer who shouldn't mess around with what he doesn't understand.   
 
 
It's okay; I got ArmadaShipClass(App.ShipClass) working.  The problem was not in creating the objects.  In fact, the objects were creating fine.  I was using the MissionLib GetPlayer() function to *get* the objects, though, and the Appc function was--I think--grabbing the parent class instance instead of the child's.  In any case, once I wrote my own GetPlayer() function, everything cleared up, and I was free to add and overwrite methods as I saw fit.
 
 
Thanks. 
              | 
         
        
           _________________
  
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          Defiant 
         
        Free "as in Free Speech" Engineer Admiral 
         
   
         
        Age: 26 
        Zodiac:   
        Joined: 27 Jan 2003 
        Posts: 2337 
        Location: Hamburg, Germany 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 uhm, sorry, I still do not get what you are trying todo. 
              | 
         
        
           _________________ BC Modification Kobayashi Maru
 
 
--
 
 Whenever you find that you are on the side of the majority, it is time to reform.
 
-- Mark Twain
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          Sim Rex 
         
        Moderator 
         
   
         
        Age: 26 
        Zodiac:   
        Joined: 11 Apr 2002 
        Posts: 1714 
         
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 
  	  | Defiant wrote: | 	 		  | uhm, sorry, I still do not get what you are trying todo. | 	  
 
 
As I understand it, he's trying to override the App ship class so that he can add custom functions to it for whatever nefarious purpose he requires...  There are probably other ways to do whatever he's trying to do, but if this works, more power to him.  I can see there possibly being problems later on, if he plans on storing data in his custom ship class, though... 
             | 
         
        
           _________________ "Could it be it's the end of our world?  All the things that we cherish and love
 
Nothing left but to face this all on my own, cause I am the chosen one!"
 
-- The Fallen Angel - Iron Maiden(Smith/Harris)
 
 
For beginner scripters - The BCU Mission Scripting Lessons
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          Defiant 
         
        Free "as in Free Speech" Engineer Admiral 
         
   
         
        Age: 26 
        Zodiac:   
        Joined: 27 Jan 2003 
        Posts: 2337 
        Location: Hamburg, Germany 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 uhm ok.
 
How about App.ShipClass.DoSomethingCoolFunction = MyFunction?
 
 
Else I believe a 'has a' version would be cleaner as the 'is a' relation here. 
              | 
         
        
           _________________ BC Modification Kobayashi Maru
 
 
--
 
 Whenever you find that you are on the side of the majority, it is time to reform.
 
-- Mark Twain
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          MLeo 
         
        Fleet Admiral 
         
  
         
        Age: 22 
        Zodiac:   
        Joined: 26 Nov 2002 
        Posts: 11439 
        Location: Netherlands 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 I have to agree with SimRex here.
 
 
The problem I forsee is the following:
 
You create a new ArmadaShipClass object, do something with it, and wait for an event to happen.
 
 
When that event happens you happily get the ArmadaShipClass object, but then. Since the classes in App.py are nothing but shadows of the real thing, your actions you did before won't be present in your just obtained ArmadaShipClass object.
 
 
To counter that effect, you would basicly create another <Insert your Foundation Technologies-like script>. 
              | 
         
        
           _________________
  
 
How to beat the Black Screen Of Death and Script problems Also handles Console/Screen/Error report/dump.
 
BC Technical FAQ [Last updated 26/12/2005]
 
"Trust me, I'm a con artist" - Moist von Lipwig, "Going Postal, Discworld"
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		
        
          Wowbagger 
         
        Lieutenant JG 
         
   
         
        Age: 20 
        Zodiac:   
        Joined: 03 Apr 2005 
        Posts: 270 
        Location: Minne-soh-tah 
	  
              
              
             | 
         
        
           
         | 
         
       
       
       
       | 
		
        
          
          | 
              
  |  
        
          
  | 
         
        
          
  | 
         
        
          | 
 All sound advice, which I will bear in mind when my code blows up on me (as it ineveitably will).
 
 
Looking at App as a "shadow" has indeed helped, at least in understanding what I'm reading.
 
 
I'll be out of town for a couple of days, experimenting with this. 
              | 
         
        
           _________________
  
  | 
         
		  | 
	
	
		| Back to top | 
		 | 
	
    
		  | 
    
	
		 |