python crash

For questions about using Classic.

Post » Wed Aug 25, 2010 8:58 am

when ever I destroy a sprite that name is in a python code it crash.

let's say i put this code in

[code:bkc3iobl]if Sprite.Value('av')<= 995:
Sprite.SetValue('av',Sprite.Value('av')+5)[/code:bkc3iobl]

and a event i like
+ Sprite: Value 'av' Equal to 1000
-> Sprite: Destroy
would crash.
B
21
S
4
G
4
Posts: 280
Reputation: 2,934

Post » Wed Aug 25, 2010 10:46 am

After all the Sprite objects are destroyed python will give an error because there is no object to access.

Change the code to check if there are objects to access:
[code:pgglqjf1]if len(Sprite) > 0:
if Sprite.Value('av')<= 995:
Sprite.SetValue('av',Sprite.Value('av')+5)[/code:pgglqjf1]
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Post » Fri Aug 27, 2010 7:33 pm

Thanks R0J0hound. I tried to use sprite.count but that doesn't work yet.
B
21
S
4
G
4
Posts: 280
Reputation: 2,934


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests