I need a script [new question: post #9]

Ok, it’s me again, and I’m stuck in python. I need some help with getLocations (or getPosition?)

Anyway this is the basis of what I need (some commands may be wrong as I’m not actually testing this script)

I need to get some objects, can it import objects from different layers? Like this

getCurrentScene (then import objects: A, B, C)

droplocation = getLocation of when A collides with B

then addObject C and setPosition to droplocation

If anyone could write up a script that does this it would be greatly appreciated. I could use the FPS template but I want some explanations as to how they did it.

I’m trying to learn, and for me it’s easier to take a premade script and dissect it, then to read a tutorial.

Thanks in advance!

Hey Killer

Here is a start of it,

When the two cubes collide, a sphere is added at the position of one of the cubes,
(euh … it gets kind a stuck in the cube though :eyebrowlift:)

If this is a bit what you are looking for, than I will pollish the script and add some more comment to it for learning purpose).

Greetings to you

Jbal

I’m not a complete noob in py, so I was able to dissect it. Many thanks. Your name is in the credits for my new rain demo check it out in my GeFX thread

Glad I could help.

JBal

Did you check out the my rain?

I just did, the water looks very cool, I just was looking how you made that.
I also shaw you pollished up my script; I can see you realy understand Python for GE.

For the ripples I would suggest adding a few objects of ever growing ripples one after the other, to simulate growing ripples. Might be even cooler than it looks already.

Oh euh, I have to watch it more closely, but are there two or more ripples added for each cube hitting the water?

JBal

I saw that, do you have any suggestions why?

And yes, as I said I know python, but am not good enough to write a script from scratch.

I learn from dissecting scripts.

I wrote a tutorial if you check my GeFX thread for animated water. I made all the textures. Go to Blender Resources | to view my Kuality Texture Library.

Thanks again!

I shal do so,

I like solving basic problems in Blender GE so if you got more of this little puzzles just ask.

Greetings to you

Jbal

I shall do so,

adn euh,
I like solving basic problems in Blender GE so if you got more of this little puzzles just ask.
By the way I like the way you ask your question; you make very clear what you would like the script to do.

Greetings to you

Jbal

Since I know basic python I can use real modules like

they I want to getLocation()

that sorta thing, I think in theory, not syntax.

There should be a language that is like

get position if the object collides with the ground
THEN
set position of this object when the object collides with the ground

that would rock.

EDIT:: do you have a solution as to why 2 objects are added at a time? the cube is deleting as soon as is collides…

Change the script to:
cont = GameLogic.getCurrentController()
own = cont.getOwner()
# Find the collisionsensor
colsens = cont.getSensor(“CollisionSensor”)

if colsens.isPositive() :hi = position = own.getPosition()X = position[0]Y = position[1]Z = position[2]GameScene = GameLogic.getCurrentScene()objList = GameScene.getObjectList()Empty = objList[“OBEmpty”]# Set position of rain drop, and add rippleEmpty.setPosition( [X,Y,Z] )AddObject = cont.getActuator(“AddObject”)AddObject.setObject( “ripple” )AddObject.setTime(30)AddObject.instantAddObject()I think this will prevent the second ripple to apear.

Jbal

I’ll test this out in a minute

Oh, you could then add:

own.setVisible(0)

so the drops will be invissible after hitting the water.

(I’dd like them deleted, but don’t know how to do that yet).

Jbal

My cubes get deleted right after hitting the plane. I have an end object on the drops when they collide.

I downloaded your .blend-file, used it with Blender 2.46 and I clearly see cubes falling thrue the water; and not dissapearing.
I wonder do I have the latest version of your .Blend-file. I will download again when I’m home (at a break at work now).

JBal

Dowloaded it again, result is the same so …

Whats wrong?

Jbal

Just delete the ‘rain’ on collision. Your blend file doesn’t do this.

col —> python —> edit object
---------> and -------> Edit object > end object

Hey Killer this will work, just added it to your demo ( you probebly somehow deleted an actuator while changing your .blend; atleast this is what happend to me a few times???)

By the way:
Euh, what did you mean by:

they I want to getLocation()

that sorta thing, I think in theory, not syntax.

There should be a language that is like

get position if the object collides with the ground
THEN
set position of this object when the object collides with the ground

that would rock.

If this is a question, I do not quit understand what you like.

Keep up the good work you are doing.

Jbal

I just said it would be awesome if there was a language that worked like that.

Ok, so now question at all
(sorry sometimes I don’t quite understand English, I am obviously not a native speaker).

About the language:
When one chooses the names of procedures/ functions/ sensors/ actuators and so on
carefully, mostly big parts of ones code will almost read as plain english.
If not, try to choose other names
(And offcourse: add comments (a lot off them) to your code so you can still understand it after a significant period)

BTW: How is the water going on?

Greetings to you

Jbal