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: 49
Joined: Mon Oct 15, 2018 8:18 pm
Location: Austria
Contact:

How do add custom traits?

Post by Zeruel87 » Fri Nov 22, 2019 9:41 pm

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: 262
Joined: Fri May 15, 2015 5:57 pm

Re: How do add custom traits?

Post by Graion Dilach » Fri Nov 22, 2019 10:51 pm

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: 49
Joined: Mon Oct 15, 2018 8:18 pm
Location: Austria
Contact:

Re: How do add custom traits?

Post by Zeruel87 » Fri Nov 22, 2019 10:59 pm

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: 356
Joined: Mon Aug 18, 2014 6:00 pm

Re: How do add custom traits?

Post by abcdefg30 » Sat Nov 23, 2019 5:40 pm

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: 5
Joined: Tue Nov 26, 2019 4:07 pm

Re: How do add custom traits?

Post by EruseanMoD » Thu Nov 28, 2019 3:09 pm

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

Post Reply