Learning Experience - Setting Actors

Hello,
I’m pretty new to using Python.
I looked over other scripts to find how i can place an actor down,
But i just cannot figure it out.
Please help?

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.actor import Actor
class World(DirectObject):
def init(self):
self.blaze=Actor.Actor(‘blaze-model’,{‘walk’:‘panda-walk4’})
self.blaze.reparentTo(render)
self.blaze.setScale(.2)
self.blaze.setPos(0,0,0)
scene=loader.loadModel(“models/environment”)
scene.reparentTo(render)
scene.setScale(0.025,0.025,0.025)
scene.setPos(0,0,0)
run()

Error:
**** End of process output ****
File “maincourse2.py”, line 3
self.blaze=Actor.Actor(‘blaze-model’,{‘walk’:‘panda-walk4’})
^
IndentationError: unexpected indent

**** End of process output ****
File “maincourse2.py”, line 5
def init(self):
^
IndentationError: expected an indented block

**** End of process output ****
File “maincourse2.py”, line 5
def init(self):
^
IndentationError: expected an indented block

**** End of process output ****

I dont understand what i’m doing wrong,
And i’d really appreciate critisism for a learning experience.

In Python, indentation is IMPORTANT.

import direct.directbase.DirectStart 
from direct.showbase.DirectObject import DirectObject 
from direct.actor import Actor 

class World(DirectObject): 
  def __init__(self): 
      self.blaze=Actor.Actor('blaze-model',{'walk':'panda-walk4'}) 
      self.blaze.reparentTo(render) 
      self.blaze.setScale(.2) 
      self.blaze.setPos(0,0,0) 
      scene=loader.loadModel("models/environment") 
      scene.reparentTo(render) 
      scene.setScale(0.025,0.025,0.025) 
      scene.setPos(0,0,0) 

run()

Hi, I did this and I no longer have any errors, so thank you!
However,
When I run the file, the panda screen opens, and goes gray.
How can I fix this as well? Using the same code listed above.

You haven’t instantiated your World class.
Call World() before the run() line.

Error:

File “maincourse2.py”, line 16
Call World()
^
SyntaxError: invalid syntax

**** End of process output ****

“Call” is the instruction from me to you.

Can you be a little more specific? I added Call World() and nothing different happens other than a new error.
Therefore I followed them and failed.
I’m still having troubles finding my issue even online.

Furthermore explanation would be much appreciated.
Thanks

The instruction from me to you is :
“call World()”

So, the instruction from you to python should be :
“World()”

PS:
ignore the quotation marks.

@Luna:
“Calling” something means executing it by writing it with “()” after the name. Thus if you have a function called “doSomething”, you call it writing “doSomething()”.

The same applies to classes, where, by calling it, you create a new instance of the class.

I suggest you read a python tutorial or a book. Everybody does in the beginning.

Hi,

I recommend these:
A Byte of Python
Invent Your Own Computer Games with Python

Regards,
Leo

There is an easy-to-follow video course with quizzes at http://www.udacity.com/course/cs101.

Create a constructive learning environment. By this the authors mean: mutual respect, shared vision, two-way communication flow, group reflection, and a preference for support rather than blame. These aspects in short mean giving education a status within the department.
Know your stuff; but even more important admit when you don’t. This improves the learning from role models. These role models should know their competence and should know their limits.
Tailor each educational encounter to the individual learner; respect and build on prior knowledge. Especially this last aspect is often difficult due to the many different teachers.
Actively engage the learner. To my opinion this one is very important. It’s accomplished when residents take their training in their own hands and are involved in educating each other, the supervisors and even medical students