top of page

Object Names

Definition

Each object in 3D Basic must have a unique name.
The name is used to identify the object and associate it with its attributes (properties).

 

Without a name, the system cannot determine which object should be affected.

-----------------------------------------------------------------------------------------------

Syntax

objectName.attribute = value

objectName.attribute1.attribute2 = value

 

  • objectName identifies the object

  • attribute specifies which property is being modified

  • value is the value assigned

-----------------------------------------------------------------------------------------------

Rules

  • The object name must always come first

  • The attribute is specified after the object name

  • Incorrect order will result in an invalid expression

-----------------------------------------------------------------------------------------------

Allowed characters in object names
Object names may only contain:

  • Letters: A–Z

  • Numbers: 0–9

-----------------------------------------------------------------------------------------------

Examples

Correct:

boxSven.size = (2,2,2)

 

Incorrect:

SvenBox.size = (2,2,2)

In the incorrect example, 3D Basic cannot determine the object type correctly.

-----------------------------------------------------------------------------------------------

Naming in Examples

This manual often uses simple object names such as:

 

box1

box2

box3

This is done to keep the examples short and easy to follow.

-----------------------------------------------------------------------------------------------

Recommendation

In your own programs, you should use more descriptive names, for example:

 

boxPlayer

boxWall

boxEnemy

 

Descriptive names make your code easier to understand, especially in larger programs with many objects.

-----------------------------------------------------------------------------------------------

Why is this important?

As the number of objects increases, it becomes difficult to understand what each object represents if all names are generic.

 

A clear name acts as built-in documentation and reduces the need for additional comments.

-----------------------------------------------------------------------------------------------

Examples

Less clear:

 

box1.move = (0,0,0)

box2.move = (10,0,0)

 

Clearer:

boxSpelare.move = (0,0,0)

boxSvart.move = (10,0,0)

 

Tips

Choose names that describe:

  • what the object is

  • what function it has

-----------------------------------------------------------------------------------------------

Explanation (simple analogy)

This can be compared to a zoo.

 

There may be several tigers, but each tiger has its own name, such as Sven or Anna. To refer to a specific tiger, you need to use its name.

 

In the same way, each object in 3D Basic needs a unique name so that the correct attributes are applied to the correct object.

bottom of page