• Content Count

  • Joined

  • Last visited

Community Reputation

1 Neutral

About JonatannossreP

  • Rank
    Junior Member
  1. Currently I have this: local function sanity_primitive(inst) if inst.components.sanity.current >= (40) then inst.components.builder.science_bonus = (0) inst.components.builder.magic_bonus = (0) inst.components.builder.ancient_bonus = (0) inst.components.builder.volcanic_bonus = (0) elseif inst.components.sanity.current > (0) and inst.components.sanity.current < (40) then inst.components.builder.science_bonus = (-1) inst.components.builder.magic_bonus = (-1) inst.components.builder.ancient_bonus = (-1) inst.components.builder.volcanic_bonus = (-1) elseif inst.components.sanity.current < (1) then inst.components.builder.science_bonus = (-10) inst.components.builder.magic_bonus = (-10) inst.components.builder.ancient_bonus = (-10) inst.components.builder.volcanic_bonus = (-10) end end local master_postinit = function(inst) inst:ListenForEvent("sanitydelta", function(inst) sanity_primitive(inst) end) sanity_primitive(inst) end I don't really want it to be a -10 "bonus" however (that is just a placeholder) as it doesn't temporarily hide already learnt recipes. But I figured it might be easier to disable crafting by hiding the actual HUD element than adding and removing recipes. This lead me to this: However, I do not understand how to implement it into my function. Any clues you can give me?
  2. 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:,-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: 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.
  3. I want to create a unique effect for a custom character when he wears an already in game hat. I want him to unlock the first magic tier when he wears the Feather Hat. He should only be able to craft from this tier when he has this hat equipped. Once equipped he can not craft or use any magic items. This turned out to be more complicated to create than anything I made previously. Not only was the basic hat nested inside a single prefab with all the other hats but I also needed to add some custom code that I haven’t seen the likes of anywhere else. I tried to make a duplicate of the feather hat first by breaking it out as a single prefab file since I figured it would make it easier to make and perk exclusive to my character with a new item. Turns out the asset's name wasn't the same as the spawn name for the Feather Hat. I tried a bunch of strings that I found for the Feather Hat by file searching with notepad++ but didn’t get the right combination since they are not consistent depending on the type of the asset. Neither could I get my new recipe for the item to actually spawn the item, the character simply made the animation and then nothing. In the end I have to say this is far beyond my knowledge. I also figured that in the end it is probably cleaner to write some codes in the modmain.lua instead, but I feel even more lost trying that. Any help would be greatly appreciated since I'm back to square one from hours of tries that lead nowhere in the end and have no idea where to start. Regards, Joppy