Asiru Posted January 9, 2016 Share Posted January 9, 2016 Okay! So, I've been attempting to create a custom character using Dana's "Artist's Guide", etc etc. When the mod starting actually crashing the game entirely, I decided to take a step all the way back to the original template. I'm trying to give my character a custom starting item as well, similar to Willow's Lighter (obviously with different mechanics though). I started by adding my custom Lua files and zipped folders individually until I came to the final changes in the modmain.lua. The first crash occured after I added my prefab name into the "PrefabFiles" section in the mod main. Obviously before I did that, the mod worked overall, except (duh) the character didn't start with that custom item. I'm not *too* familiar with this sort of setup. I'm only proficient in Java, and I'm pretty much new to Lua. So any educational code examples would be appreciated. Of course, I'd be happy to provide any files when you need them. If it makes any difference I'm using Windows 10. Thanks in advance!Asiru Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/ Share on other sites More sharing options...
greenglacier Posted January 9, 2016 Share Posted January 9, 2016 (edited) Sigh. I feel bad for doing this to him every time but what can I do if he's the only person I know to understand modding.I summon thee, mighty modder, @Mobbstar. Edited January 9, 2016 by greenglacier Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-707171 Share on other sites More sharing options...
Mobbstar Posted January 9, 2016 Share Posted January 9, 2016 This modder has been summoned from Oblivion. And I'm tired as heck, so I'll mostly link you to other tutorials and samples. You sound like you understand if-blocks, that saves us a lot of time. For starters, the log. Don't Starve prints out a log with general information, as well as essential crash reports including traceback. Basically, when your game crashes, you want to open the log and look for the indent part (the traceback) or use a search function to find it. Why the traceback? Because it's always glaring obvious to find and directly attached to the actual error. You can find more information on logs here: link Maybe you'd prefer using the newer template by D.W.Leo, albeit making the animation file might be more difficult. You can find the walk-through here: link Learn about the code structure in DS here: link Grab some coding samples here: link, link Consider reading through the unofficial API docs: link Yes, it's very optimistic to call this proper documentations. If you have any particular problems, use the search bar up there. If you can't find anything in the mod forums (make sure to search in the forums, not the individual thread), post the issue in a new topic or on this thread. I suggest you look at other mods if you need inspiration for how to achieve the perks. By the way, in Lua, blocks don't use face brackets, they start with a key word (e.g. "do") and end with the key word "end". Variables are not strictly typed, a string variable can be set to a number without issue. Functions don't require an particular amount of parameters. Things never start with 0, always with 1. Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-707185 Share on other sites More sharing options...
greenglacier Posted January 9, 2016 Share Posted January 9, 2016 @Mobbstar,@Asiru.Our lord has been spoken. Now appreciate his wisdom and do an offering to him. Like a sacrifice. Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-707190 Share on other sites More sharing options...
Asiru Posted January 9, 2016 Author Share Posted January 9, 2016 (edited) Ah, yes. I know the tutorials. I'll go through them and work carefully. Thanks for the help, and the Lua background! Edit: Just for clarity's sake, is there any difference I should know between creating a new character or a new item with special mechanics? I think everything in DS is an entity, so I'd assume you could do some pretty weird stuff. Edited January 10, 2016 by Asiru Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-707208 Share on other sites More sharing options...
Mobbstar Posted January 10, 2016 Share Posted January 10, 2016 Ah, yes. I know the tutorials. I'll go through them and work carefully. Thanks for the help, and the Lua background! Edit: Just for clarity's sake, is there any difference I should know between creating a new character or a new item with special mechanics? I think everything in DS is an entity, so I'd assume you could do some pretty weird stuff. Characters are created with a special function, which sets everything needed up. This makes it easier to set a starting inventory (you simply pass a table/array to said function), for example. Other than that, they're a prefab just like a tree, the fire hound flames and WX's rain sparks. Yes, you can do weird stuff with prefabs. HeavenFall's Summons mod has invisible prefabs which remove themselves after casting magic (I don't know whether it still works). Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-707385 Share on other sites More sharing options...
Asiru Posted January 12, 2016 Author Share Posted January 12, 2016 @Mobbstar Well, everything I've done so far has been successful. Thanks for the help! Now comes all the custom parts that I'm hoping will make my character unique. So. I'm trying to make an item that you can use on predefined types of mobs. I'm assuming it's something like a fire staff, with a spellcaster component? Anyway, the "spell" is supposed to take the animal you clicked the spell on, and make it be friendly to the player for exactly 1 game day. Do you have any tips on making the mob friendly (even if it's naturally hostile), making the actual spell work, and making it last for a day (I'm guessing the timer component)? A second, less important thing, how would I create a "cast spell" animation? I mean the fire staff is just swung wildly downwards, which doesn't quite work for my spell (there's no projectile). Would it just be the "PlayAnimation" function for the character? I'm sure you're crazy busy, but any help you could provide would be awesome. Thanks again! Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-708301 Share on other sites More sharing options...
Mobbstar Posted January 12, 2016 Share Posted January 12, 2016 @Asiru, It's difficult to "pacify" a creature, they all handle this kind of thing a little bit differently. But what they all have in common is the combat component, which keeps track of the current target and also carries the retarget functions. Repeatedly setting the target to none could work, but disabling the target and retarget functions should make things work smoothly. I may be overthinking this problem right now, but I don't think there's a "disable combat", only "disable whole brain/stategraph" and "delete combat". As for animation, look at the ancient staves (staffs?). The green, yellow and purple staff all use a longer casting animation. Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-708308 Share on other sites More sharing options...
Asiru Posted January 13, 2016 Author Share Posted January 13, 2016 @Asiru, It's difficult to "pacify" a creature, they all handle this kind of thing a little bit differently. But what they all have in common is the combat component, which keeps track of the current target and also carries the retarget functions. Repeatedly setting the target to none could work, but disabling the target and retarget functions should make things work smoothly. I may be overthinking this problem right now, but I don't think there's a "disable combat", only "disable whole brain/stategraph" and "delete combat". As for animation, look at the ancient staves (staffs?). The green, yellow and purple staff all use a longer casting animation. Hmm. That's unfortunate about the mobs, but I understand it. I was hoping it would be something like befriending pigs, where they'd fight for you (maybe not chop down trees with their fists though haha). Maybe I just don't know enough about it, but I'd think that disabling the targeting functions wouldn't allow them to fight for the player either. Just one last small thing about Lua. If I want to set the "spell function", as the spellcaster component suggests, how would I go about creating that function? I think I understand the whole "local function name(parameters)" thing, but how could I take the mob that was clicked into those parameters? I'm assuming to access the mob inside the function, I'd just use the name I used in the parameters? Are there any keywords I need to look out for (bit of a silly question)? You've been a great help! Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-708401 Share on other sites More sharing options...
Mobbstar Posted January 13, 2016 Share Posted January 13, 2016 (edited) @Asiru, you can either create a variable for that function or create it while setting it. local function MySpellFn(...)--spellend local function fn()--creating the instanceinst.components.spellcaster:SetSpellFn(MySpellFn)--codeend --OR-- local function fn()--creating the instanceinst.components.spellcaster:SetSpellFn(function(...)--spellend)--codeend By searching for occurances of the respective variable in the spellcaster component, you can figure out the possible arguments. Why didn't Klei list the possible arguments anywhere in form of comments? I don't know! MySpellFn(inst, target_entity, target_pos) EDIT: And yes, by temporarily changing the targeting functions of a creature, you'd make them entirely incapable of fighting. Alternatively, you could "extend" the function and restore the original later, though that is more of a hack than anything else. local old_fn = sample_fn --keep a pointer to the original functionsample_fn = function(...)--code if old_fn then old_fn(...) end--codeend It's not ideal. If several mods do this, one might "extend" a function and another might take the modified function as original, which might be restored at the end instead of the actual original function. Edited January 13, 2016 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-708564 Share on other sites More sharing options...
Asiru Posted January 13, 2016 Author Share Posted January 13, 2016 @Asiru, you can either create a variable for that function or create it while setting it. local function MySpellFn(...)--spellend local function fn()--creating the instanceinst.components.spellcaster:SetSpellFn(MySpellFn)--codeend --OR-- local function fn()--creating the instanceinst.components.spellcaster:SetSpellFn(function(...)--spellend)--codeend By searching for occurances of the respective variable in the spellcaster component, you can figure out the possible arguments. Why didn't Klei list the possible arguments anywhere in form of comments? I don't know! MySpellFn(inst, target_entity, target_pos) EDIT: And yes, by temporarily changing the targeting functions of a creature, you'd make them entirely incapable of fighting. Alternatively, you could "extend" the function and restore the original later, though that is more of a hack than anything else. local old_fn = sample_fn --keep a pointer to the original functionsample_fn = function(...)--code if old_fn then old_fn(...) end--codeend It's not ideal. If several mods do this, one might "extend" a function and another might take the modified function as original, which might be restored at the end instead of the actual original function. I see...hm. Well, I can poke around for a bit, see what I can do. If nothing works out, at least it was a learning experience! I'm sorry haha, I did say this was like 'the last thing I needed' or something, but I've been digging around for a while looking for the functions associated with "entity". It's a bit of an ask, but is there any easier way I'd be able to find those? Other than "Ctrl+F"-ing through the whole scripts folder? Slightly off-topic: I couldn't really find a list of event names on the forums or unofficial docs (good potential there, by the way), so I thought maybe I would find all the event names in the scripts folder and pool them all into one resource. Just for the modders really. Do you think the docs would take that kind of thing? Disregard me if you have nothing to do with the unofficial docs. Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-708625 Share on other sites More sharing options...
MarvelousJared Posted January 16, 2016 Share Posted January 16, 2016 Hi, I started making a character following along with Dleowolf's tutorial and the video that was posted. Everything was going well. Unfortunately when I try to load up my character, they do not show up anymore. It says that it is out of date. I was curious what the current API version for standard Don't Starve is. Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-710167 Share on other sites More sharing options...
Mobbstar Posted January 17, 2016 Share Posted January 17, 2016 14 hours ago, MarvelousJared said: Hi, I started making a character following along with Dleowolf's tutorial and the video that was posted. Everything was going well. Unfortunately when I try to load up my character, they do not show up anymore. It says that it is out of date. I was curious what the current API version for standard Don't Starve is. api_version = 6 api_version_dst = 10 Link to comment https://forums.kleientertainment.com/forums/topic/62184-help-custom-character/#findComment-710444 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now