Error cs1514 expected

i get this error but i couldn't fix it ‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏...

You are making a class with a ; and no { }. This is how you are making the class:

   public class CamShake;

A class should be declared like:

   public class CamShake
   {
   }

I don’t know what you wanted to put inside it, but this is how you would do it by what I understand:

   public class CamShake : MonoBehaviour
   {
       public void CamShake()
       {
          //something.
       }
       public GameObject muzzleFlash, bulletHoleGraphic;
       public float camShakeMagnitude, camShakeDuration;
   }

I also changed the public void CamShake; to public void CamShake() {}. Classes and methods both use { }.

{ } are used to tell the computer what to do inside a certain function or class. And ; is used to tell the computer to execute that code. You don’t tell the computer to execute the method until it is called.

Declare a method:

    void Method1()
    {
        //do something
    }

Above, we aren’t actually telling the computer to do it, but we are telling the computer where to go when we call it.

Call the method:

    Method1();

Note: this won’t do anything unless you have the method declared somewhere else in the class.

Right now, there is no point for making a class unless you have a method inside. This is because you could save the variables in the other script. I guess you could keep the class to be more organized, but it isn’t needed.

You may have not meant to write class there. If you didn’t, comment what you were trying to do, and I will try my best to give you the correct keyword. Here is a list of the keywords.

C++ Error 1513-1514

Всем привет, я новичок как в Unity так и в C++.
Прошу вашей помощи, импортировал ассет на что Unity пожаловался на скрипт, многие ошибки устранил но вот две ошибки не получается, вот эти «error CS1514: { expected и error CS1513: } expected»
Вот сам скрипт:

Используется csharp

using UnityEngine;
using CharacterMotor;
public class CharacterMotor;
public class StepsHandlerExample : MonoBehaviour
{
    private CharacterMotor charMot;
    private Vector3 displacement;
    private float iniBackSpeed;
    private float iniForSpeed;
    private float iniSideSpeed;
    private Vector3 lastPos;
    private float slowBackSpeed;
    private float slowForSpeed;
    private float slowSideSpeed;
    public float slowWalkVolume = 0.1f;
    private bool onetime;
    public float normalWalkRate = 0.7f;
    public float slowWalkRate = 1.5f;

    private void Start()
    {
        lastPos = transform.position;
        charMot = GetComponent<CharacterMotor>();
        iniForSpeed = charMot.movement.maxForwardSpeed;
        iniBackSpeed = charMot.movement.maxBackwardsSpeed;
        iniSideSpeed = charMot.movement.maxSidewaysSpeed;

        slowBackSpeed = charMot.movement.maxBackwardsSpeed 6.0f;
        slowForSpeed = charMot.movement.maxForwardSpeed 7.0f;
        slowSideSpeed = charMot.movement.maxSidewaysSpeed 5.0f;

    }

    private void Update()
    {
        if (Input.GetKey(KeyCode.LeftShift))
        {
            GetComponent<AudioSource>().volume = slowWalkVolume;
            charMot.movement.maxForwardSpeed = slowForSpeed;
            charMot.movement.maxBackwardsSpeed = slowBackSpeed;
            charMot.movement.maxSidewaysSpeed = slowSideSpeed;
            if (onetime)
            {
                onetime = false;
                CancelInvoke(«NormalWalk»);
                InvokeRepeating(«NormalWalk», 0f, slowWalkRate);
            }

        }
        else
        {
            GetComponent<AudioSource>().volume = 1f;
            charMot.movement.maxForwardSpeed = iniForSpeed;
            charMot.movement.maxBackwardsSpeed = iniBackSpeed;
            charMot.movement.maxSidewaysSpeed = iniSideSpeed;
            if (!onetime)
            {
                onetime = true;
                CancelInvoke(«NormalWalk»);
                InvokeRepeating(«NormalWalk», 0f, normalWalkRate);
            }

         
        }
    }

    private void NormalWalk()
    {
        displacement = transform.position lastPos;
        lastPos = transform.position;
        if (!charMot.IsJumping())
        {
            if (displacement.magnitude > 0.01)
            {
                if (!GetComponent<AudioSource>().isPlaying)
                {
                    GetComponent<AudioSource>().Play();
                }
            }
        }
    }

    private void OnGUI()
    {
        GUI.Box(new Rect(Screen.width/12, Screen.height (Screen.height/4), Screen.width/1.1f, Screen.height/5),
                  «Hold Left Shift to walk slowly without noise! see the difference if you run behind the enemy!»);
    }
}

Заранее всем спасибо большое.

Shram
UNец
 
Сообщения: 5
Зарегистрирован: 04 мар 2019, 14:02

Re: C++ Error 1513-1514

Сообщение 1max1 04 мар 2019, 15:16

Как насчет сходить уроки по с# почитать, глядишь сможешь отличать его от c++. К тому же, если ты и дальше планируешь развиваться, то код писать нужно в нормальной среде типа Visual Studio, которая будет подчеркивать строки с ошибками.
Что по твоему должна делать эта строка в твоем коде?

Используется csharp

public class CharacterMotor;

Конечно же ты не знаешь, потому что код-то не твой, ты его от куда-то взял в надежде на чудо, а разбираться не захотел :((

Аватара пользователя
1max1
Адепт
 
Сообщения: 5285
Зарегистрирован: 28 июн 2017, 10:51

Re: C++ Error 1513-1514

Сообщение Friend123 04 мар 2019, 17:09

1max1, улыбнул )))))

Аватара пользователя
Friend123
Старожил
 
Сообщения: 701
Зарегистрирован: 26 фев 2012, 22:12
Откуда: Тверь
  • ICQ

Re: C++ Error 1513-1514

Сообщение Shram 04 мар 2019, 18:32

1max1 писал(а):Как насчет сходить уроки по с# почитать, глядишь сможешь отличать его от c++. К тому же, если ты и дальше планируешь развиваться, то код писать нужно в нормальной среде типа Visual Studio, которая будет подчеркивать строки с ошибками.
Что по твоему должна делать эта строка в твоем коде?

Используется csharp

public class CharacterMotor;

Конечно же ты не знаешь, потому что код-то не твой, ты его от куда-то взял в надежде на чудо, а разбираться не захотел :((

Конечно не мой умник, читай внимательно ! Написано же что был импортирован ассет и было около 6-и ошибок, они ссылались на «CharacterMotor»
а когда я кидаю другой скрипт «CharacterMotor» тогда появдяется другая ошибка, «The type or namespace name ‘ParticleAnimator’ could not be found (are you missing a using directive or an assembly reference?»
Затем пришел к этим единственным ошибкам.
Но я вижу здесь все злые.

Shram
UNец
 
Сообщения: 5
Зарегистрирован: 04 мар 2019, 14:02

Re: C++ Error 1513-1514

Сообщение Friend123 04 мар 2019, 18:37

Shram писал(а):Но я вижу здесь все злые.

Это не мы злые, это вы, простите, задаете вопросы уровня 1 курса универа по программированию

Вот, если выдает ошибку, то в самой ошибке всегда сказано что не так, они все типовые. Простое гугление даст ответ в 10 раз быстрее, чем писать на форуме.

P.S. Как-то я думал всегда, что форумы для обсуждения сложных проблем. Ошибался видать.

Аватара пользователя
Friend123
Старожил
 
Сообщения: 701
Зарегистрирован: 26 фев 2012, 22:12
Откуда: Тверь
  • ICQ

Re: C++ Error 1513-1514

Сообщение Shram 04 мар 2019, 18:47

Friend123 писал(а):

Shram писал(а):Но я вижу здесь все злые.

Это не мы злые, это вы, простите, задаете вопросы уровня 1 курса универа по программированию

Вот, если выдает ошибку, то в самой ошибке всегда сказано что не так, они все типовые. Простое гугление даст ответ в 10 раз быстрее, чем писать на форуме.

P.S. Как-то я думал всегда, что форумы для обсуждения сложных проблем. Ошибался видать.

P.S. а я думал почемучка для этого и была создана.

Ну хорошо, смотрите я создал новый проект импортировал ассет, на что он мне ответил ошибкой вот такую

«StepsHandlerExample.cs(5,13): error CS0246: The type or namespace name ‘CharacterMotor’ could not be found (are you missing a using directive or an assembly reference?»

И поверьте я пользовался «Google» проверил имя скрипта «CharacterMotor» совпадает, Google не чего не нашел.

Shram
UNец
 
Сообщения: 5
Зарегистрирован: 04 мар 2019, 14:02

Re: C++ Error 1513-1514

Сообщение 1max1 04 мар 2019, 19:40

Похоже автор твоего ассета забыл добавить скрипт CharacterMotor))

И поверьте я пользовался «Google» проверил имя скрипта «CharacterMotor» совпадает, Google не чего не нашел.

Что-то я тебе не верю)))

http://wiki.unity3d.com/index.php/CharacterMotor

Аватара пользователя
1max1
Адепт
 
Сообщения: 5285
Зарегистрирован: 28 июн 2017, 10:51

Re: C++ Error 1513-1514

Сообщение Shram 04 мар 2019, 19:57

1max1 писал(а):Похоже автор твоего ассета забыл добавить скрипт CharacterMotor))

И поверьте я пользовался «Google» проверил имя скрипта «CharacterMotor» совпадает, Google не чего не нашел.

Что-то я тебе не верю)))

http://wiki.unity3d.com/index.php/CharacterMotor

Этот скрипт я находил и добавлял, но все же спасибо, но теперь вылезли еще ошибки, суть их схожая

«The type or namespace name ‘ParticleAnimator’ could not be found (are you missing a using directive or an assembly reference?»

Теперь я понял что значит Не удалось найти ссылка на сборку, нет тупа скрипта, я ведь правельно все понял ? Значит уже два скрипта он забыл положить ?

Shram
UNец
 
Сообщения: 5
Зарегистрирован: 04 мар 2019, 14:02


Re: C++ Error 1513-1514

Сообщение Shram 04 мар 2019, 20:36

Ну да точно, ассет требует версию 4.6 теперь все понял.
Спасибо большое, вот теперь есть не большой как в скриптах так и в юнити.

Shram
UNец
 
Сообщения: 5
Зарегистрирован: 04 мар 2019, 14:02


Вернуться в Почемучка

Кто сейчас на конференции

Сейчас этот форум просматривают: Google [Bot] и гости: 31



  • #1

DocumentsMy GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(8,40) : error CS1514: { expected

DocumentsMy GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(8,40) : error CS1519: Invalid token ‘.’ in class, struct, or interface member declaration

DocumentsMy GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(9,5) : error CS1519: Invalid token ‘{‘ in class, struct, or interface member declaration

anyone can help me thx

Kazzymodus


  • #2

Generally, it’s virtually impossible to help you unless you post the code. Errors alone don’t tell us any more than they tell you.

  • #3

Generally, it’s virtually impossible to help you unless you post the code. Errors alone don’t tell us any more than they tell you.

sorry im quite new to the modding community :D

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
public class environmentalsuitchest.ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Body);
return true;
}

public override void SetDefaults()
{
item.name = «Environmental Suit Chestplate»
item.width = 32;
item.height = 32;
AddTooltip(«A suit required to venture on EDN III.»);
item.value = 10;
item.rare = 2;
item.defense = 15;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Dirt, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

so this is the codes do you see any problems?

Kazzymodus


  • #4

sorry im quite new to the modding community :D

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
public class environmentalsuitchest.ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Body);
return true;
}

public override void SetDefaults()
{
item.name = «Environmental Suit Chestplate»
item.width = 32;
item.height = 32;
AddTooltip(«A suit required to venture on EDN III.»);
item.value = 10;
item.rare = 2;
item.defense = 15;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Dirt, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

so this is the codes do you see any problems?

This is wrong:

Code:

public class environmentalsuitchest.ModItem

The . operator is for member access. You should use the : operator for inheritance.

Code:

public class environmentalsuitchest : ModItem

Furthermore, you should follow proper naming conventions for your identifiers. Classes, namespaces, properties and methods should be PascalCased (so EnvironmentalSuitChest instead of environmentalsuitchest). Fields and local variables should be camelCased (so for example healthIncrease, and not healthincrease or HealthIncrease).

item.name and AddTooltip are going to throw errors as well, they should be set in SetStaticDefaults. Look to ExampleMod for an example of how to do that.

  • #5

This is wrong:

Code:

public class environmentalsuitchest.ModItem

The . operator is for member access. You should use the : operator for inheritance.

Code:

public class environmentalsuitchest : ModItem

Furthermore, you should follow proper naming conventions for your identifiers. Classes, namespaces, properties and methods should be PascalCased (so EnvironmentalSuitChest instead of environmentalsuitchest). Fields and local variables should be camelCased (so for example healthIncrease, and not healthincrease or HealthIncrease).

item.name and AddTooltip are going to throw errors as well, they should be set in SetStaticDefaults. Look to ExampleMod for an example of how to do that.

thanks it helped but now i get this issue.
My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(10,30) : error CS0115: ‘LostPlanet3.Items.Armor.environmentalsuitchest.Autoload(ref string, ref string, System.Collections.Generic.IList<Terraria.ModLoader.EquipType>)’: no suitable method found to override

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
public class EnvironmentalSuitChest : ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Body);
return true;
}

public override void SetStaticDefaults()
{
item.name = «Environmental Suit Chestplate»
item.width = 32;
item.height = 32;
AddTooltip(«A suit required to venture on EDN III.»);
item.value = 10;
item.rare = 2;
item.defense = 15;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Dirt, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

sorry if im being a burden to you :(

Kazzymodus


  • #6

thanks it helped but now i get this issue.
My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(10,30) : error CS0115: ‘LostPlanet3.Items.Armor.environmentalsuitchest.Autoload(ref string, ref string, System.Collections.Generic.IList<Terraria.ModLoader.EquipType>)’: no suitable method found to override

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
public class EnvironmentalSuitChest : ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Body);
return true;
}

public override void SetStaticDefaults()
{
item.name = «Environmental Suit Chestplate»
item.width = 32;
item.height = 32;
AddTooltip(«A suit required to venture on EDN III.»);
item.value = 10;
item.rare = 2;
item.defense = 15;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Dirt, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

sorry if im being a burden to you :(

It’s no burden at all! ;)

Anyway, just remove the whole Autoload method, and add this just above your class declaration:

Code:

[AutoloadEquip(EquipType.Body)] // <-- Add this
public class EnvironmentalSuitChest : ModItem
{
// etc.

  • #7

It’s no burden at all! ;)

Anyway, just remove the whole Autoload method, and add this just above your class declaration:

Code:

[AutoloadEquip(EquipType.Body)] // <-- Add this
public class EnvironmentalSuitChest : ModItem
{
// etc.

Now i did that
now these issues pop up
My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(9,2) : error CS1518: Expected class, delegate, enum, interface, or struct

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(32,1) : error CS1022: Type or namespace definition, or end-of-file expected

Code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
    [AutoloadEquip(EquipType.Body)]
    }
    public class EnvironmentalSuitChest : ModItem
    {
        public override void SetStaticDefaults()
        {
            item.name = "Environmental Suit Chestplate"
            item.width = 32;
            item.height = 32;
            AddTooltip("A suit required to venture on EDN III.");
            item.value = 10;
            item.rare = 2;
            item.defense = 15;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Dirt, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

Kazzymodus


  • #8

Now i did that
now these issues pop up
My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(9,2) : error CS1518: Expected class, delegate, enum, interface, or struct

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(32,1) : error CS1022: Type or namespace definition, or end-of-file expected

Code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
    [AutoloadEquip(EquipType.Body)]
    }
    public class EnvironmentalSuitChest : ModItem
    {
        public override void SetStaticDefaults()
        {
            item.name = "Environmental Suit Chestplate"
            item.width = 32;
            item.height = 32;
            AddTooltip("A suit required to venture on EDN III.");
            item.value = 10;
            item.rare = 2;
            item.defense = 15;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Dirt, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

There shouldn’t be a } after the attribute, look at my example again.

  • #9

There shouldn’t be a } after the attribute, look at my example again.

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(13,18) : error CS1061: ‘Terraria.Item’ does not contain a definition for ‘name’ and no extension method ‘name’ accepting a first argument of type ‘Terraria.Item’ could be found (are you missing a using directive or an assembly reference?)

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(16,13) : error CS0103: The name ‘AddTooltip’ does not exist in the current context

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(25,41) : error CS0117: ‘Terraria.ID.ItemID’ does not contain a definition for ‘Dirt’

Code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
    [AutoloadEquip(EquipType.Body)]
    public class EnvironmentalSuitChest : ModItem
    {
        public override void SetStaticDefaults()
        {
            item.name = "Environmental Suit Chestplate";
            item.width = 32;
            item.height = 32;
            AddTooltip("A suit required to venture on EDN III.");
            item.value = 10;
            item.rare = 2;
            item.defense = 15;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Dirt, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

So when i tried fixing the dirt thing a bunch more issues popped up so yeah i reverted it to see if you can help :D

Kazzymodus


  • #10

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(13,18) : error CS1061: ‘Terraria.Item’ does not contain a definition for ‘name’ and no extension method ‘name’ accepting a first argument of type ‘Terraria.Item’ could be found (are you missing a using directive or an assembly reference?)

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(16,13) : error CS0103: The name ‘AddTooltip’ does not exist in the current context

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(25,41) : error CS0117: ‘Terraria.ID.ItemID’ does not contain a definition for ‘Dirt’

Code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
    [AutoloadEquip(EquipType.Body)]
    public class EnvironmentalSuitChest : ModItem
    {
        public override void SetStaticDefaults()
        {
            item.name = "Environmental Suit Chestplate";
            item.width = 32;
            item.height = 32;
            AddTooltip("A suit required to venture on EDN III.");
            item.value = 10;
            item.rare = 2;
            item.defense = 15;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Dirt, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

So when i tried fixing the dirt thing a bunch more issues popped up so yeah i reverted it to see if you can help :D

The first two errors I already predicted here:

item.name and AddTooltip are going to throw errors as well, they should be set in SetStaticDefaults. Look to ExampleMod for an example of how to do that.

As for ItemID.Dirt, that should be ItemID.DirtBlock.

And you really should get an IDE like Visual Studio to help you out.

  • #11

The first two errors I already predicted here:

As for ItemID.Dirt, that should be ItemID.DirtBlock.

And you really should get an IDE like Visual Studio to help you out.

I fixed the tooltip error while waiting because i remembered you talked about it before.
thanks. now theres this :(

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(13,13) : error CS1656: Cannot assign to ‘SetDefault’ because it is a ‘method group’

Code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
    [AutoloadEquip(EquipType.Body)]
    public class EnvironmentalSuitChest : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault = ("Environmental Suit Chestplate");
            item.width = 32;
            item.height = 32;
            Tooltip.SetDefault("A suit required to venture on EDN III.");
            item.value = 10;
            item.rare = 2;
            item.defense = 15;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

Kazzymodus


  • #12

I fixed the tooltip error while waiting because i remembered you talked about it before.
thanks. now theres this :(

My GamesTerrariaModLoaderMod SourcesLostPlanet3ItemsArmorenvironmentalsuitchest.cs(13,13) : error CS1656: Cannot assign to ‘SetDefault’ because it is a ‘method group’

Code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace LostPlanet3.Items.Armor
{
    [AutoloadEquip(EquipType.Body)]
    public class EnvironmentalSuitChest : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault = ("Environmental Suit Chestplate");
            item.width = 32;
            item.height = 32;
            Tooltip.SetDefault("A suit required to venture on EDN III.");
            item.value = 10;
            item.rare = 2;
            item.defense = 15;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

Remove the = after DisplayName.SetDefault. You’re calling the method, not assigning to it.

  • #13

Remove the = after DisplayName.SetDefault. You’re calling the method, not assigning to it.

thanks seems like the code is working
but one last issue

It looks like this mod doesn’t have a class extending Mod. Mods need a Mod class to function.
at Terraria.ModLoader.AssemblyManager.InstantiateMods(List`1 modsToLoad)

Inner Exception:
Sequence contains no matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at Terraria.ModLoader.AssemblyManager.InstantiateMods(List`1 modsToLoad)

Kazzymodus


  • #14

thanks seems like the code is working
but one last issue

It looks like this mod doesn’t have a class extending Mod. Mods need a Mod class to function.
at Terraria.ModLoader.AssemblyManager.InstantiateMods(List`1 modsToLoad)

Inner Exception:
Sequence contains no matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at Terraria.ModLoader.AssemblyManager.InstantiateMods(List`1 modsToLoad)

Exactly what it says, you need a class extending Mod for your mod to work.

Here’s the example from ExampleMod. Don’t go copy pasting everything, though, only use the methods you actually need.

  • #15

Exactly what it says, you need a class extending Mod for your mod to work.

Here’s the example from ExampleMod. Don’t go copy pasting everything, though, only use the methods you actually need.

i dont follow, are you refering to this?

Code:

/*public static class ExampleModExtensions
{
public static int CountItem(this Player player, int type)
{
int count = 0;
for (int i = 0; i < 58; i++)
{
if (type == player.inventory[i].type && player.inventory[i].stack > 0)
{
count += player.inventory[i].stack;
}
}
return count;
}
}*/
}

Kazzymodus


  • #16

i dont follow, are you refering to this?

Code:

/*public static class ExampleModExtensions
{
public static int CountItem(this Player player, int type)
{
int count = 0;
for (int i = 0; i < 58; i++)
{
if (type == player.inventory[i].type && player.inventory[i].stack > 0)
{
count += player.inventory[i].stack;
}
}
return count;
}
}*/
}

Please read this:

https://forums.terraria.org/index.p…tting-started-with-tmodloader.44817/#ModClass

  • #17

ah i get it, like a parent right?

Kazzymodus


  • #18

ah i get it, like a parent right?

Yes.

  • #19

Items/Armor/EnvironmentalSuitChest_Body
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AddEquipTexture(ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AutoloadItem(Type type)
at Terraria.ModLoader.Mod.Autoload()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
is this a because i didnt make a code for texture selection?

Kazzymodus


  • #20

Items/Armor/EnvironmentalSuitChest_Body
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AddEquipTexture(ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AutoloadItem(Type type)
at Terraria.ModLoader.Mod.Autoload()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
is this a because i didnt make a code for texture selection?

Yes. You need a sprite for the item icon (EnvironmentalSuitChest.png) and a sprite for the equipped armour (EnvironmentalSuitChest_Body.png).

My question seems to come from differences between text files in different OSes. So I will try my luck here.

I would like to try the default project created from a .NET Core template on Ubuntu 18.04. I have installed SQL Server mssql-server_15.0.4003.23-3_amd64.deb and choose Express as edition. Since LocalDB is Windows only, I figure that I have to modify src/WebUI/appsettings.json to replace LocalDB connection string with the following SQL Server connection string (I am not sure if it is correct):

  "ConnectionStrings": {
      "DefaultConnection": "Server=localhost\SQLEXPRESS,1433;Database=ExampleDb;User Id=sa;Password=password;"
  },

Then I go into src/WebUI/ and build it but fail (see below). The errors seem not related to my change of the connection string.

Regarding the first error, I open src/Domain/Domain.csproj in Emacs, which shows something strange <U+FEFF>, which https://en.wikipedia.org/wiki/Byte_order_mark says is about endianness. I wonder how I could make the files work?

<U+FEFF>namespace default.Domain.Enums
{
    public enum PriorityLevel
    {
        None,
        Low,
        Medium,
        High
    }
}

Thanks.

$ dotnet build
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 147.56 ms for /tmp/test/default/src/Domain/Domain.csproj.
  Restore completed in 213.91 ms for /tmp/test/default/src/Application/Application.csproj.
  Restore completed in 57.04 ms for /tmp/test/default/src/Infrastructure/Infrastructure.csproj.
  Restore completed in 9.65 ms for /tmp/test/default/src/WebUI/WebUI.csproj.
Enums/PriorityLevel.cs(1,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(2,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(4,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,32): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(7,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,27): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(6,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(4,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]

Build FAILED.

Enums/PriorityLevel.cs(1,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(2,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(4,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,32): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(7,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,27): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(6,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(4,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
    0 Warning(s)
    60 Error(s)

Доброе утро, парни! Я новичок в C# и разработке игр, так что не ругайтесь)))
Итак, у меня есть код, но у меня 1 ошибка в 5-й строке. Помогите, пожалуйста, почти все перепробовал, не помогает. Надеюсь, ты поможешь мне. Спасибо))
Ошибка: PostProcessingController.cs(5,6): error CS1514: Unexpected symbol public’, expecting .’ or {‘
Я плохо знаю C#, ты моя единственная надежда!

using UnityEngine;
using System.Collections;
namespace UnityEngine.Rendering.PostProcessing

public class PostProcessingController : MonoBehaviour \<--ERROR IN HERE 
{
    public PostProcessVolume Volume;
    public DepthOfFieldSettings DofSettings;

    public ColorGradingSettings ColorSettings;

    DepthOfField dof;
    ColorGrading colorGrading;

    void Start()
    {
        Volume.sharedProfile = Instantiate(Volume.sharedProfile);

        dof = Volume.profile.GetSetting<DepthOfField>();
        colorGrading = Volume.profile.GetSetting<ColorGrading>();

        DofSettings.focusDistance = dof.focusDistance.value;
        DofSettings.aperture = dof.aperture.value;
        DofSettings.focalLength = dof.focalLength.value;

        ColorSettings.Lift = colorGrading.lift.value;
        ColorSettings.GreenOutGreenIn = colorGrading.mixerGreenOutGreenIn.value;
    }

    void Update()
    {
        dof.focusDistance.value = DofSettings.focusDistance;
        dof.aperture.value = DofSettings.aperture;
        dof.focalLength.value = DofSettings.focalLength;

        colorGrading.lift.value = ColorSettings.Lift;
        colorGrading.mixerGreenOutGreenIn.value = ColorSettings.GreenOutGreenIn;
    }

    public void LerpDof(DepthOfFieldSettings start, DepthOfFieldSettings end, float t)
    {
        DofSettings.focusDistance = Mathf.Lerp(start.focusDistance, end.focusDistance, t);
        DofSettings.aperture = Mathf.Lerp(start.aperture, end.aperture, t);
        DofSettings.focalLength = Mathf.Lerp(start.focalLength, end.focalLength, t);
    }

    public void LerpColorGrading(ColorGradingSettings start, ColorGradingSettings end, float t)
    {
        ColorSettings.Lift = Vector4.Lerp(start.Lift, end.Lift, t);
        ColorSettings.GreenOutGreenIn = Mathf.Lerp(start.GreenOutGreenIn, end.GreenOutGreenIn, t);
    }

    [ContextMenu("Show grading")]
    void showLift()
    {
        colorGrading = Volume.profile.GetSetting<ColorGrading>();
        Debug.Log(colorGrading.lift.value);
        Debug.Log(colorGrading.mixerGreenOutGreenIn.value);
    }

    [System.Serializable]
    public struct DepthOfFieldSettings
    {
        public float focusDistance;
        public float aperture;
        public float focalLength;
    }

    [System.Serializable]
    public struct ColorGradingSettings
    {
        public Vector4 Lift;
        public float GreenOutGreenIn;
    }
}

I get to help a lot of people learn C# programming every year. As I watch new developers grow and get used to working in C# and Visual Studio, it has become fairly clear to me that reading C# compiler errors and even their documentation is an acquired skill. I’ve made a request for Microsoft to improve the error message feedback in Visual Studio, but until that’s resolved developers still have a tough time working through early obstacles.

Because of this, I’m creating this unusual post to serve as beginner-friendly documentation to what I personally view as the most likely compiler errors a new developer is likely to encounter. Microsoft has wonderful documentation on compiler errors, and this is something that will help you out significantly as you grow, but early on a paragraph or two aimed at a beginner can be exactly what you need.

I also snuck in a few of the more interesting compiler errors I noticed about the maximum limits of the C# compiler, so even if you’re very familiar with C# at this point you’ll likely still learn a few things skimming this list.

Take a look at my list and my recommendations on these issues and let me know if you find this helpful or encounter something I missed.

CS0003 – Out of Memory

This occurs when a computer runs out of memory compiling your code. Close any unnecessary programs and reboot the machine if the problem persists.

CS0004 – Warning Treated as Error

Developers may configure projects to treat certain warnings as errors. These warnings may be specified in the build section of the project’s properties. Typically it is best to resolve the specific warning listed in the build errors since someone wanted that to be treated severely.

CS0015 – Type Name too Long

.NET requires the names of types and namespaces to be less than 1024 characters. If you find yourself getting this error, you may want to reconsider your team’s naming choices.

CS0017 – More than one entry point defined

This occurs when your program has more than one class defined with a static void main method. Remove one of them or manually set the project’s startup object in the project properties.

CS0019 – Operator ‘operator’ cannot be applied to operands of type ‘type’ and ‘type’

This occurs when you try to compare two different types in ways that cannot be compared. For example, checking to see if integer values are equal to Boolean values, subtracting a string from a number, etc. This error often occurs when developers forget what type of data is stored by a particular variable.

CS0020 – Division by Constant Zero

This occurs if you try to force a division by zero in your code. You cannot force a division by zero through a numeric literal or by using a constant for the denominator, but you can declare a variable holding 0 and use that as a denominator.

CS0021 – Cannot apply indexing to type

This occurs when you try to use an array or list-style indexer on a type that doesn’t support it. This often occurs when developers assume they’re working with an array, string, or list and are not.

CS0023 – Operator ‘operator’ cannot be applied to operand of type ‘type’

This occurs when you try to use a mathematical operator with a type that doesn’t support it. For example, trying to generate a negative value of a string. Double check that your variables are of the type you think they are and re-evaluate what you are trying to do.

CS0026 – Keyword this cannot be used in a static method

This error occurs when you are working inside of a static method and try to use the this keyword. Static methods are methods associated with the class itself and not with an instance of the class. As a result, static methods do not have access to any properties, methods, or fields on the class that are not static.

CS0029 – Cannot implicitly convert type ‘type’ to ‘type’

This occurs when you have a variable of one type and are trying to store it into a variable of another type. Some types allow you to automatically convert from one type to another (an implicit conversion), but the types you are using do not support that. You may need to use an explicit cast using (type) syntax.

CS0030 – Cannot convert type ‘type’ to ‘type’

This occurs when there is no implicit or explicit conversion between two different types. If you’re sure you need to do what you’re doing, you could create a method to convert from one type to the other.

CS0031 – Constant value ‘value’ cannot be converted to a ‘type’.

This occurs when you try to store a value into a variable type that cannot store that particular value. For example, if you try to store 5 billion into an integer (which can store values up to around 2.1 billion) you will get this compiler error. You can resolve this error by storing the value into a type that can hold larger values, such as a long.

CS0050 – Inconsistent accessibility: return type ‘type’ is less accessible than method ‘method’

This occurs when a method returns a type that has a visibility or access modifier that is more restrictive than the method and class the method is currently in. For example this error will occur if a public method in a public class returns a type that is defined as internal.

This error usually occurs when developers forget to mark a class as public. Remember that classes have a default access modifier of internal when no access modifier is specified. Typically the fix for this is to explicitly declare that class as public.

CS0051 – Inconsistent accessibility: parameter type ‘type’ is less accessible than method ‘method’

This occurs when a method takes in a parameter that is of a type that has a visibility or access modifier that is more restrictive than the method and class the method is currently in. For example this error will occur if a public method in a public class requires a parameter of a type that is defined as internal.

This error usually occurs when developers forget to mark a class as public. Remember that classes have a default access modifier of internal when no access modifier is specified. Typically the fix for this is to explicitly declare that class as public.

CS0052 – Inconsistent accessibility: field type ‘type’ is less accessible than field ‘field’

This occurs when a class has a public field that is of a type that has a visibility or access modifier that is more restrictive than the class the method is currently in. For example this error will occur if a class has a public field of a type that is defined as internal.

This error usually occurs when developers forget to mark a class as public. Remember that classes have a default access modifier of internal when no access modifier is specified. Typically the fix for this is to explicitly declare that class as public.

CS0053 – Inconsistent accessibility: property type ‘type’ is less accessible than property ‘property’

This occurs when a class has a property of a type that has a visibility or access modifier that is more restrictive than the property’s visibility. For example this error will occur if a public property is of a type that is defined as internal.

This error usually occurs when developers forget to mark a class as public. Remember that classes have a default access modifier of internal when no access modifier is specified. Typically the fix for this is to explicitly declare that class as public.

CS0060 – Inconsistent accessibility: base class ‘class1’ is less accessible than class ‘class2’

This occurs when a class inherits from another class but the subclass’s access modifier is less restrictive than the base class’s access modifier. For example this error will occur if a public class inherits from an internal class.

This error usually occurs when developers forget to mark a class as public. Remember that classes have a default access modifier of internal when no access modifier is specified. Typically the fix for this is to explicitly declare that class as public.

CS0061 – Inconsistent accessibility: base interface ‘interface 1’ is less accessible than interface ‘interface 2’

This occurs when an interface inherits from another interface but the child interface’s access modifier is less restrictive than the base interface’s access modifier. For example this error will occur if a public interface inherits from an internal interface.

This error usually occurs when developers forget to mark an interface as public. Remember that interfaces have a default access modifier of internal when no access modifier is specified, although every member of an interface is public. Typically the fix for this is to explicitly declare that interface as public.

CS0100 – The parameter name ‘parameter name’ is a duplicate

This occurs when a developer declares a method but uses the same parameter name twice in the method’s parameter list. The fix for this is generally to remove an unneeded parameter or to rename parameters so that all parameters have a different name.

CS0101 – The namespace ‘namespace’ already contains a definition for ‘type’

This occurs when a class is defined twice in the same namespace. This can occur when a class is renamed but the old file still exists, when a developer forgot to mark a class as part of a different namespace, or when a developer intended to use the partial keyword but forgot to specify it. The fix for this will vary based on which files you want and what namespaces they should live in.

CS0102 – The type ‘type name’ already contains a definition for ‘identifier’

This occurs when you declare a member such as a field twice in the same class. Often this is a symptom of using an existing variable name instead of choosing a new name.

CS0103 – The name ‘identifier’ does not exist in the current context

This error often occurs when trying to use a variable defined in another scope. This commonly occurs when you try to define a variable inside of a try block and refer to it in a catch block, when there was no guarantee that the runtime was able to create that variable and therefore the variable is not available.

The fix for this is typically to declare the variable before the try / catch block and update its value from the try block. In this way the catch block will get either the initial value of the variable or its updated value and will be able to reference it.

CS0111 – Type ‘class’ already defines a member called ‘member’ with the same parameter types

This occurs when a developer creates a duplicate method or property with an identical signature consisting of a return type and parameter types. The compiler detects that there will not be a way for code outside of the class to distinguish between one member and the other and so this error is raised. Typically when this occurs you need to either rename one of the two members, change the parameters of one of the methods, or merge the two methods together into one method.

CS0117 – ‘type’ does not contain a definition for ‘identifier’

This occurs when you are trying to call a method or use a property on an instance of an object, but there is no method or property with that name. This can be an issue with capitalization, spelling, or forgetting the name of the member you’re referring to. Code completion can help you find the correct name to use.

CS0120 – An object reference is required for the non-static field, method, or property ‘member’

This often occurs in static methods when you attempt to work with non-static members of the same class. Remember that static methods are associated with the class itself and not with a specific instance of that class. As a result, static methods cannot access properties, fields, and methods that are not marked as static.

The fix for this is often to remove the static keyword from the method that needs to access instance variables. This is counter-intuitive since the compiler pushes you towards adding static in other places, but if you follow that path to its logical conclusion all of your data becomes static eventually, so you’re better off removing the static keyword when confronted by this.

CS0122 – ‘member’ is inaccessible due to its protection level

This occurs when you are trying to call a method or use a property on an instance of an object, but that member is defined as private or protected and you are outside of the class or something that inherits from it. You may not be intended to work with the method or property you are using and you should probably look for public members that might meet your needs without compromising the class’s encapsulation.

CS0127 – Since ‘function’ returns void, a return keyword must not be followed by an object expression

This is a rarer error that occurs when you are in a method defined as void but are trying to return a specific object. Remember that void methods do not return any value so a return statement should just be listed as return;. If you find that you do need to return a value, you should change the return type of the method from void to some specific type.

CS0128 – A local variable named ‘variable’ is already defined in this scope

This occurs when you re-declare a variable that already exists. The solution for this is to either use a different variable name or to remove the type name from your statement and change it from a variable declaration to an assignment statement and re-use the existing variable.

This error often comes from copying and pasting code that declares a new variable.

CS0133 – The expression being assigned to ‘variable’ must be constant

This occurs when you are declaring a const and declaring it to another variable. Constants are evaluated at the time your code is compiled and the compiler will not know the value of your variables. As a result, constants must be set to a literal number or string value.

CS0134 – ‘variable’ is of type ‘type’. A const field of a reference type other than string can only be initialized with null.

This occurs when you are trying to declare a const of a type other than a numeric or string value. Typically, if you have a const that needs to store a reference type you should instead use readonly which is less optimized than a const but works with reference types and ensures that the value will never change.

CS0136 – A local variable named ‘var’ cannot be declared in this scope because it would give a different meaning to ‘var’, which is already used in a ‘parent or current/child’ scope

This occurs when you declare a new variable with the same name as another variable in a visible scope. The solution for this is to either use a different variable name or to remove the type name from your statement and change it from a variable declaration to an assignment statement and re-use the existing variable.

CS0145 – A const field requires a value to be provided

This occurs when you declare a const but do not provide a value. You should set a const equal to some string or numeric variable when declaring it.

CS0150 – A constant value is expected

This occurs when the compiler requires a constant value such as a numeric or string literal but a variable is defined. This can occur when you use a variable in a switch statement or when you are using an array initializer for an array with a variable size.

Switch statements cannot use cases for specific variables, though switch expressions are more flexible.

When working with arrays of varying size, you may want to avoid the use of array initializers and instead manually set the elements of the array after creation.

CS0152 – The label ‘label’ already occurs in this switch statement

This occurs when you duplicate a case statement inside of a switch statement. Typically this occurs when you didn’t notice the case already existed and you can delete your repeated case statement.

CS0160 – A previous catch clause already catches all exceptions of this or of a super type (‘type’)

The ordering of catch statements in a try / catch matters since the runtime will try to match the first catch that applies to the exception it encountered. Because of this, the compiler generates this error if it sees a more specific exception type after a less specific exception type since this results in a case where the more specific catch statement could never be reached.

Move your more specific catch statement above the less specific one to fix this error.

CS0161 – Not all code paths return a value

This occurs because the C# compiler believes that it is possible to get to the end of your method without encountering a return statement. Keep in mind that the C# compiler does very little inferences based on your if statements and even if it may not actually be possible to reach the end of the method without returning, the compiler still thinks it is.

The fix for this is almost always to add a final return statement.

CS0165 – Use of unassigned local variable

This occurs when the compiler sees a variable that is defined but not set to an initial value and determines that the value of that variable needs to be read from later on in the method before the variable is guaranteed to have its value set.

The fix for this is generally to set the variable to be equal to an initial value.

CS0176 – Static member ‘member’ cannot be accessed with an instance reference; qualify it with a type name instead

This occurs when you have a static property or field on a class but are trying to refer to it on a specific instance of that class.

Use the class name instead of the instance variable to access the static member.

CS0201 – Only assignment, call, increment, decrement, and new object expressions can be used as a statement

This typically occurs when you are performing some sort of mathematical operation but not storing the result into a variable. The compiler understands the operation but sees it has no value, so it raises the error.

The fix for this is to store the result of the mathematical operation into a variable or to remove the unnecessary line.

CS0204 – Only 65534 locals are allowed

Apparently you have a method that has over 65 thousand local variables inside of it. The compiler doesn’t like this very much and, frankly, I’m a little concerned why you’d need that many.

Reconsider your life choices.

CS0230 – Type and identifier are both required in a foreach statement

This occurs when you are writing a foreach statement without specifying all parts of the statement.

foreach statements require a variable type, a variable name, the word in, and some variable that can be enumerated over. For example: foreach (string person in people)

CS0234 – The type or namespace name ‘name’ does not exist in the namespace ‘namespace’ (are you missing an assembly reference?)

This occurs when you are trying to refer to a type via its fully-qualified name, including the namespace, but no known type exists with that namespace and type name. This can be a spelling error, a mistake as to which namespace the type lives in, or a correct namespace and type, but your project does not yet have a reference to the project the type is defined in.

If your spelling and namespaces are correct you may need to add a project reference to your project or install a package via nuget.

CS0236 – A field initializer cannot reference the non-static field, method, or property ‘name’.

This occurs when you try to define a field by referencing another field. This error exists to prevent unpredictable behavior based on which field initializers run first.

The fix for this is to set the value of the field in the constructor instead of in a field initializer.

CS0246 – The type or namespace name ‘type/namespace’ could not be found (are you missing a using directive or an assembly reference?)

This occurs when you are trying to refer to a type no known type exists with that type name in the using statements currently in your file.

This is usually a spelling error or a missing using statement at the top of your file.

If your spelling and using statements are correct you may need to add a project reference to your project or install a package via nuget.

CS0266 – Cannot implicitly convert type ‘type1’ to ‘type2’. An explicit conversion exists (are you missing a cast?)

This occurs when you are trying to store a variable of one type into a variable of another type without casting. For example, if you are trying to set a double value into an int variable you will see this error.

The statement “an explicit conversion exists (are you missing a cast)” is telling you that these types are compatible, but the compiler wants to make sure you intend to convert from one to another so it requires you to cast your variable from one type to another.

You cast variables in C# by using parentheses around a type name like this: int num = (int)myDouble;

CS0500 – ‘class member’ cannot declare a body because it is marked abstract

This occurs when you declare an abstract member inside of an abstract class, but you tried to give it a method body (using {}). Abstract members do not have method bodies.

Remove the  {}’s from your abstract method. Alternatively, if you want to provide a default implementation and allow inheriting classes to optionally override yours, use virtual instead of abstract.

CS0501 – ‘member function’ must declare a body because it is not marked abstract, extern, or partial

This occurs when you try to declare a method but forget to give it a method body with {}’s.

This can also occur when you mean to define an abstract method but forgot to use the abstract keyword.

CS0506 – ‘function1’ : cannot override inherited member ‘function2’ because it is not marked “virtual”, “abstract”, or “override”

In C# you have to mark a method as virtual or abstract to be able to override it.

The fix for this is usually to add the virtual keyword to the method in the base class.

CS0507 – ‘function1’ : cannot change access modifiers when overriding ‘access’ inherited member ‘function2’

When overriding a method you must keep the same access modifier as the base method. If the access modifier needs to change, change it in all classes that have the method.

CS0508 – ‘Type 1’: return type must be ‘Type 2’ to match overridden member ‘Member Name’

When overriding a method you cannot change the return type of the method. If you think you need to return something radically different, you may need to introduce a new method instead of overriding an existing one. Alternatively, creative uses of interfaces or inheritance can allow you to return a more specific version of something from a method through polymorphism.

CS0513 – ‘function’ is abstract but it is contained in nonabstract class ‘class’

When you need a method to be abstract, the entire class needs to be abstract as well.

CS0525 – Interfaces cannot contain fields

This one is self-explanatory. An interface is a contract that defines what members need to be present. Fields in classes should be private and are implementation details that do not belong in an interface.

CS0526 – Interfaces cannot contain constructors

This one is self-explanatory. An interface is a contract that defines what members need to be present on an already-constructed class. Interfaces do not care about how an instance is created and cannot denote constructors required for a given class.

CS0531 – ‘member’ : interface members cannot have a definition

This occurs when you try to give an interface member a method body. Interfaces denote capabilities that must be in place, not how those capabilities should work.

If you think you really need a default implementation of a method, you might want to use an abstract class instead of an interface.

CS0534 – ‘function1’ does not implement inherited abstract member ‘function2’

This occurs when you inherit from an abstract class that has abstract members but do not override those members. Because of this, the compiler has no implementation for those abstract members and does not know how to handle them if they are called.

Override the inherited member or mark the inheriting class as abstract as well.

CS0535 – ‘class’ does not implement interface member ‘member’

This occurs when you implement an interface but have not provided members that match those defined in the interface. Members must match the exact type signatures of those defined in the interface and should have names that match those in the interface as well.

CS0645 – Identifier too long

This occurs when you try to name a variable or other identifier something longer than 512 letters long.

What exactly are you trying to do over there that has you naming variables this long?

CS0844 – Cannot use local variable ‘name’ before it is declared.

This occurs when you try to use a variable in a method above when that variable is declared. C# does not have hoisting like some other languages do and variables are only available after they are declared.

Reorder your statements to match your needs.

CS1001 – Identifier expected

This usually occurs when you forget the name of a variable, class, or parameter but have defined other aspects of that line of code. Check some reference materials for what you are trying to do because you’re missing something important.

CS1002 – Semicolon expected

C# requires you to end most statements with a semicolon, including this one. Add a semicolon to the end of the line and all should be well.

CS1026 – ) expected

You have too many opening parentheses and not enough closing parentheses. Check to make sure that all open-parentheses have a matching closing parentheses.

Clicking on a parentheses in Visual Studio will highlight the matching parentheses making it easier to spot the one you’re missing.

CS1033 – Source file has exceeded the limit of 16,707,565 lines representable in the PDB; debug information will be incorrect

What on earth are you even doing over there? Why would you have a source file that requires more than 16 million lines?

Don’t do that. Just no. It’s time to hire a consultant.

CS1034 – Compiler limit exceeded: Line cannot exceed ‘number’ characters

Some people like tabs. Some people like spaces. You, apparently solve this debate by removing line breaks entirely.

You should never need to have a line of code longer than 16 million characters.

CS1035 – End-of-file found, ‘*/’ expected

Your code has a block comment start (/*) but no matching end comment. Add an end comment (*/) and the compiler will be happier.

CS1039 – Unterminated string literal

It looks like you started a string somewhere but forgot to put the other quotation mark. Add it in where it needs to be.

CS1501 – No overload for method ‘method’ takes ‘number’ arguments

This occurs when you are trying to call a method with an incorrect number of arguments or parameters to that method. Check the code or documentation for the method you’re trying to call and ensure you have the correct number of arguments specified.

CS1513 – } expected (missing closing scope)

You have too many opening curly braces and not enough closing curly braces. Check to make sure that all open curly braces have a matching closing curly brace.

Clicking on a { in Visual Studio will highlight the matching } making it easier to spot the one you’re missing.

CS1514 – { expected

Your code requires a { but you didn’t provide one. This often happens after declaring a namespace or class. Check your syntax and add curly braces where they need to go.

CS1525 – Invalid expression term ‘character’

This error seems ambiguous, but most of the time when I see this error it comes from someone trying to use == to assign a value to a variable instead of using the = operator. If this is not your error, you may need to consult some documentation or reference material for valid syntax for what you’re trying to do.

CS1552 – Array type specifier, [], must appear before parameter name

This error occurs when you put [] syntax around the variable name and not around the type name when declaring an array.

Write your arrays as int[] myArray; instead of int myArray[];.

CS1604 – Cannot assign to ‘variable’ because it is read-only

This occurs when you’ve declared a readonly or const variable and are trying to set its value. You can’t do that. If you need to change its value, it can’t be readonly or const.

CS7036 – No argument given that corresponds to the required formal parameter (incorrect method call)

This error occurs when trying to call a base constructor but not specifying a parameter that is required by that constructor.

Double check your base() call and make sure the number and types of parameters lines up with a specific constructor present on your base class.

Понравилась статья? Поделить с друзьями:
  • Error cs1513 как исправить
  • Error cs1513 expected unity что делать
  • Error cs1503 unity
  • Error cs1503 argument 2 cannot convert from unityengine vector3 to unityengine transform
  • Error cs1503 argument 2 cannot convert from double to float