Page 1 of 1

How do add custom traits?

Posted: Fri Nov 22, 2019 9:41 pm
by Zeruel87
Greetings,

is there a Tutorial how to add custom traits, if yes, where can i find it, if no, how to do it.

As far as my understanding goes it has to do with (for example the "example" mod) the "OpenRA.Mods.Example" folder, the Traits themself are in form of ".cs" files and it has something to do with the "OpenRA.Mods.Example.csproj"

if i add some stuff there and run the "make.cmd" with "all" command i get various errors displayed.
when i add entrys in the "OpenRA.Mods.Example"
<Compile Include="Traits\XXX.cs" />
i get the error like:
"C:\Program Files\dotnet\sdk\3.0.100\Roslyn\Microsoft.CSharp.Core.targets(59,5): error MSB3105: Das Element "Traits\XXX.cs" wurde im Parameter "Sources" mehrmals angegeben. Doppelte Elemente werden vom Parameter "Sources" nicht unterstützt."

translated to english it means the Element with the Parameter "Sources" has multiple entrys"

Re: How do add custom traits?

Posted: Fri Nov 22, 2019 10:51 pm
by Graion Dilach
Custom traits need to be written in the C# programming language. You can't just write stuff there and assume them working. Based on the PMs we had a few days ago... while I am impressed you care about what --check-yaml outputs and you put effort into fixing those, I'm not sure if you're able to comprehend what that means for you, sorry.

Re: How do add custom traits?

Posted: Fri Nov 22, 2019 10:59 pm
by Zeruel87
i know traits need to be written in a certain way (C#), iam not writing Traits myself, iam testing this with existing traits of another mod that iam allowed to use.

Yes, i care about many things, my Spirit and motivation to do modding is high :D i just dont know how to add existing traits (.cs)

Re: How do add custom traits?

Posted: Sat Nov 23, 2019 5:40 pm
by abcdefg30
You should use an IDE like Visual Studio Community 2019 to add and edit those files. It'll make it a lot easier for you (i.e. automatically adding the files to the csproj, or displaying errors).

Re: How do add custom traits?

Posted: Thu Nov 28, 2019 3:09 pm
by EruseanMoD
i'm not the OP, but thanks for the recommendation nonetheless, it's the sort of thing I might find useful as long as I'm not too familiar with C#.

Re: How do add custom traits?

Posted: Wed Dec 25, 2019 5:30 pm
by Matt
Das Element "Traits\XXX.cs" wurde im Parameter "Sources" mehrmals angegeben. Doppelte Elemente werden vom Parameter "Sources" nicht unterstützt."
That indicates that you duplicated a file. You can't overwrite it with new code. You have to rename it like https://github.com/AttacqueSuperior/Eng ... Duplicates does.