BCU main page Bridge Commander Universe
...welcome to the new world.
 
 FAQFAQ  RanksRanks  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups  Staff SiteStaff Site    RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inheritance from App

 
Post new topic   Reply to topic    Bridge Commander Universe Forum Index -> BC Scripting
View previous topic :: View next topic  
Author Message

Wowbagger

Lieutenant JG
Lieutenant JG


Age: 20
Zodiac: Taurus
Joined: 03 Apr 2005
Posts: 270
Location: Minne-soh-tah
Offline

 

 



Reply with quote

Post Posted: 07-02-2006 02:07 AM Post subject: Inheritance from App

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
View user's profile Send private message

Defiant

Free "as in Free Speech" Engineer
Admiral
Admiral


Age: 26
Zodiac: Capricorn
Joined: 27 Jan 2003
Posts: 2337
Location: Hamburg, Germany
Offline

 

 



Reply with quote

Post Posted: 07-02-2006 06:29 AM Post subject:

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
View user's profile Send private message Send e-mail Visit poster's website

MLeo

Fleet Admiral
Fleet Admiral


Age: 22
Zodiac: Aquarius
Joined: 26 Nov 2002
Posts: 11439
Location: Netherlands
Offline

 

 



Reply with quote

Post Posted: 07-02-2006 09:06 AM Post subject:

Shouldn't be impossible, though be carefull when you do.
For one thing, some functions can call exported functions from the exe side of things.


_________________

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
View user's profile Send private message Send e-mail MSN Messenger

Wowbagger

Lieutenant JG
Lieutenant JG


Age: 20
Zodiac: Taurus
Joined: 03 Apr 2005
Posts: 270
Location: Minne-soh-tah
Offline

 

 



Reply with quote

Post Posted: 07-02-2006 05:28 PM Post subject:

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
View user's profile Send private message

MLeo

Fleet Admiral
Fleet Admiral


Age: 22
Zodiac: Aquarius
Joined: 26 Nov 2002
Posts: 11439
Location: Netherlands
Offline

 

 



Reply with quote

Post Posted: 07-02-2006 05:53 PM Post subject:

I think you got your brain waves wrong, don't think of the classes in App.py as the actual classes, but as shadows of the actual classes, or portals to the real objects.

I got a question for you, what functionality are you trying to specialize?


_________________

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
View user's profile Send private message Send e-mail MSN Messenger

Wowbagger

Lieutenant JG
Lieutenant JG


Age: 20
Zodiac: Taurus
Joined: 03 Apr 2005
Posts: 270
Location: Minne-soh-tah
Offline

 

 



Reply with quote

Post Posted: 07-02-2006 06:46 PM Post subject:

Or I'm still a n00b programmer who shouldn't mess around with what he doesn't understand. Grin

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
View user's profile Send private message

Defiant

Free "as in Free Speech" Engineer
Admiral
Admiral


Age: 26
Zodiac: Capricorn
Joined: 27 Jan 2003
Posts: 2337
Location: Hamburg, Germany
Offline

 

 



Reply with quote

Post Posted: 07-02-2006 07:46 PM Post subject:

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
View user's profile Send private message Send e-mail Visit poster's website

Sim Rex

Moderator
Moderator


Age: 26
Zodiac: Capricorn
Joined: 11 Apr 2002
Posts: 1714

Offline

 

 



Reply with quote

Post Posted: 07-02-2006 10:03 PM Post subject:

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
View user's profile Send private message Send e-mail

Defiant

Free "as in Free Speech" Engineer
Admiral
Admiral


Age: 26
Zodiac: Capricorn
Joined: 27 Jan 2003
Posts: 2337
Location: Hamburg, Germany
Offline

 

 



Reply with quote

Post Posted: 07-03-2006 03:27 AM Post subject:

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
View user's profile Send private message Send e-mail Visit poster's website

MLeo

Fleet Admiral
Fleet Admiral


Age: 22
Zodiac: Aquarius
Joined: 26 Nov 2002
Posts: 11439
Location: Netherlands
Offline

 

 



Reply with quote

Post Posted: 07-03-2006 12:22 PM Post subject:

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
View user's profile Send private message Send e-mail MSN Messenger

Wowbagger

Lieutenant JG
Lieutenant JG


Age: 20
Zodiac: Taurus
Joined: 03 Apr 2005
Posts: 270
Location: Minne-soh-tah
Offline

 

 



Reply with quote

Post Posted: 07-03-2006 04:27 PM Post subject:

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic

All times are GMT

Page 1 of 1
   Bridge Commander Universe Forum Index -> BC Scripting
 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group
Bridge Commander Universe is a Nightsoft company. All rights reserved.