Script failing in old versions of Blender

Hi

I’m having trouble trying to get ray sensors and object actuators to work in 2.37a.
https://blenderartists.org/forum/viewtopic.php?t=48356

So I thought maybe there is a bug with ray sensors and I load the scene into 2.36. I had to comment out some of the code (see below) and now my ray sensors work.

The code that I had to comment out is really simple and that is what is puzzling me. I have objects in my scene with various properties attached to them. One of the properties is a simple counter. On one object it might be used to initialise some default variables and actuators.


if own.first_run ==1:
  high_score = 0
  up_key = cont.getSensor('up_sens')
  own.first_run = 0

In Blender 2.37 this code worked. In 2.36 unless

own.first_run = 0

is commented out it refuses to run giving errors such as

NameError: name ‘invader_count’ is not defined

Maybe if someone can explain these code errors in 2.36, that might lead me to solve my ray sensor problem in 2.37a?

thanks for reading this!

%| Ok… there’s nothing wrong with the code at all.

I’ve had code similar to this run on 2.36 with no problem.

I’ve tried the exact code you have with a cube as default setup calling the script with the necessary properties and such.

:expressionless: Please can you just provide a .blend cause that snippet of code is too vague on what your problem might be… Then again the NameError might suggest something…, but can’t be too sure what it is without the .blend.

Jason Lin

Hey Jason

The code for whole program is a bit of a mess and it includes textures and very large .wav files. I’m relunctant to post it.

However thank you very much for testing that snippet of code. It means whatever problem I have I can eliminate that section of code.

cheers mate :smiley: