prob w/ OOP and importing
Author |
Message |
mirhagk
|
Posted: Wed Dec 16, 2009 9:55 am Post subject: prob w/ OOP and importing |
|
|
What is it you are trying to achieve?
To make a game with object oriented weapons
What is the problem you are having?
I have 3 types of program, the main program, the weapon class and the individual weapons (that could be expanded to 100's).
I need to have all three in my game (I'd prefer not to just include the individual weapons in the main program)
The only thing is that the weapons inherit the weapon class, and turing won't let me import that into it
I can't put more than one class into a file that is to be imported
Describe what you have tried to solve this problem
Almost every combination of include, import w/e. If I have to I'll just include the weapons in the main file but I don't want to if I don't have to.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
the three programs are like the following:
main program:
Turing: |
import "weapons.tu","cannon.tu"
|
weapons.tu
Turing: |
unit
class WEAPONS
var name:string
%%%other code doesn't really matter
deferred proc draw
end WEAPONS
|
cannon.tu
Turing: |
unit
class CANNON
import "weapons.tu"
inherit WEAPONS
body draw
%%doesnt matter
end draw
end CANNON
|
Please specify what version of Turing you are using
4.1 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Superskull85
|
Posted: Wed Dec 16, 2009 10:14 am Post subject: Re: prob w/ OOP and importing |
|
|
Change your import to:
Turing: | import WEAPONS in "weapons.tu", CANNON in "cannon.tu" |
Or if your class name matches the file name, and the two files are in the same directory:
Turing: | import WEAPONS, CANNON |
Also unless you are creating a specific WEAPONS object within your CANNON you do not need to import and inherit the WEAPONS class into your CANNON class, just inherit it. |
|
|
|
|
 |
mirhagk
|
Posted: Wed Dec 16, 2009 11:28 am Post subject: RE:prob w/ OOP and importing |
|
|
alright i figured out the problem, i had put the cannon object into a subfolder, and it messed up (even though it returned an error saying it couldn't find it the weapons class in the main folder)
is there a way to put it in a folder?? |
|
|
|
|
 |
Superskull85
|
Posted: Wed Dec 16, 2009 2:13 pm Post subject: Re: prob w/ OOP and importing |
|
|
Sure.
Relative paths:
Turing: | import ClassName in "Folder Name/ClassName.tu" [, ClassName2 in "Folder Name/ClassName2.tu"] |
Absolute paths:
Turing: | import ClassName in "C:/Folder Name/ClassName.tu" [, ClassName2 in "C:/Folder Name/ClassName2.tu"] |
You can do the same thing when inheriting classes as well.
Relative paths:
Turing: | inherit ClassName in "Folder Name/ClassName.tu" [, ClassName2 in "Folder Name/ClassName2.tu"] |
Absolute paths:
Turing: | inherit ClassName in "C:/Folder Name/ClassName.tu" [, ClassName2 in "C:/Folder Name/ClassName2.tu"] |
|
|
|
|
|
 |
mirhagk
|
Posted: Wed Dec 16, 2009 4:17 pm Post subject: RE:prob w/ OOP and importing |
|
|
no try to do it with those three sample programs.
weapons.tu and cannon.tu are in a folder called weapons. thats what I was doing and it kept giving me an error when I tried to inherit it |
|
|
|
|
 |
|
|