Probelm With Codes

Hello, I am making a Minecraft-Clone game caled BuildWorld, and the game uses MinePackage. I have some code from the wiki for a building function, and here it is.

public class MyCoolNewDecoration : IDecoration
{
private readonly WorldData m_WorldData;

public MyCoolNewDecoration(WorldData worldData)
{
m_WorldData = worldData;
}

public bool Decorate(int blockX, int blockY, int blockZ, Random random)
{
if (IsAValidLocationforDecoration(blockX, blockY, blockZ, random))
{
CreateDecorationAt(blockX, blockY, blockZ, random);
return true;
}

return false;
}

private void CreateDecorationAt(int blockX, int blockY, int blockZ, Random random)
{
m_WorldData.SetBlockType(blockX, blockY, blockZ, BlockType.Stone);
}

private bool IsAValidLocationforDecoration(int blockX, int blockY, int blockZ, Random random)
{
if (random.RandomRange(1, 100) < 90)
{
return false;
}

return m_WorldData.GetBlock(blockX, blockY, blockZ).Type == BlockType.Air;
}
}

The thing keeps saying The type or namespace “IDecorator” could not be found. I badly need someone to help with this code, so I can implement a building function into the game. IDecorator is another script I have. Anyone help? :slight_smile:

The script IDecorator belongs a certain namespace you need to import using the keyword “using ;”. Open up the file IDecorator.cs and look for the namespace declaration.

Oh. I probably have to learn what that is. I think I wasted all my time learning HTML 5. Can you show me what is a Namespace declaration in C#?

http://lmgtfy.com/?q=c%23+namespace

namespace Weapons
{
    public class Shotgun : AbstractWeapon {
    }
}

This would be an example. In order to use the class Shotgun in another script you would have to write

using Weapons;

to tell the compiler that you want to use the namespace Weapons in that script file.

Here is the code for IDecoration

using System;

public interface IDecoration
{
void Decorate(int blockX, int blockY, int blockZ, Random random);}

Okay, so this is no namespace problem. In which folders did you put MyCoolNewDecoration and IDecoration respectively?

Go to assets, then Scripts, then WorldDecorations. Both of these are in the same folder.

Any help? Tried to implement this yesteray, which caused a massive bug (The terain refused to generate)

Any help?