Documentation icon indicating copy to clipboard operation
Documentation copied to clipboard

Entry for Snippets of Code?

Open Dealman opened this issue 4 years ago • 6 comments

Not sure how many would find it useful, but maybe having a link where people can contribute various small snippets of code? Instead of fully fledged tutorials.

One simple example would be to fetch how much XP the player has of the current skill level in for example OneHanded. While there is a method to return the progress(percentage) I couldn't find a method to return the actual XP of the current level. For example let's say the player has 35/150 in OneHanded, one way you could fetch that value would be like this;

MathF.Round(hero.HeroDeveloper.GetPropertyValue(DefaultSkills.OneHanded) - Campaign.Current.Models.CharacterDevelopmentModel.GetXpRequiredForSkillLevel(hero.GetSkillValue(DefaultSkills.OneHanded)));

And it would return 35.

I think having a collection of short snippets like these could be beneficial and help novices get started a bit easier. :)

Dealman avatar Apr 05 '20 12:04 Dealman

Instead of creating a snippets section, I think it would be easier/more organized to create a tutorial instead. In the above case, you could create a tutorial about working with skills, which would also include the above snippet.

strlngd avatar Apr 05 '20 18:04 strlngd

I would find it useful. A searchable store of "how to do x" would be an amazing resource for people who cannot commit the time or lack the skill to understand the structure of whatever they want to do.

Forcing a tutorial would limit contributions and increase the burden of organization.

mewosmith avatar Apr 07 '20 20:04 mewosmith

You can search based on markdown headers. When I migrate to VuePress you will also be able to search based on 2nd-level (and perhaps 3rd-level) headers as well. I think that in the long-term, having snippets of code in separate files is a bad idea. I couldn't find any quality documentation that does this either.

strlngd avatar Apr 08 '20 01:04 strlngd

I think it would also be useful to create an own API which offers easy to use methods like your example @Dealman provides. If people contribute time to time we will have a good collection of methods and newcomers as senior developer would have a benefit.

Peweez avatar Apr 12 '20 08:04 Peweez

I think own API - not good idea, because it's unneccesary and very limited. Tutorials are good for begginers to start. It can cover base aspects. Instead of code snippets I suggest to share finished smal libraries.

Anakael avatar Apr 18 '20 19:04 Anakael

I have various interesting snippets which are pretty advanced and obscure that I'd like to share but I'm not sure that they would work as seperate tutorials. A catch-all entry for "interesting snippets" I think actually might be useful.

iPherian avatar Apr 24 '20 06:04 iPherian