Events in Python

For questions about using Classic.

Post » Sat Sep 11, 2010 11:54 pm

How do events work in the Python scripting?

Let's say I have two types of objects, a Player and a Statue, and I put a script on them that fires when they collide.

If I have two statues, how do I tell which one I just collided with?

[code:z77wrael]for s in Statue:
if Player.Overlaps(s):
.......
[/code:z77wrael]

This method doesn't seem to work as Overlaps never returns true, regardless of whether or not the two objects are actually overlapping.

Then there's the OnCollide method in Python. What does this do? Is there a way to attach a callback to fire when this event fires?
B
1
G
2
Posts: 8
Reputation: 641

Post » Mon Sep 13, 2010 8:37 pm

I finally found the answer here after much searching, in Construct-land this behavior is referred to as "picking".

In the Python script editor, when you have a script that is a response to an event, then the objects involved in that event are part of the SOL object.

In this case on a collision between the Player and a Statue

SOL.Player is the player involved
SOL.Statue is the statue involved
B
1
G
2
Posts: 8
Reputation: 641


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests