Thanks for the help and motivation. I’ve done some programming in C and some other scripting when modding other games, but I've not used lua format. I’ve managed to make a character that can do quite a lot of things, but this more complex functionality for an item is hard. I'm not familiar with the many different pre-existing tags, names and variables (the API I guess) in DST and fail to find a good list of them. List like this: https://github.com/Nsy/dontstarvemods/wiki/Recipes,-Prefabs,-Craft-and-Tabs is helpful. These in particular are quite easy to find in existing .lua files, but it would be easier if I don't have to do it for every pre-existing variable etc. It also increases the likelihood that I misinterpret something and pick the wrong one. Are there more like them? It's hard to reverse engineer things just to get a picture of how things work so that one can reuse the existing variables in smart ways.
I’ve a working character that uses Klei's mod API. He has a beard and hair that when it grows increases his strength. This comes at the cost of lowering his max hunger and sanity and increasing the drain of them a lot. Similar to Wolfgang in the “food for power” regard, but you have to dedicate days (21 for max) of penalty to gain the power instead of being able to gain boost up whenever you wish in a matter of seconds at the cost of some food with no other penalty. I have a modmain.lua and a few custom prefab-items with their own recipes that work. I also have restricted his access to some recipes completely since I want to limit his access to “electronics”, for a lack of better word, since he is primitive being. The first thing I tried when making this magic-tier-unlocking-hat was making a new prefab called primitive_featherhat.lua. I tried to copy the functionality of the original feather hat from the hat.lua by "breaking it out", since the hat.lua contains the functionality of the majority of hats. I used this as a base for the hat:
When I could not get the new feather hat to work I abandon that idea and thought it would be better to do it in the modmain.lua instead. Your solution makes it sound like I’m the right track in terms of how I’m thinking about the logic behind the functions needed. I always try to think about how the “core logic” should work before I program anything. The problem is that I don’t know “the language”, or API rather, well enough yet, and therefore can not express what I’m thinking. I’ve to practice more first I guess and build my knowledge up to this. Maybe instead of making a list of items that he can craft I make a list of items he can not craft. Then he would automatically gain access to mod items. As you said, theoretically it should be doable, but I’m not there yet in practice. I will continue to gradually build up a better understanding for all things by doing various trial and error functions and increasing the complexity until I reach my goal.
This: http://dontstarveapi.com/ site is useful for many things, but I since it's made for DS and not DST I have yet to explore it a lot since I know that things don't works exactly the same between the games and I don't want to learn "wrong" the first time around, but would you recommend some of it anyway? What also makes it harder for me is the client and host side of things in DST and I've not completely wrapped my head around how it affects how I write my code. It was easier in DS.