Problem with importing a script

Hey there!

I have the following code to import a python-script from my harddrive into a script-behaviour.

script_uri = "C:/Users/blablabla/"
file = open(script_uri,"r")
  scriptContent =
  print "Error reading"
print "ONE"
print "TWO"
script_r.Script = scriptContent
print "THREE"
script_l.Script = scriptContent
print "FOUR"

Works fine for script_r.Script, but i need the same script in another component aswell (script_l) and that doesn’t work.

I do not get any errors, but the simulation stops before print “THREE” and after I click play a second time my code restarts skipping the function this time because I also create some behaviours in this function and I put in an if-statement so it wont run a second time. But why does my code stop at this point?

Best regards

I guess it is only possible to change the content of a script when the simulation isn’t running and also not started.

I think when changing the content of script_r, the simulation will be stopped. Thats why the print of THREE won’t appear.

Is there any reason why you are changing a python script during the simulation run? I assume it is not possible.


Hey Ralle,

well i want the intelligence of the robot and other connected components to be created through my conveyor, so i can change robots without having to prepare them manually. The script only gets written once a new robot gets connected to my conveyor, after that it skips this function.

I guessed so too after a view tries. VC probably tries to execute this imported script but it’s all signal based, so nothing is happening.

I think i’ll have to create a button to write the scripts then.

Thanks Ralle!