How do add custom traits?

how to add custom traits from one mod to another mod

Information and discussion for custom maps and mods.
Post Reply
User avatar
Zeruel87
Posts: 56
Joined: Mon Oct 15, 2018 8:18 pm
Location: Austria
Contact:

How do add custom traits?

Post 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"
Check out my CnC mod at:
https://www.moddb.com/mods/cameo

User avatar
Graion Dilach
Posts: 277
Joined: Fri May 15, 2015 5:57 pm

Re: How do add custom traits?

Post 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.

User avatar
Zeruel87
Posts: 56
Joined: Mon Oct 15, 2018 8:18 pm
Location: Austria
Contact:

Re: How do add custom traits?

Post 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)
Check out my CnC mod at:
https://www.moddb.com/mods/cameo

abcdefg30
Posts: 641
Joined: Mon Aug 18, 2014 6:00 pm

Re: How do add custom traits?

Post 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).

EruseanMoD
Posts: 4
Joined: Tue Nov 26, 2019 4:07 pm

Re: How do add custom traits?

Post 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#.

Matt
Posts: 1144
Joined: Tue May 01, 2012 12:21 pm
Location: Germany

Re: How do add custom traits?

Post 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.

Post Reply