Jump to content

Need help with programming/coding


Recommended Posts

For a long time I've been thinking of making my own mod with some character for DST, but I can only make the character itself according to some random tutorial - there were no other additions like cool abilities. I've been trying a lot to make a code myself but I literally know nothing about it, so I decided to ask for help here.

1. I need character to change their appearance during the night and be immune to darkness. My main inspiration is Charlie mod, so I would be glad if somebody showed me how something like that was made-

2. It's not really important, but it would be nice if character had their own hat with them when appearing in the world

3. If I just change the code, do I need to change/rewrite anything extra? Will there be any conflicts in the game?

Any help is very valuable to me (;´д`)

Link to comment
Share on other sites

If you're completely new to coding you may want to take a little bit of time to learn the basics of how it works and the terminology, especially the basics of how LUA works

From there I would suggest doing a couple things; Poking around this forum has a lot of the answers you might be looking for from people asking stuff in the past, looking at mods with the similar stuff you want can give you an idea of what you might need to do (like the Charlie mod, for example) and can give a good idea of where in the code stuff goes, finally the best way to learn how to do specific things (but the hardest to figure out on your own) is looking at the game's files in script.zip as that can give lots of valuable information on what exactly you can work with.

1. I don't tend to mess with appearance much so I don't know the best way to do that part, looking up similar stuff here in the forums should provide the answer though. It mostly has to do with the skinner component. For the other part, I believe the Charlie mod gets immunity because of the night vision which is a little complicated to setup but is one option. Otherwise looking at the grue component (the component responsible for getting attacked in darkness) there is a built in way to add immunity, you'd just need to put this in your master_postinit

inst.components.grue:AddImmunity("character_name")

which simply calls the grue's function to add a key to the immunity table and stop the process of being attacked in the dark. "character_name" can be replaced with your character's name, or anything really as long as it inst being used by the game ("light", "invincible", "sleeping") You can also do the same but with :RemoveImmunity to remove the key from the table and no longer be immune.

2. If you're using the example character as a base you should already have a TUNING.GAMEMODE_STARTING_ITEMS.DEFAULTTUNING.CHARACTER = { } in your character prefab where CHARACTER is your character's name, adding a prefab name in quotes in the { } will make you spawn with it just make sure there's a comma between each item. Making a custom hat item would require its own separate prefab to make a hat item (you will need your own textures/animation for it) but besides the textures its not the hard to make a very basic hat item. This should work as a start for both texture and the prefab I believe :

3. I'm not exactly sure what you're asking, but assuming you mean copying a piece of code from somewhere, the main problems would be that the code is expecting another piece of code that you might not have or it has the same name as something else in your code. Otherwise you'd just need to make sure anything referencing a specific character is referencing your character instead.

I hope that helps get you started at least, I can re-explain something if I didn't explain it well or be more specific about something if needed

  • Thanks 1
Link to comment
Share on other sites

7 hours ago, Merkyrrie said:

If you're completely new to coding you may want to take a little bit of time to learn the basics of how it works and the terminology, especially the basics of how LUA works

From there I would suggest doing a couple things; Poking around this forum has a lot of the answers you might be looking for from people asking stuff in the past, looking at mods with the similar stuff you want can give you an idea of what you might need to do (like the Charlie mod, for example) and can give a good idea of where in the code stuff goes, finally the best way to learn how to do specific things (but the hardest to figure out on your own) is looking at the game's files in script.zip as that can give lots of valuable information on what exactly you can work with.

1. I don't tend to mess with appearance much so I don't know the best way to do that part, looking up similar stuff here in the forums should provide the answer though. It mostly has to do with the skinner component. For the other part, I believe the Charlie mod gets immunity because of the night vision which is a little complicated to setup but is one option. Otherwise looking at the grue component (the component responsible for getting attacked in darkness) there is a built in way to add immunity, you'd just need to put this in your master_postinit

inst.components.grue:AddImmunity("character_name")

which simply calls the grue's function to add a key to the immunity table and stop the process of being attacked in the dark. "character_name" can be replaced with your character's name, or anything really as long as it inst being used by the game ("light", "invincible", "sleeping") You can also do the same but with :RemoveImmunity to remove the key from the table and no longer be immune.

2. If you're using the example character as a base you should already have a TUNING.GAMEMODE_STARTING_ITEMS.DEFAULTTUNING.CHARACTER = { } in your character prefab where CHARACTER is your character's name, adding a prefab name in quotes in the { } will make you spawn with it just make sure there's a comma between each item. Making a custom hat item would require its own separate prefab to make a hat item (you will need your own textures/animation for it) but besides the textures its not the hard to make a very basic hat item. This should work as a start for both texture and the prefab I believe :

3. I'm not exactly sure what you're asking, but assuming you mean copying a piece of code from somewhere, the main problems would be that the code is expecting another piece of code that you might not have or it has the same name as something else in your code. Otherwise you'd just need to make sure anything referencing a specific character is referencing your character instead.

I hope that helps get you started at least, I can re-explain something if I didn't explain it well or be more specific about something if needed

Thank you very much! This is enough for me to know where to start, so don't worry, your advice is very helpful and informative.

The main problem at the beginning was the immunity system for me at night, since I didn’t understand how it works at all. Well, seems everything is not as complicated as I thought. Once again, thanks a lot for your help!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...